From 5865607241ff8253849bc9f8243db79c0d0862ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 13 Jan 2022 11:08:41 +0000 Subject: [PATCH 1/9] Read additional graph drive prop from space.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- graph/pkg/service/v0/driveitems.go | 144 ++++++++++++++++ graph/pkg/service/v0/drives.go | 267 ++++++++++++++++------------- graph/pkg/service/v0/graph.go | 2 + graph/pkg/service/v0/service.go | 2 + 4 files changed, 297 insertions(+), 118 deletions(-) create mode 100644 graph/pkg/service/v0/driveitems.go diff --git a/graph/pkg/service/v0/driveitems.go b/graph/pkg/service/v0/driveitems.go new file mode 100644 index 000000000..870aee2d8 --- /dev/null +++ b/graph/pkg/service/v0/driveitems.go @@ -0,0 +1,144 @@ +package svc + +import ( + "context" + "net/http" + "path" + "path/filepath" + "time" + + cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" + storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" + "github.com/go-chi/render" + libregraph "github.com/owncloud/libre-graph-api-go" + "github.com/owncloud/ocis/graph/pkg/service/v0/errorcode" +) + +// GetRootDriveChildren implements the Service interface. +func (g Graph) GetRootDriveChildren(w http.ResponseWriter, r *http.Request) { + g.logger.Info().Msg("Calling GetRootDriveChildren") + ctx := r.Context() + + client, err := g.GetClient() + if err != nil { + g.logger.Error().Err(err).Msg("could not get client") + errorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, err.Error()) + return + } + + res, err := client.GetHome(ctx, &storageprovider.GetHomeRequest{}) + switch { + case err != nil: + g.logger.Error().Err(err).Msg("error sending get home grpc request") + errorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, err.Error()) + return + case res.Status.Code != cs3rpc.Code_CODE_OK: + if res.Status.Code == cs3rpc.Code_CODE_NOT_FOUND { + errorcode.ItemNotFound.Render(w, r, http.StatusNotFound, res.Status.Message) + return + } + g.logger.Error().Err(err).Msg("error sending get home grpc request") + errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, res.Status.Message) + return + } + + lRes, err := client.ListContainer(ctx, &storageprovider.ListContainerRequest{ + Ref: &storageprovider.Reference{ + Path: res.Path, + }, + }) + switch { + case err != nil: + g.logger.Error().Err(err).Msg("error sending list container grpc request") + errorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, err.Error()) + return + case res.Status.Code != cs3rpc.Code_CODE_OK: + if res.Status.Code == cs3rpc.Code_CODE_NOT_FOUND { + errorcode.ItemNotFound.Render(w, r, http.StatusNotFound, res.Status.Message) + return + } + if res.Status.Code == cs3rpc.Code_CODE_PERMISSION_DENIED { + // TODO check if we should return 404 to not disclose existing items + errorcode.AccessDenied.Render(w, r, http.StatusForbidden, res.Status.Message) + return + } + g.logger.Error().Err(err).Msg("error sending list container grpc request") + errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, res.Status.Message) + return + } + + files, err := formatDriveItems(lRes.Infos) + if err != nil { + g.logger.Error().Err(err).Msg("error encoding response as json") + errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error()) + return + } + + render.Status(r, http.StatusOK) + render.JSON(w, r, &listResponse{Value: files}) +} + +func (g Graph) getDriveItem(ctx context.Context, root *storageprovider.ResourceId, relativePath string) (*libregraph.DriveItem, error) { + + client, err := g.GetClient() + if err != nil { + g.logger.Error().Err(err).Msg("error creating grpc client") + return nil, err + } + + ref := &storageprovider.Reference{ + ResourceId: root, + // the path is always relative to the root of the drive, not the location of the .config/ocis/space.yaml file + Path: filepath.Join("./", relativePath), + } + res, err := client.Stat(ctx, &storageprovider.StatRequest{Ref: ref}) + if res.Status.Code != cs3rpc.Code_CODE_OK { + return nil, err + } + + return cs3ResourceToDriveItem(res.Info) +} + +func formatDriveItems(mds []*storageprovider.ResourceInfo) ([]*libregraph.DriveItem, error) { + responses := make([]*libregraph.DriveItem, 0, len(mds)) + for i := range mds { + res, err := cs3ResourceToDriveItem(mds[i]) + if err != nil { + return nil, err + } + responses = append(responses, res) + } + + return responses, nil +} + +func cs3TimestampToTime(t *types.Timestamp) time.Time { + return time.Unix(int64(t.Seconds), int64(t.Nanos)) +} + +func cs3ResourceToDriveItem(res *storageprovider.ResourceInfo) (*libregraph.DriveItem, error) { + size := new(int64) + *size = int64(res.Size) // uint64 -> int :boom: + name := path.Base(res.Path) + + driveItem := &libregraph.DriveItem{ + Id: &res.Id.OpaqueId, + Name: &name, + ETag: &res.Etag, + Size: size, + } + if res.Mtime != nil { + lastModified := cs3TimestampToTime(res.Mtime) + driveItem.LastModifiedDateTime = &lastModified + } + if res.Type == storageprovider.ResourceType_RESOURCE_TYPE_FILE { + driveItem.File = &libregraph.OpenGraphFile{ // FIXME We cannot use libregraph.File here because the openapi codegenerator autodetects 'File' as a go type ... + MimeType: &res.MimeType, + } + } + if res.Type == storageprovider.ResourceType_RESOURCE_TYPE_CONTAINER { + driveItem.Folder = &libregraph.Folder{} + } + return driveItem, nil +} diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index 12059dd0b..275847697 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -2,15 +2,15 @@ package svc import ( "context" + "crypto/tls" "encoding/json" "fmt" + "io/ioutil" "math" "net/http" "net/url" - "path" "strconv" "strings" - "time" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" @@ -18,6 +18,7 @@ import ( storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ctxpkg "github.com/cs3org/reva/pkg/ctx" + "github.com/cs3org/reva/pkg/rhttp" "github.com/go-chi/chi/v5" "github.com/go-chi/render" libregraph "github.com/owncloud/libre-graph-api-go" @@ -25,10 +26,17 @@ import ( "github.com/owncloud/ocis/ocis-pkg/service/grpc" sproto "github.com/owncloud/ocis/settings/pkg/proto/v0" settingsSvc "github.com/owncloud/ocis/settings/pkg/service/v0" + "gopkg.in/yaml.v2" merrors "go-micro.dev/v4/errors" ) +const ( + // "github.com/cs3org/reva/internal/http/services/datagateway" is internal so we redeclare it here + // TokenTransportHeader holds the header key for the reva transfer token + TokenTransportHeader = "X-Reva-Transfer" +) + // GetDrives implements the Service interface. func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request) { g.logger.Info().Msg("Calling GetDrives") @@ -100,70 +108,6 @@ func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request) { render.JSON(w, r, &listResponse{Value: files}) } -// GetRootDriveChildren implements the Service interface. -func (g Graph) GetRootDriveChildren(w http.ResponseWriter, r *http.Request) { - g.logger.Info().Msg("Calling GetRootDriveChildren") - ctx := r.Context() - - client, err := g.GetClient() - if err != nil { - g.logger.Error().Err(err).Msg("could not get client") - errorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, err.Error()) - return - } - - res, err := client.GetHome(ctx, &storageprovider.GetHomeRequest{}) - switch { - case err != nil: - g.logger.Error().Err(err).Msg("error sending get home grpc request") - errorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, err.Error()) - return - case res.Status.Code != cs3rpc.Code_CODE_OK: - if res.Status.Code == cs3rpc.Code_CODE_NOT_FOUND { - errorcode.ItemNotFound.Render(w, r, http.StatusNotFound, res.Status.Message) - return - } - g.logger.Error().Err(err).Msg("error sending get home grpc request") - errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, res.Status.Message) - return - } - - lRes, err := client.ListContainer(ctx, &storageprovider.ListContainerRequest{ - Ref: &storageprovider.Reference{ - Path: res.Path, - }, - }) - switch { - case err != nil: - g.logger.Error().Err(err).Msg("error sending list container grpc request") - errorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, err.Error()) - return - case res.Status.Code != cs3rpc.Code_CODE_OK: - if res.Status.Code == cs3rpc.Code_CODE_NOT_FOUND { - errorcode.ItemNotFound.Render(w, r, http.StatusNotFound, res.Status.Message) - return - } - if res.Status.Code == cs3rpc.Code_CODE_PERMISSION_DENIED { - // TODO check if we should return 404 to not disclose existing items - errorcode.AccessDenied.Render(w, r, http.StatusForbidden, res.Status.Message) - return - } - g.logger.Error().Err(err).Msg("error sending list container grpc request") - errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, res.Status.Message) - return - } - - files, err := formatDriveItems(lRes.Infos) - if err != nil { - g.logger.Error().Err(err).Msg("error encoding response as json") - errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error()) - return - } - - render.Status(r, http.StatusOK) - render.JSON(w, r, &listResponse{Value: files}) -} - // CreateDrive creates a storage drive (space). func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) { us, ok := ctxpkg.ContextGetUser(r.Context()) @@ -350,40 +294,38 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) { render.JSON(w, r, updatedDrive) } -func cs3TimestampToTime(t *types.Timestamp) time.Time { - return time.Unix(int64(t.Seconds), int64(t.Nanos)) -} - -func cs3ResourceToDriveItem(res *storageprovider.ResourceInfo) (*libregraph.DriveItem, error) { - size := new(int64) - *size = int64(res.Size) // uint64 -> int :boom: - name := path.Base(res.Path) - - driveItem := &libregraph.DriveItem{ - Id: &res.Id.OpaqueId, - Name: &name, - ETag: &res.Etag, - Size: size, - } - if res.Mtime != nil { - lastModified := cs3TimestampToTime(res.Mtime) - driveItem.LastModifiedDateTime = &lastModified - } - if res.Type == storageprovider.ResourceType_RESOURCE_TYPE_FILE { - driveItem.File = &libregraph.OpenGraphFile{ // FIXME We cannot use libregraph.File here because the openapi codegenerator autodetects 'File' as a go type ... - MimeType: &res.MimeType, +func (g Graph) formatDrives(ctx context.Context, baseURL *url.URL, mds []*storageprovider.StorageSpace) ([]*libregraph.Drive, error) { + responses := make([]*libregraph.Drive, 0, len(mds)) + for _, space := range mds { + res, err := cs3StorageSpaceToDrive(baseURL, space) + if err != nil { + return nil, err } - } - if res.Type == storageprovider.ResourceType_RESOURCE_TYPE_CONTAINER { - driveItem.Folder = &libregraph.Folder{} - } - return driveItem, nil -} - -func formatDriveItems(mds []*storageprovider.ResourceInfo) ([]*libregraph.DriveItem, error) { - responses := make([]*libregraph.DriveItem, 0, len(mds)) - for i := range mds { - res, err := cs3ResourceToDriveItem(mds[i]) + spaceYaml, err := g.getSpaceYaml(ctx, space) + if err == nil { + if spaceYaml.Description != "" { + res.Description = &spaceYaml.Description + } + if len(spaceYaml.Special) > 0 { + s := make([]libregraph.DriveItem, 0, len(spaceYaml.Special)) + for name, relativePath := range spaceYaml.Special { + sdi, err := g.getDriveItem(ctx, space.Root, relativePath) + if err != nil { + // TODO log + continue + } + n := name // copy the name to a dedicated variable + sdi.SpecialFolder = &libregraph.SpecialFolder{ + Name: &n, + } + // TODO cache until ./.config/ocis/space.yaml file changes + s = append(s, *sdi) + } + res.Special = &s + } + } + // TODO this overwrites the quota that might already have been mapped in cs3StorageSpaceToDrive above ... move this into the cs3StorageSpaceToDrive method? + res.Quota, err = g.getDriveQuota(ctx, space) if err != nil { return nil, err } @@ -444,27 +386,12 @@ func cs3StorageSpaceToDrive(baseURL *url.URL, space *storageprovider.StorageSpac } } // FIXME use coowner from https://github.com/owncloud/open-graph-api + // TODO read .space.yaml and parse it for description and thumbnail? + // return drive, nil } -func (g Graph) formatDrives(ctx context.Context, baseURL *url.URL, mds []*storageprovider.StorageSpace) ([]*libregraph.Drive, error) { - responses := make([]*libregraph.Drive, 0, len(mds)) - for i := range mds { - res, err := cs3StorageSpaceToDrive(baseURL, mds[i]) - if err != nil { - return nil, err - } - res.Quota, err = g.getDriveQuota(ctx, mds[i]) - if err != nil { - return nil, err - } - responses = append(responses, res) - } - - return responses, nil -} - func (g Graph) getDriveQuota(ctx context.Context, space *storageprovider.StorageSpace) (*libregraph.Quota, error) { client, err := g.GetClient() if err != nil { @@ -484,13 +411,13 @@ func (g Graph) getDriveQuota(ctx context.Context, space *storageprovider.Storage res, err := client.GetQuota(ctx, req) switch { case err != nil: - g.logger.Error().Err(err).Msg("error sending get quota grpc request") + g.logger.Error().Err(err).Msg("could not call GetQuota") return nil, nil case res.Status.Code == cs3rpc.Code_CODE_UNIMPLEMENTED: // TODO well duh return nil, nil case res.Status.Code != cs3rpc.Code_CODE_OK: - g.logger.Error().Err(err).Msg("error sending sending get quota grpc request") + g.logger.Error().Err(err).Msg("error sending get quota grpc request") return nil, err } @@ -509,6 +436,110 @@ func (g Graph) getDriveQuota(ctx context.Context, space *storageprovider.Storage return &qta, nil } +type SpaceYaml struct { + Version string `yaml:"version"` + Description string `yaml:"description"` + // map of {name} -> {relative path to resource}, eg: + // readme -> readme.md + // image -> .config/ocis/space.png + Special map[string]string `yaml:"special"` +} + +// generates a space root stat cache key used to detect changes in a space +func spaceRootStatKey(id *storageprovider.ResourceId) string { + if id == nil || id.StorageId == "" || id.OpaqueId == "" { + return "" + } + return "sid:" + id.StorageId + "!oid:" + id.OpaqueId +} + +type spaceYamlEntry struct { + spaceYaml SpaceYaml + spaceYamlMtime *types.Timestamp + rootMtime *types.Timestamp +} + +func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageSpace) (*SpaceYaml, error) { + + /*} + if syc, err := g.spaceYamlCache.Get(spaceRootStatKey(space.Root)); err == nil { + if spaceYamlEntry, ok := spaceYamlEntry(syc) { + if spaceYamlEntry.rootMtime != nil && space.Mtime != nil { + + + } + } + } + */ + // TODO try reading from cache, invalidate when space mtime changes + client, err := g.GetClient() + if err != nil { + g.logger.Error().Err(err).Msg("error creating grpc client") + return nil, err + } + dlReq := &storageprovider.InitiateFileDownloadRequest{ + Ref: &storageprovider.Reference{ + ResourceId: &storageprovider.ResourceId{ + StorageId: space.Root.StorageId, + OpaqueId: space.Root.OpaqueId, + }, + Path: "./.config/ocis/space.yaml", + }, + } + // ctx := metadata.AppendToOutgoingContext(ctx, "If-Modified-Since", TODO send cached mtime of space yaml ) + // TODO initiate file download only if the etag does not match + rsp, err := client.InitiateFileDownload(ctx, dlReq) + if err != nil { + return nil, err + } + if rsp.Status.Code != cs3rpc.Code_CODE_OK { + return nil, fmt.Errorf("could not initiate download of %s: %s", dlReq.Ref.Path, rsp.Status.Message) + } + var ep, tk string + for _, p := range rsp.Protocols { + if p.Protocol == "spaces" { + ep, tk = p.DownloadEndpoint, p.Token + } + } + if ep == "" { + return nil, fmt.Errorf("space does not support the spaces download protocol") + } + + httpReq, err := rhttp.NewRequest(ctx, "GET", ep, nil) + if err != nil { + return nil, err + } + // httpReq.Header.Set(ctxpkg.TokenHeader, auth) + httpReq.Header.Set(TokenTransportHeader, tk) + + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{ + InsecureSkipVerify: true, //nolint:gosec + } + httpClient := &http.Client{} + + resp, err := httpClient.Do(httpReq) // nolint:bodyclose + if err != nil { + return nil, err + } + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("could not get the .space.yaml. Request returned with statuscode %d ", resp.StatusCode) + } + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + spaceYaml := &SpaceYaml{} + //if err := yaml.NewDecoder(resp.Body).Decode(spaceYaml); err != nil { + if err := yaml.Unmarshal(body, spaceYaml); err != nil { + return nil, err + } + + return spaceYaml, nil +} + func calculateQuotaState(total int64, used int64) (state string) { percent := (float64(used) / float64(total)) * 100 diff --git a/graph/pkg/service/v0/graph.go b/graph/pkg/service/v0/graph.go index 251bd0eda..2b7cb0141 100644 --- a/graph/pkg/service/v0/graph.go +++ b/graph/pkg/service/v0/graph.go @@ -3,6 +3,7 @@ package svc import ( "net/http" + "github.com/ReneKroon/ttlcache/v2" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" "github.com/cs3org/reva/pkg/rgrpc/todo/pool" "github.com/go-chi/chi/v5" @@ -17,6 +18,7 @@ type Graph struct { mux *chi.Mux logger *log.Logger identityBackend identity.Backend + spaceYamlCache *ttlcache.Cache } // ServeHTTP implements the Service interface. diff --git a/graph/pkg/service/v0/service.go b/graph/pkg/service/v0/service.go index 36d0cf451..c9b98d41c 100644 --- a/graph/pkg/service/v0/service.go +++ b/graph/pkg/service/v0/service.go @@ -3,6 +3,7 @@ package svc import ( "net/http" + "github.com/ReneKroon/ttlcache/v2" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" @@ -55,6 +56,7 @@ func NewService(opts ...Option) Service { mux: m, logger: &options.Logger, identityBackend: backend, + spaceYamlCache: ttlcache.NewCache(), } m.Route(options.Config.HTTP.Root, func(r chi.Router) { From 6b935e47d00d70ba998db16baff42cd406c44850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 14 Jan 2022 13:54:00 +0000 Subject: [PATCH 2/9] return WebDavURL to special resources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- graph/pkg/service/v0/drives.go | 35 ++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index 275847697..1f6c1aad6 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -9,6 +9,7 @@ import ( "math" "net/http" "net/url" + "path/filepath" "strconv" "strings" @@ -19,6 +20,7 @@ import ( types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ctxpkg "github.com/cs3org/reva/pkg/ctx" "github.com/cs3org/reva/pkg/rhttp" + "github.com/cs3org/reva/pkg/utils" "github.com/go-chi/chi/v5" "github.com/go-chi/render" libregraph "github.com/owncloud/libre-graph-api-go" @@ -318,6 +320,9 @@ func (g Graph) formatDrives(ctx context.Context, baseURL *url.URL, mds []*storag sdi.SpecialFolder = &libregraph.SpecialFolder{ Name: &n, } + webdavURL := baseURL.String() + filepath.Join(space.Id.OpaqueId, relativePath) + sdi.WebDavUrl = &webdavURL + // TODO cache until ./.config/ocis/space.yaml file changes s = append(s, *sdi) } @@ -459,18 +464,28 @@ type spaceYamlEntry struct { rootMtime *types.Timestamp } +/* +parent reference could be used to indicate the parent + + "parentReference": { + "driveId": "c12644a14b0a7750", + "driveType": "personal", + "id": "C12644A14B0A7750!1383", + "name": "Screenshots", + "path": "/drive/root:/Bilder/Screenshots" + }, + +*/ func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageSpace) (*SpaceYaml, error) { - /*} + // if the root mtime if syc, err := g.spaceYamlCache.Get(spaceRootStatKey(space.Root)); err == nil { - if spaceYamlEntry, ok := spaceYamlEntry(syc) { + if spaceYamlEntry, ok := syc.(spaceYamlEntry); ok { if spaceYamlEntry.rootMtime != nil && space.Mtime != nil { - - + utils.LaterTS(spaceYamlEntry.rootMtime, space.Mtime) } } } - */ // TODO try reading from cache, invalidate when space mtime changes client, err := g.GetClient() if err != nil { @@ -484,9 +499,17 @@ func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageS OpaqueId: space.Root.OpaqueId, }, Path: "./.config/ocis/space.yaml", + // TODO what if a public share should have a readme and an image? + // should we just default to a ./Readme.md and ./folder.png/jpg? + // what existing conventions could we use? .desktop file? .env file? + // how should users set a README fo public link file shares? They only point to a file, not a folder that could contain a readme and image + // should weo reuse the readme and image of the space that contains the file shared via link? }, } - // ctx := metadata.AppendToOutgoingContext(ctx, "If-Modified-Since", TODO send cached mtime of space yaml ) + //ctx = metadata.AppendToOutgoingContext(ctx, headers.IfModifiedSince, "TODO grpc has no official cache headers") + // FIXME how can clients retrieve a file just by id? + // The drive Item does currently not have a relative path ... + // so clients would have to make a request by id ... but webdav cannot do that ... // TODO initiate file download only if the etag does not match rsp, err := client.InitiateFileDownload(ctx, dlReq) if err != nil { From 5b97a12acd5a6e070949ed78ebcd9eb31497b632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 14 Jan 2022 14:14:35 +0000 Subject: [PATCH 3/9] refactor headers into a dedicated package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- graph/pkg/service/v0/drives.go | 21 ++------------------- graph/pkg/service/v0/net/headers/headers.go | 9 +++++++++ 2 files changed, 11 insertions(+), 19 deletions(-) create mode 100644 graph/pkg/service/v0/net/headers/headers.go diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index 1f6c1aad6..73f75f75c 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -25,6 +25,7 @@ import ( "github.com/go-chi/render" libregraph "github.com/owncloud/libre-graph-api-go" "github.com/owncloud/ocis/graph/pkg/service/v0/errorcode" + "github.com/owncloud/ocis/graph/pkg/service/v0/net/headers" "github.com/owncloud/ocis/ocis-pkg/service/grpc" sproto "github.com/owncloud/ocis/settings/pkg/proto/v0" settingsSvc "github.com/owncloud/ocis/settings/pkg/service/v0" @@ -33,12 +34,6 @@ import ( merrors "go-micro.dev/v4/errors" ) -const ( - // "github.com/cs3org/reva/internal/http/services/datagateway" is internal so we redeclare it here - // TokenTransportHeader holds the header key for the reva transfer token - TokenTransportHeader = "X-Reva-Transfer" -) - // GetDrives implements the Service interface. func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request) { g.logger.Info().Msg("Calling GetDrives") @@ -464,18 +459,6 @@ type spaceYamlEntry struct { rootMtime *types.Timestamp } -/* -parent reference could be used to indicate the parent - - "parentReference": { - "driveId": "c12644a14b0a7750", - "driveType": "personal", - "id": "C12644A14B0A7750!1383", - "name": "Screenshots", - "path": "/drive/root:/Bilder/Screenshots" - }, - -*/ func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageSpace) (*SpaceYaml, error) { // if the root mtime @@ -533,7 +516,7 @@ func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageS return nil, err } // httpReq.Header.Set(ctxpkg.TokenHeader, auth) - httpReq.Header.Set(TokenTransportHeader, tk) + httpReq.Header.Set(headers.TokenTransportHeader, tk) http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{ InsecureSkipVerify: true, //nolint:gosec diff --git a/graph/pkg/service/v0/net/headers/headers.go b/graph/pkg/service/v0/net/headers/headers.go new file mode 100644 index 000000000..4df20e10a --- /dev/null +++ b/graph/pkg/service/v0/net/headers/headers.go @@ -0,0 +1,9 @@ +package headers + +const ( + // "github.com/cs3org/reva/internal/http/services/datagateway" is internal so we redeclare it here + // TokenTransportHeader holds the header key for the reva transfer token + TokenTransportHeader = "X-Reva-Transfer" + // IfModifiedSince is used to mimic/pass on caching headers when using grpc + IfModifiedSince = "If-Modified-Since" +) From 942bd0b98df921cba79bce1d82a7ff3f6a061b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 14 Jan 2022 15:50:57 +0000 Subject: [PATCH 4/9] add initial ok & not found caching, config, logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- graph/pkg/config/config.go | 8 ++- graph/pkg/config/defaultconfig.go | 1 + graph/pkg/service/v0/driveitems.go | 6 +- graph/pkg/service/v0/drives.go | 104 ++++++++++++++++++----------- graph/pkg/service/v0/graph.go | 10 +-- graph/pkg/service/v0/service.go | 10 +-- 6 files changed, 87 insertions(+), 52 deletions(-) diff --git a/graph/pkg/config/config.go b/graph/pkg/config/config.go index d094cf54f..09a00b25c 100644 --- a/graph/pkg/config/config.go +++ b/graph/pkg/config/config.go @@ -28,9 +28,11 @@ type Config struct { } type Spaces struct { - WebDavBase string `ocisConfig:"webdav_base" env:"OCIS_URL;GRAPH_SPACES_WEBDAV_BASE"` - WebDavPath string `ocisConfig:"webdav_path" env:"GRAPH_SPACES_WEBDAV_PATH"` - DefaultQuota string `ocisConfig:"default_quota" env:"GRAPH_SPACES_DEFAULT_QUOTA"` + WebDavBase string `ocisConfig:"webdav_base" env:"OCIS_URL;GRAPH_SPACES_WEBDAV_BASE"` + WebDavPath string `ocisConfig:"webdav_path" env:"GRAPH_SPACES_WEBDAV_PATH"` + DefaultQuota string `ocisConfig:"default_quota" env:"GRAPH_SPACES_DEFAULT_QUOTA"` + Insecure bool `ocisConfig:"insecure" env:"OCIS_INSECURE;GRAPH_SPACES_INSECURE"` + ExtendedSpacePropertiesCacheTTL int `ocisConfig:"extended_space_properties_cache_ttl" env:"GRAPH_SPACES_EXTENDED_SPACE_PROPERTIES_CACHE_TTL"` } type LDAP struct { diff --git a/graph/pkg/config/defaultconfig.go b/graph/pkg/config/defaultconfig.go index 3bb022786..c46d27a39 100644 --- a/graph/pkg/config/defaultconfig.go +++ b/graph/pkg/config/defaultconfig.go @@ -24,6 +24,7 @@ func DefaultConfig() *Config { WebDavBase: "https://localhost:9200", WebDavPath: "/dav/spaces/", DefaultQuota: "1000000000", + Insecure: false, }, Identity: Identity{ Backend: "cs3", diff --git a/graph/pkg/service/v0/driveitems.go b/graph/pkg/service/v0/driveitems.go index 870aee2d8..e695353c1 100644 --- a/graph/pkg/service/v0/driveitems.go +++ b/graph/pkg/service/v0/driveitems.go @@ -2,6 +2,7 @@ package svc import ( "context" + "fmt" "net/http" "path" "path/filepath" @@ -93,9 +94,12 @@ func (g Graph) getDriveItem(ctx context.Context, root *storageprovider.ResourceI Path: filepath.Join("./", relativePath), } res, err := client.Stat(ctx, &storageprovider.StatRequest{Ref: ref}) - if res.Status.Code != cs3rpc.Code_CODE_OK { + if err != nil { return nil, err } + if res.Status.Code != cs3rpc.Code_CODE_OK { + return nil, fmt.Errorf("could not stat %s: %s", ref, res.Status.Message) + } return cs3ResourceToDriveItem(res.Info) } diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index 73f75f75c..20cfa8f1f 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -5,13 +5,13 @@ import ( "crypto/tls" "encoding/json" "fmt" - "io/ioutil" "math" "net/http" "net/url" "path/filepath" "strconv" "strings" + "time" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" @@ -20,7 +20,6 @@ import ( types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ctxpkg "github.com/cs3org/reva/pkg/ctx" "github.com/cs3org/reva/pkg/rhttp" - "github.com/cs3org/reva/pkg/utils" "github.com/go-chi/chi/v5" "github.com/go-chi/render" libregraph "github.com/owncloud/libre-graph-api-go" @@ -298,17 +297,22 @@ func (g Graph) formatDrives(ctx context.Context, baseURL *url.URL, mds []*storag if err != nil { return nil, err } - spaceYaml, err := g.getSpaceYaml(ctx, space) + spaceProperties, err := g.getExtendedSpaceProperties(ctx, space) + if err != nil { + g.logger.Error().Err(err).Interface("space", space).Msg("error reading extendedSpaceProperties") + continue + } if err == nil { - if spaceYaml.Description != "" { - res.Description = &spaceYaml.Description + if spaceProperties.Description != "" { + res.Description = &spaceProperties.Description } - if len(spaceYaml.Special) > 0 { - s := make([]libregraph.DriveItem, 0, len(spaceYaml.Special)) - for name, relativePath := range spaceYaml.Special { + if len(spaceProperties.Special) > 0 { + s := make([]libregraph.DriveItem, 0, len(spaceProperties.Special)) + for name, relativePath := range spaceProperties.Special { sdi, err := g.getDriveItem(ctx, space.Root, relativePath) if err != nil { - // TODO log + // TODO cach not found response + g.logger.Debug().Err(err).Interface("space", space).Interface("path", relativePath).Msg("error fetching drive item") continue } n := name // copy the name to a dedicated variable @@ -386,8 +390,6 @@ func cs3StorageSpaceToDrive(baseURL *url.URL, space *storageprovider.StorageSpac } } // FIXME use coowner from https://github.com/owncloud/open-graph-api - // TODO read .space.yaml and parse it for description and thumbnail? - // return drive, nil } @@ -436,13 +438,14 @@ func (g Graph) getDriveQuota(ctx context.Context, space *storageprovider.Storage return &qta, nil } -type SpaceYaml struct { - Version string `yaml:"version"` - Description string `yaml:"description"` +// ExtendedSpaceProperties are stored in a file +type ExtendedSpaceProperties struct { + Version string `yaml:"version" json:"version"` + Description string `yaml:"description" json:"description"` // map of {name} -> {relative path to resource}, eg: // readme -> readme.md // image -> .config/ocis/space.png - Special map[string]string `yaml:"special"` + Special map[string]string `yaml:"special" json:"special"` } // generates a space root stat cache key used to detect changes in a space @@ -453,26 +456,26 @@ func spaceRootStatKey(id *storageprovider.ResourceId) string { return "sid:" + id.StorageId + "!oid:" + id.OpaqueId } -type spaceYamlEntry struct { - spaceYaml SpaceYaml - spaceYamlMtime *types.Timestamp - rootMtime *types.Timestamp +type spacePropertiesEntry struct { + spaceProperties ExtendedSpaceProperties + rootMtime *types.Timestamp } -func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageSpace) (*SpaceYaml, error) { +func (g Graph) getExtendedSpaceProperties(ctx context.Context, space *storageprovider.StorageSpace) (*ExtendedSpaceProperties, error) { - // if the root mtime - if syc, err := g.spaceYamlCache.Get(spaceRootStatKey(space.Root)); err == nil { - if spaceYamlEntry, ok := syc.(spaceYamlEntry); ok { - if spaceYamlEntry.rootMtime != nil && space.Mtime != nil { - utils.LaterTS(spaceYamlEntry.rootMtime, space.Mtime) + // if the root is older or equal to our cache we can reuse the cached extended spaces properties + if syc, err := g.spacePropertiesCache.Get(spaceRootStatKey(space.Root)); err == nil { + if spe, ok := syc.(spacePropertiesEntry); ok { + if spe.rootMtime != nil && space.Mtime != nil { + if spe.rootMtime.Seconds > space.Mtime.Seconds { // second precision is good enough + return &spe.spaceProperties, nil + } } } } - // TODO try reading from cache, invalidate when space mtime changes + client, err := g.GetClient() if err != nil { - g.logger.Error().Err(err).Msg("error creating grpc client") return nil, err } dlReq := &storageprovider.InitiateFileDownloadRequest{ @@ -498,9 +501,22 @@ func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageS if err != nil { return nil, err } - if rsp.Status.Code != cs3rpc.Code_CODE_OK { + switch rsp.Status.Code { + case cs3rpc.Code_CODE_OK: + // continue + case cs3rpc.Code_CODE_NOT_FOUND: + // cache an empty instance + spacePropertiesEntry := spacePropertiesEntry{ + spaceProperties: ExtendedSpaceProperties{}, + rootMtime: space.Mtime, + } + g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)) + + return &spacePropertiesEntry.spaceProperties, nil + default: return nil, fmt.Errorf("could not initiate download of %s: %s", dlReq.Ref.Path, rsp.Status.Message) } + var ep, tk string for _, p := range rsp.Protocols { if p.Protocol == "spaces" { @@ -515,11 +531,10 @@ func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageS if err != nil { return nil, err } - // httpReq.Header.Set(ctxpkg.TokenHeader, auth) httpReq.Header.Set(headers.TokenTransportHeader, tk) http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{ - InsecureSkipVerify: true, //nolint:gosec + InsecureSkipVerify: g.config.Spaces.Insecure, //nolint:gosec } httpClient := &http.Client{} @@ -528,22 +543,35 @@ func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageS return nil, err } - if resp.StatusCode != http.StatusOK { + switch resp.StatusCode { + case http.StatusOK: + // continue + case http.StatusNotFound: + // cache an empty instance + spacePropertiesEntry := spacePropertiesEntry{ + spaceProperties: ExtendedSpaceProperties{}, + rootMtime: space.Mtime, + } + g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)) + + return &spacePropertiesEntry.spaceProperties, nil + default: return nil, fmt.Errorf("could not get the .space.yaml. Request returned with statuscode %d ", resp.StatusCode) } - body, err := ioutil.ReadAll(resp.Body) - if err != nil { + spaceProperties := ExtendedSpaceProperties{} + if err := yaml.NewDecoder(resp.Body).Decode(&spaceProperties); err != nil { return nil, err } - spaceYaml := &SpaceYaml{} - //if err := yaml.NewDecoder(resp.Body).Decode(spaceYaml); err != nil { - if err := yaml.Unmarshal(body, spaceYaml); err != nil { - return nil, err + // cache properties + spacePropertiesEntry := spacePropertiesEntry{ + spaceProperties: spaceProperties, + rootMtime: space.Mtime, } + g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)) - return spaceYaml, nil + return &spaceProperties, nil } func calculateQuotaState(total int64, used int64) (state string) { diff --git a/graph/pkg/service/v0/graph.go b/graph/pkg/service/v0/graph.go index 2b7cb0141..827b45ab7 100644 --- a/graph/pkg/service/v0/graph.go +++ b/graph/pkg/service/v0/graph.go @@ -14,11 +14,11 @@ import ( // Graph defines implements the business logic for Service. type Graph struct { - config *config.Config - mux *chi.Mux - logger *log.Logger - identityBackend identity.Backend - spaceYamlCache *ttlcache.Cache + config *config.Config + mux *chi.Mux + logger *log.Logger + identityBackend identity.Backend + spacePropertiesCache *ttlcache.Cache } // ServeHTTP implements the Service interface. diff --git a/graph/pkg/service/v0/service.go b/graph/pkg/service/v0/service.go index c9b98d41c..cb1168483 100644 --- a/graph/pkg/service/v0/service.go +++ b/graph/pkg/service/v0/service.go @@ -52,11 +52,11 @@ func NewService(opts ...Option) Service { } svc := Graph{ - config: options.Config, - mux: m, - logger: &options.Logger, - identityBackend: backend, - spaceYamlCache: ttlcache.NewCache(), + config: options.Config, + mux: m, + logger: &options.Logger, + identityBackend: backend, + spacePropertiesCache: ttlcache.NewCache(), } m.Route(options.Config.HTTP.Root, func(r chi.Router) { From 94d6daa222181b2c851cf21124303fcb1da86bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 17 Jan 2022 15:39:15 +0000 Subject: [PATCH 5/9] check error when setting cache with ttl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- go.mod | 2 +- graph/pkg/service/v0/drives.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 370309494..a8fb58590 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.17 require ( github.com/CiscoM31/godata v1.0.5 github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e + github.com/ReneKroon/ttlcache/v2 v2.11.0 github.com/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20211220083148-8e52761edb49 github.com/asim/go-micro/plugins/logger/zerolog/v4 v4.0.0-20211220083148-8e52761edb49 github.com/asim/go-micro/plugins/registry/etcd/v4 v4.0.0-20211220083148-8e52761edb49 @@ -83,7 +84,6 @@ require ( github.com/Masterminds/sprig v2.22.0+incompatible // indirect github.com/Microsoft/go-winio v0.5.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20211112122917-428f8eabeeb3 // indirect - github.com/ReneKroon/ttlcache/v2 v2.11.0 // indirect github.com/RoaringBitmap/roaring v0.9.4 // indirect github.com/acomagu/bufpipe v1.0.3 // indirect github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index e0eddaf95..4d858c827 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -525,7 +525,9 @@ func (g Graph) getExtendedSpaceProperties(ctx context.Context, space *storagepro spaceProperties: ExtendedSpaceProperties{}, rootMtime: space.Mtime, } - g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)) + if err := g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)); err != nil { + g.logger.Error().Err(err).Msg("could not cache extended space properties") + } return &spacePropertiesEntry.spaceProperties, nil default: @@ -567,7 +569,9 @@ func (g Graph) getExtendedSpaceProperties(ctx context.Context, space *storagepro spaceProperties: ExtendedSpaceProperties{}, rootMtime: space.Mtime, } - g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)) + if err := g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)); err != nil { + g.logger.Error().Err(err).Msg("could not cache extended space properties") + } return &spacePropertiesEntry.spaceProperties, nil default: @@ -584,7 +588,9 @@ func (g Graph) getExtendedSpaceProperties(ctx context.Context, space *storagepro spaceProperties: spaceProperties, rootMtime: space.Mtime, } - g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)) + if err := g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)); err != nil { + g.logger.Error().Err(err).Msg("could not cache extended space properties") + } return &spaceProperties, nil } From 9b4fae170495ce0904ff36daaaa016cbf7d9ad8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 18 Jan 2022 12:12:21 +0000 Subject: [PATCH 6/9] add mockery for minimal graph testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- .bingo/Variables.mk | 6 + .bingo/mockery.mod | 5 + .bingo/mockery.sum | 330 +++++++++++++++++++++++ .bingo/mutagen.sum | 1 + .bingo/variables.env | 2 + go.mod | 5 +- go.sum | 6 +- graph/Makefile | 3 +- graph/mocks/gateway_client.go | 289 ++++++++++++++++++++ graph/pkg/service/v0/driveitems.go | 13 +- graph/pkg/service/v0/drives.go | 31 +-- graph/pkg/service/v0/graph.go | 46 +++- graph/pkg/service/v0/graph_suite_test.go | 13 + graph/pkg/service/v0/graph_test.go | 52 ++++ graph/pkg/service/v0/instrument.go | 5 + graph/pkg/service/v0/logging.go | 5 + graph/pkg/service/v0/option.go | 14 +- graph/pkg/service/v0/service.go | 13 + graph/pkg/service/v0/tracing.go | 5 + 19 files changed, 797 insertions(+), 47 deletions(-) create mode 100644 .bingo/mockery.mod create mode 100644 .bingo/mockery.sum create mode 100644 graph/mocks/gateway_client.go create mode 100644 graph/pkg/service/v0/graph_suite_test.go create mode 100644 graph/pkg/service/v0/graph_test.go diff --git a/.bingo/Variables.mk b/.bingo/Variables.mk index 7ee79f3d7..94c5d9bce 100644 --- a/.bingo/Variables.mk +++ b/.bingo/Variables.mk @@ -59,6 +59,12 @@ $(HUGO): $(BINGO_DIR)/hugo.mod @echo "(re)installing $(GOBIN)/hugo-v0.91.0" @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=hugo.mod -o=$(GOBIN)/hugo-v0.91.0 "github.com/gohugoio/hugo" +MOCKERY := $(GOBIN)/mockery-v2.9.4 +$(MOCKERY): $(BINGO_DIR)/mockery.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/mockery-v2.9.4" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=mockery.mod -o=$(GOBIN)/mockery-v2.9.4 "github.com/vektra/mockery/v2" + MUTAGEN := $(GOBIN)/mutagen-v0.12.0 $(MUTAGEN): $(BINGO_DIR)/mutagen.mod @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. diff --git a/.bingo/mockery.mod b/.bingo/mockery.mod new file mode 100644 index 000000000..23a7bc36c --- /dev/null +++ b/.bingo/mockery.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.17 + +require github.com/vektra/mockery/v2 v2.9.4 diff --git a/.bingo/mockery.sum b/.bingo/mockery.sum new file mode 100644 index 000000000..8862cce4b --- /dev/null +++ b/.bingo/mockery.sum @@ -0,0 +1,330 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.18.0 h1:CbAm3kP2Tptby1i9sYy2MGRg0uxIN9cyDb59Ys7W8z8= +github.com/rs/zerolog v1.18.0/go.mod h1:9nvC1axdVrAHcu/s9taAVfBuIdTZLVQmKQyvrUjF5+I= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= +github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= +github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/vektra/mockery/v2 v2.9.4 h1:ZjpYWY+YLkDIKrKtFnYPxJax10lktcUapWZtOSg4g7g= +github.com/vektra/mockery/v2 v2.9.4/go.mod h1:2gU4Cf/f8YyC8oEaSXfCnZBMxMjMl/Ko205rlP0fO90= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200323144430-8dcfad9e016e h1:ssd5ulOvVWlh4kDSUF2SqzmMeWfjmwDXM+uGw/aQjRE= +golang.org/x/tools v0.0.0-20200323144430-8dcfad9e016e/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/.bingo/mutagen.sum b/.bingo/mutagen.sum index edfbfc30b..eeade8794 100644 --- a/.bingo/mutagen.sum +++ b/.bingo/mutagen.sum @@ -10,6 +10,7 @@ github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= github.com/mutagen-io/apimachinery v0.21.3-mutagen1 h1:7bnH35Ayna8ERRINDJ+J+bRd/85vv7ySFzFYpkmX62o= github.com/mutagen-io/extstat v0.0.0-20210224131814-32fa3f057fa8 h1:NEBqH/oVnWBunxdrdy1vlyGior8smhC6jZjxlWSG2BU= +github.com/mutagen-io/fsevents v0.0.0-20180903111129-10556809b434 h1:PYeqqury0vVzjjUVO6dwtfA2HXOaPYgDclSgKX8u0gs= github.com/mutagen-io/gopass v0.0.0-20170602182606-9a121bec1ae7 h1:0PaUmAw6e54jseSG0ob2U9P1p6p+Sppw3sanphmM4LY= github.com/mutagen-io/mutagen v0.12.0 h1:RtTezK5ewMhsLnHwXY4g/E5xaq63GWZrl1Ocr7W5e9w= github.com/mutagen-io/mutagen v0.12.0/go.mod h1:Ms9m9qVNIHVR6W4ceY/OFv31V2nN1hH1atxfUP1W4F0= diff --git a/.bingo/variables.env b/.bingo/variables.env index 18d60568b..b54bcc82b 100644 --- a/.bingo/variables.env +++ b/.bingo/variables.env @@ -22,6 +22,8 @@ GOX="${GOBIN}/gox-v1.0.1" HUGO="${GOBIN}/hugo-v0.91.0" +MOCKERY="${GOBIN}/mockery-v2.9.4" + MUTAGEN="${GOBIN}/mutagen-v0.12.0" PROTOC_GEN_DOC="${GOBIN}/protoc-gen-doc-v1.5.0" diff --git a/go.mod b/go.mod index a8fb58590..092f21860 100644 --- a/go.mod +++ b/go.mod @@ -140,7 +140,7 @@ require ( github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/gomodule/redigo v1.8.6 // indirect + github.com/gomodule/redigo v1.8.8 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/gookit/goutil v0.4.0 // indirect @@ -165,7 +165,7 @@ require ( github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect - github.com/mattn/go-sqlite3 v1.14.10 // indirect + github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 // indirect github.com/miekg/dns v1.1.44 // indirect @@ -214,6 +214,7 @@ require ( github.com/sony/gobreaker v0.5.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/steveyen/gtreap v0.1.0 // indirect + github.com/stretchr/objx v0.3.0 // indirect github.com/tus/tusd v1.8.0 // indirect github.com/wk8/go-ordered-map v0.2.0 // indirect github.com/xanzy/ssh-agent v0.3.1 // indirect diff --git a/go.sum b/go.sum index 1c73d4352..195d27c57 100644 --- a/go.sum +++ b/go.sum @@ -638,8 +638,9 @@ github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y= -github.com/gomodule/redigo v1.8.6 h1:h7kHSqUl2kxeaQtVslsfUCPJ1oz2pxcyzLy4zezIzPw= github.com/gomodule/redigo v1.8.6/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= +github.com/gomodule/redigo v1.8.8 h1:f6cXq6RRfiyrOJEV7p3JhLDlmawGBVBBP1MggY8Mo4E= +github.com/gomodule/redigo v1.8.8/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -933,8 +934,9 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk= github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= +github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= diff --git a/graph/Makefile b/graph/Makefile index 89e96a254..720a6756f 100644 --- a/graph/Makefile +++ b/graph/Makefile @@ -24,7 +24,8 @@ docs-generate: config-docs-generate include ../.make/generate.mk .PHONY: ci-go-generate -ci-go-generate: # CI runs ci-node-generate automatically before this target +ci-go-generate: $(MOCKERY) # CI runs ci-node-generate automatically before this target + $(MOCKERY) --dir pkg/service/v0 --case underscore --name GatewayClient .PHONY: ci-node-generate ci-node-generate: diff --git a/graph/mocks/gateway_client.go b/graph/mocks/gateway_client.go new file mode 100644 index 000000000..edb1fe554 --- /dev/null +++ b/graph/mocks/gateway_client.go @@ -0,0 +1,289 @@ +// Code generated by mockery v2.9.4. DO NOT EDIT. + +package mocks + +import ( + context "context" + + gatewayv1beta1 "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" + grpc "google.golang.org/grpc" + + mock "github.com/stretchr/testify/mock" + + providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" +) + +// GatewayClient is an autogenerated mock type for the GatewayClient type +type GatewayClient struct { + mock.Mock +} + +// CreateStorageSpace provides a mock function with given fields: ctx, in, opts +func (_m *GatewayClient) CreateStorageSpace(ctx context.Context, in *providerv1beta1.CreateStorageSpaceRequest, opts ...grpc.CallOption) (*providerv1beta1.CreateStorageSpaceResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta1.CreateStorageSpaceResponse + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.CreateStorageSpaceRequest, ...grpc.CallOption) *providerv1beta1.CreateStorageSpaceResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta1.CreateStorageSpaceResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.CreateStorageSpaceRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteStorageSpace provides a mock function with given fields: ctx, in, opts +func (_m *GatewayClient) DeleteStorageSpace(ctx context.Context, in *providerv1beta1.DeleteStorageSpaceRequest, opts ...grpc.CallOption) (*providerv1beta1.DeleteStorageSpaceResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta1.DeleteStorageSpaceResponse + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.DeleteStorageSpaceRequest, ...grpc.CallOption) *providerv1beta1.DeleteStorageSpaceResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta1.DeleteStorageSpaceResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.DeleteStorageSpaceRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetHome provides a mock function with given fields: ctx, in, opts +func (_m *GatewayClient) GetHome(ctx context.Context, in *providerv1beta1.GetHomeRequest, opts ...grpc.CallOption) (*providerv1beta1.GetHomeResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta1.GetHomeResponse + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.GetHomeRequest, ...grpc.CallOption) *providerv1beta1.GetHomeResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta1.GetHomeResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.GetHomeRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetQuota provides a mock function with given fields: ctx, in, opts +func (_m *GatewayClient) GetQuota(ctx context.Context, in *gatewayv1beta1.GetQuotaRequest, opts ...grpc.CallOption) (*providerv1beta1.GetQuotaResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta1.GetQuotaResponse + if rf, ok := ret.Get(0).(func(context.Context, *gatewayv1beta1.GetQuotaRequest, ...grpc.CallOption) *providerv1beta1.GetQuotaResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta1.GetQuotaResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *gatewayv1beta1.GetQuotaRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// InitiateFileDownload provides a mock function with given fields: ctx, in, opts +func (_m *GatewayClient) InitiateFileDownload(ctx context.Context, in *providerv1beta1.InitiateFileDownloadRequest, opts ...grpc.CallOption) (*gatewayv1beta1.InitiateFileDownloadResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *gatewayv1beta1.InitiateFileDownloadResponse + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.InitiateFileDownloadRequest, ...grpc.CallOption) *gatewayv1beta1.InitiateFileDownloadResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*gatewayv1beta1.InitiateFileDownloadResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.InitiateFileDownloadRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListContainer provides a mock function with given fields: ctx, in, opts +func (_m *GatewayClient) ListContainer(ctx context.Context, in *providerv1beta1.ListContainerRequest, opts ...grpc.CallOption) (*providerv1beta1.ListContainerResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta1.ListContainerResponse + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ListContainerRequest, ...grpc.CallOption) *providerv1beta1.ListContainerResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta1.ListContainerResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ListContainerRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListStorageSpaces provides a mock function with given fields: ctx, in, opts +func (_m *GatewayClient) ListStorageSpaces(ctx context.Context, in *providerv1beta1.ListStorageSpacesRequest, opts ...grpc.CallOption) (*providerv1beta1.ListStorageSpacesResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta1.ListStorageSpacesResponse + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ListStorageSpacesRequest, ...grpc.CallOption) *providerv1beta1.ListStorageSpacesResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta1.ListStorageSpacesResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ListStorageSpacesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Stat provides a mock function with given fields: ctx, in, opts +func (_m *GatewayClient) Stat(ctx context.Context, in *providerv1beta1.StatRequest, opts ...grpc.CallOption) (*providerv1beta1.StatResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta1.StatResponse + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.StatRequest, ...grpc.CallOption) *providerv1beta1.StatResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta1.StatResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.StatRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateStorageSpace provides a mock function with given fields: ctx, in, opts +func (_m *GatewayClient) UpdateStorageSpace(ctx context.Context, in *providerv1beta1.UpdateStorageSpaceRequest, opts ...grpc.CallOption) (*providerv1beta1.UpdateStorageSpaceResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta1.UpdateStorageSpaceResponse + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.UpdateStorageSpaceRequest, ...grpc.CallOption) *providerv1beta1.UpdateStorageSpaceResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta1.UpdateStorageSpaceResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.UpdateStorageSpaceRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/graph/pkg/service/v0/driveitems.go b/graph/pkg/service/v0/driveitems.go index e695353c1..69e371633 100644 --- a/graph/pkg/service/v0/driveitems.go +++ b/graph/pkg/service/v0/driveitems.go @@ -21,12 +21,7 @@ func (g Graph) GetRootDriveChildren(w http.ResponseWriter, r *http.Request) { g.logger.Info().Msg("Calling GetRootDriveChildren") ctx := r.Context() - client, err := g.GetClient() - if err != nil { - g.logger.Error().Err(err).Msg("could not get client") - errorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, err.Error()) - return - } + client := g.GetClient() res, err := client.GetHome(ctx, &storageprovider.GetHomeRequest{}) switch { @@ -82,11 +77,7 @@ func (g Graph) GetRootDriveChildren(w http.ResponseWriter, r *http.Request) { func (g Graph) getDriveItem(ctx context.Context, root *storageprovider.ResourceId, relativePath string) (*libregraph.DriveItem, error) { - client, err := g.GetClient() - if err != nil { - g.logger.Error().Err(err).Msg("error creating grpc client") - return nil, err - } + client := g.GetClient() ref := &storageprovider.Reference{ ResourceId: root, diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index 4d858c827..7ffa66c82 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -47,12 +47,7 @@ func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request) { g.logger.Info().Msg("Calling GetDrives") ctx := r.Context() - client, err := g.GetClient() - if err != nil { - g.logger.Err(err).Msg("error getting grpc client") - errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error()) - return - } + client := g.GetClient() permissions := make(map[string]struct{}, 1) s := sproto.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient) @@ -138,11 +133,7 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) { return } - client, err := g.GetClient() - if err != nil { - errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error()) - return - } + client := g.GetClient() drive := libregraph.Drive{} if err := json.NewDecoder(r.Body).Decode(&drive); err != nil { errorcode.GeneralException.Render(w, r, http.StatusBadRequest, "invalid schema definition") @@ -233,11 +224,7 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) { return } - client, err := g.GetClient() - if err != nil { - errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error()) - return - } + client := g.GetClient() updateSpaceRequest := &storageprovider.UpdateStorageSpaceRequest{ // Prepare the object to apply the diff from. The properties on StorageSpace will overwrite @@ -410,11 +397,7 @@ func cs3StorageSpaceToDrive(baseURL *url.URL, space *storageprovider.StorageSpac } func (g Graph) getDriveQuota(ctx context.Context, space *storageprovider.StorageSpace) (*libregraph.Quota, error) { - client, err := g.GetClient() - if err != nil { - g.logger.Error().Err(err).Msg("error creating grpc client") - return nil, err - } + client := g.GetClient() req := &gateway.GetQuotaRequest{ Ref: &storageprovider.Reference{ @@ -489,10 +472,8 @@ func (g Graph) getExtendedSpaceProperties(ctx context.Context, space *storagepro } } - client, err := g.GetClient() - if err != nil { - return nil, err - } + client := g.GetClient() + dlReq := &storageprovider.InitiateFileDownloadRequest{ Ref: &storageprovider.Reference{ ResourceId: &storageprovider.ResourceId{ diff --git a/graph/pkg/service/v0/graph.go b/graph/pkg/service/v0/graph.go index 827b45ab7..7127c8278 100644 --- a/graph/pkg/service/v0/graph.go +++ b/graph/pkg/service/v0/graph.go @@ -1,23 +1,63 @@ package svc import ( + "context" "net/http" "github.com/ReneKroon/ttlcache/v2" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" - "github.com/cs3org/reva/pkg/rgrpc/todo/pool" + provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" "github.com/go-chi/chi/v5" "github.com/owncloud/ocis/graph/pkg/config" "github.com/owncloud/ocis/graph/pkg/identity" "github.com/owncloud/ocis/ocis-pkg/log" + "google.golang.org/grpc" ) +//go:generate make generate + +// GatewayClient is the subset of the gateway.GatewayAPIClient that's being uses to interact with the gateway +type GatewayClient interface { + //gateway.GatewayAPIClient + + // Returns the home path for the given authenticated user. + // When a user has access to multiple storage providers, one of them is the home. + GetHome(ctx context.Context, in *provider.GetHomeRequest, opts ...grpc.CallOption) (*provider.GetHomeResponse, error) + // Returns a list of resource information + // for the provided reference. + // MUST return CODE_NOT_FOUND if the reference does not exists. + ListContainer(ctx context.Context, in *provider.ListContainerRequest, opts ...grpc.CallOption) (*provider.ListContainerResponse, error) + // Returns the resource information at the provided reference. + // MUST return CODE_NOT_FOUND if the reference does not exist. + Stat(ctx context.Context, in *provider.StatRequest, opts ...grpc.CallOption) (*provider.StatResponse, error) + // Initiates the download of a file using an + // out-of-band data transfer mechanism. + InitiateFileDownload(ctx context.Context, in *provider.InitiateFileDownloadRequest, opts ...grpc.CallOption) (*gateway.InitiateFileDownloadResponse, error) + // Creates a storage space. + CreateStorageSpace(ctx context.Context, in *provider.CreateStorageSpaceRequest, opts ...grpc.CallOption) (*provider.CreateStorageSpaceResponse, error) + // Lists storage spaces. + ListStorageSpaces(ctx context.Context, in *provider.ListStorageSpacesRequest, opts ...grpc.CallOption) (*provider.ListStorageSpacesResponse, error) + // Updates a storage space. + UpdateStorageSpace(ctx context.Context, in *provider.UpdateStorageSpaceRequest, opts ...grpc.CallOption) (*provider.UpdateStorageSpaceResponse, error) + // Deletes a storage space. + DeleteStorageSpace(ctx context.Context, in *provider.DeleteStorageSpaceRequest, opts ...grpc.CallOption) (*provider.DeleteStorageSpaceResponse, error) + // Returns the quota available under the provided + // reference. + // MUST return CODE_NOT_FOUND if the reference does not exist + // MUST return CODE_RESOURCE_EXHAUSTED on exceeded quota limits. + GetQuota(ctx context.Context, in *gateway.GetQuotaRequest, opts ...grpc.CallOption) (*provider.GetQuotaResponse, error) +} + +// GetGatewayServiceClientFunc is a callback used to pass in a mock during testing +type GetGatewayServiceClientFunc func() (GatewayClient, error) + // Graph defines implements the business logic for Service. type Graph struct { config *config.Config mux *chi.Mux logger *log.Logger identityBackend identity.Backend + client GatewayClient spacePropertiesCache *ttlcache.Cache } @@ -27,8 +67,8 @@ func (g Graph) ServeHTTP(w http.ResponseWriter, r *http.Request) { } // GetClient returns a gateway client to talk to reva -func (g Graph) GetClient() (gateway.GatewayAPIClient, error) { - return pool.GetGatewayServiceClient(g.config.Reva.Address) +func (g Graph) GetClient() GatewayClient { + return g.client } type listResponse struct { diff --git a/graph/pkg/service/v0/graph_suite_test.go b/graph/pkg/service/v0/graph_suite_test.go new file mode 100644 index 000000000..1c6cfc6cc --- /dev/null +++ b/graph/pkg/service/v0/graph_suite_test.go @@ -0,0 +1,13 @@ +package svc_test + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestGraph(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Graph Suite") +} diff --git a/graph/pkg/service/v0/graph_test.go b/graph/pkg/service/v0/graph_test.go new file mode 100644 index 000000000..6bcf59159 --- /dev/null +++ b/graph/pkg/service/v0/graph_test.go @@ -0,0 +1,52 @@ +package svc_test + +import ( + "context" + "net/http" + "net/http/httptest" + + provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/pkg/rgrpc/status" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/owncloud/ocis/graph/mocks" + "github.com/owncloud/ocis/graph/pkg/config" + service "github.com/owncloud/ocis/graph/pkg/service/v0" + "github.com/stretchr/testify/mock" +) + +var _ = Describe("Graph", func() { + var ( + svc service.Service + client *mocks.GatewayClient + ctx context.Context + ) + + JustBeforeEach(func() { + ctx = context.Background() + client = &mocks.GatewayClient{} + svc = service.NewService( + service.Config(config.DefaultConfig()), + service.GatewayServiceClient(client), + ) + }) + + Describe("NewService", func() { + It("returns a service", func() { + Expect(svc).ToNot(BeNil()) + }) + }) + Describe("drive", func() { + It("can list an empty list of spaces", func() { + client.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(&provider.ListStorageSpacesResponse{ + Status: status.NewOK(ctx), + StorageSpaces: []*provider.StorageSpace{}, + }, nil) + + r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/me/drives", nil) + rr := httptest.NewRecorder() + svc.GetDrives(rr, r) + Expect(rr.Code).To(Equal(http.StatusOK)) + }) + }) +}) diff --git a/graph/pkg/service/v0/instrument.go b/graph/pkg/service/v0/instrument.go index a0fb82542..05cb9306c 100644 --- a/graph/pkg/service/v0/instrument.go +++ b/graph/pkg/service/v0/instrument.go @@ -53,3 +53,8 @@ func (i instrument) DeleteUser(w http.ResponseWriter, r *http.Request) { func (i instrument) PatchUser(w http.ResponseWriter, r *http.Request) { i.next.PatchUser(w, r) } + +// GetDrives implements the Service interface. +func (i instrument) GetDrives(w http.ResponseWriter, r *http.Request) { + i.next.GetDrives(w, r) +} diff --git a/graph/pkg/service/v0/logging.go b/graph/pkg/service/v0/logging.go index d5ce3373a..6a29c3ef8 100644 --- a/graph/pkg/service/v0/logging.go +++ b/graph/pkg/service/v0/logging.go @@ -53,3 +53,8 @@ func (l logging) DeleteUser(w http.ResponseWriter, r *http.Request) { func (l logging) PatchUser(w http.ResponseWriter, r *http.Request) { l.next.PatchUser(w, r) } + +// GetDrives implements the Service interface. +func (l logging) GetDrives(w http.ResponseWriter, r *http.Request) { + l.next.GetDrives(w, r) +} diff --git a/graph/pkg/service/v0/option.go b/graph/pkg/service/v0/option.go index 8d6b31fde..49664dde6 100644 --- a/graph/pkg/service/v0/option.go +++ b/graph/pkg/service/v0/option.go @@ -12,9 +12,10 @@ type Option func(o *Options) // Options defines the available options for this package. type Options struct { - Logger log.Logger - Config *config.Config - Middleware []func(http.Handler) http.Handler + Logger log.Logger + Config *config.Config + Middleware []func(http.Handler) http.Handler + GatewayServiceClient GatewayClient } // newOptions initializes the available default options. @@ -48,3 +49,10 @@ func Middleware(val ...func(http.Handler) http.Handler) Option { o.Middleware = val } } + +// GatewayServiceClient provides a function to set the middleware option. +func GatewayServiceClient(val GatewayClient) Option { + return func(o *Options) { + o.GatewayServiceClient = val + } +} diff --git a/graph/pkg/service/v0/service.go b/graph/pkg/service/v0/service.go index 3bd4b810c..990a764e9 100644 --- a/graph/pkg/service/v0/service.go +++ b/graph/pkg/service/v0/service.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/ReneKroon/ttlcache/v2" + "github.com/cs3org/reva/pkg/rgrpc/todo/pool" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" @@ -22,6 +23,8 @@ type Service interface { PostUser(http.ResponseWriter, *http.Request) DeleteUser(http.ResponseWriter, *http.Request) PatchUser(http.ResponseWriter, *http.Request) + + GetDrives(w http.ResponseWriter, r *http.Request) } // NewService returns a service implementation for Service. @@ -61,6 +64,16 @@ func NewService(opts ...Option) Service { identityBackend: backend, spacePropertiesCache: ttlcache.NewCache(), } + if options.GatewayServiceClient == nil { + var err error + svc.client, err = pool.GetGatewayServiceClient(options.Config.Reva.Address) + if err != nil { + options.Logger.Error().Err(err).Msg("Could not get gateway client") + return nil + } + } else { + svc.client = options.GatewayServiceClient + } m.Route(options.Config.HTTP.Root, func(r chi.Router) { r.Use(middleware.StripSlashes) diff --git a/graph/pkg/service/v0/tracing.go b/graph/pkg/service/v0/tracing.go index c1e544214..59e9197c7 100644 --- a/graph/pkg/service/v0/tracing.go +++ b/graph/pkg/service/v0/tracing.go @@ -49,3 +49,8 @@ func (t tracing) DeleteUser(w http.ResponseWriter, r *http.Request) { func (t tracing) PatchUser(w http.ResponseWriter, r *http.Request) { t.next.PatchUser(w, r) } + +// GetDrives implements the Service interface. +func (t tracing) GetDrives(w http.ResponseWriter, r *http.Request) { + t.next.GetDrives(w, r) +} From e9ccf09c207ffc4cdbe13258cbc6be4dbd471bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 18 Jan 2022 15:29:09 +0000 Subject: [PATCH 7/9] test reading from space.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- graph/Makefile | 1 + graph/mocks/http_client.go | 37 ++++++ graph/pkg/service/v0/driveitems.go | 18 +-- graph/pkg/service/v0/drives.go | 30 +++-- graph/pkg/service/v0/graph.go | 19 ++- graph/pkg/service/v0/graph_test.go | 193 ++++++++++++++++++++++++++++- graph/pkg/service/v0/option.go | 22 ++-- graph/pkg/service/v0/service.go | 15 ++- 8 files changed, 297 insertions(+), 38 deletions(-) create mode 100644 graph/mocks/http_client.go diff --git a/graph/Makefile b/graph/Makefile index 720a6756f..88ecd177d 100644 --- a/graph/Makefile +++ b/graph/Makefile @@ -26,6 +26,7 @@ include ../.make/generate.mk .PHONY: ci-go-generate ci-go-generate: $(MOCKERY) # CI runs ci-node-generate automatically before this target $(MOCKERY) --dir pkg/service/v0 --case underscore --name GatewayClient + $(MOCKERY) --dir pkg/service/v0 --case underscore --name HTTPClient .PHONY: ci-node-generate ci-node-generate: diff --git a/graph/mocks/http_client.go b/graph/mocks/http_client.go new file mode 100644 index 000000000..d8e18327c --- /dev/null +++ b/graph/mocks/http_client.go @@ -0,0 +1,37 @@ +// Code generated by mockery v2.9.4. DO NOT EDIT. + +package mocks + +import ( + http "net/http" + + mock "github.com/stretchr/testify/mock" +) + +// HTTPClient is an autogenerated mock type for the HTTPClient type +type HTTPClient struct { + mock.Mock +} + +// Do provides a mock function with given fields: req +func (_m *HTTPClient) Do(req *http.Request) (*http.Response, error) { + ret := _m.Called(req) + + var r0 *http.Response + if rf, ok := ret.Get(0).(func(*http.Request) *http.Response); ok { + r0 = rf(req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(*http.Request) error); ok { + r1 = rf(req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/graph/pkg/service/v0/driveitems.go b/graph/pkg/service/v0/driveitems.go index 69e371633..6341446b0 100644 --- a/graph/pkg/service/v0/driveitems.go +++ b/graph/pkg/service/v0/driveitems.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" "path" - "path/filepath" "time" cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" + "github.com/cs3org/reva/pkg/utils" "github.com/go-chi/render" libregraph "github.com/owncloud/libre-graph-api-go" "github.com/owncloud/ocis/graph/pkg/service/v0/errorcode" @@ -21,7 +21,7 @@ func (g Graph) GetRootDriveChildren(w http.ResponseWriter, r *http.Request) { g.logger.Info().Msg("Calling GetRootDriveChildren") ctx := r.Context() - client := g.GetClient() + client := g.GetGatewayClient() res, err := client.GetHome(ctx, &storageprovider.GetHomeRequest{}) switch { @@ -77,12 +77,12 @@ func (g Graph) GetRootDriveChildren(w http.ResponseWriter, r *http.Request) { func (g Graph) getDriveItem(ctx context.Context, root *storageprovider.ResourceId, relativePath string) (*libregraph.DriveItem, error) { - client := g.GetClient() + client := g.GetGatewayClient() ref := &storageprovider.Reference{ ResourceId: root, // the path is always relative to the root of the drive, not the location of the .config/ocis/space.yaml file - Path: filepath.Join("./", relativePath), + Path: utils.MakeRelativePath(relativePath), } res, err := client.Stat(ctx, &storageprovider.StatRequest{Ref: ref}) if err != nil { @@ -119,15 +119,19 @@ func cs3ResourceToDriveItem(res *storageprovider.ResourceInfo) (*libregraph.Driv driveItem := &libregraph.DriveItem{ Id: &res.Id.OpaqueId, - Name: &name, - ETag: &res.Etag, Size: size, } + if name != "" { + driveItem.Name = &name + } + if res.Etag != "" { + driveItem.ETag = &res.Etag + } if res.Mtime != nil { lastModified := cs3TimestampToTime(res.Mtime) driveItem.LastModifiedDateTime = &lastModified } - if res.Type == storageprovider.ResourceType_RESOURCE_TYPE_FILE { + if res.Type == storageprovider.ResourceType_RESOURCE_TYPE_FILE && res.MimeType != "" { driveItem.File = &libregraph.OpenGraphFile{ // FIXME We cannot use libregraph.File here because the openapi codegenerator autodetects 'File' as a go type ... MimeType: &res.MimeType, } diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index 7ffa66c82..e233a9acd 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -2,7 +2,6 @@ package svc import ( "context" - "crypto/tls" "encoding/json" "fmt" "math" @@ -47,7 +46,7 @@ func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request) { g.logger.Info().Msg("Calling GetDrives") ctx := r.Context() - client := g.GetClient() + client := g.GetGatewayClient() permissions := make(map[string]struct{}, 1) s := sproto.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient) @@ -133,7 +132,7 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) { return } - client := g.GetClient() + client := g.GetGatewayClient() drive := libregraph.Drive{} if err := json.NewDecoder(r.Body).Decode(&drive); err != nil { errorcode.GeneralException.Render(w, r, http.StatusBadRequest, "invalid schema definition") @@ -224,7 +223,7 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) { return } - client := g.GetClient() + client := g.GetGatewayClient() updateSpaceRequest := &storageprovider.UpdateStorageSpaceRequest{ // Prepare the object to apply the diff from. The properties on StorageSpace will overwrite @@ -397,7 +396,7 @@ func cs3StorageSpaceToDrive(baseURL *url.URL, space *storageprovider.StorageSpac } func (g Graph) getDriveQuota(ctx context.Context, space *storageprovider.StorageSpace) (*libregraph.Quota, error) { - client := g.GetClient() + client := g.GetGatewayClient() req := &gateway.GetQuotaRequest{ Ref: &storageprovider.Reference{ @@ -472,7 +471,7 @@ func (g Graph) getExtendedSpaceProperties(ctx context.Context, space *storagepro } } - client := g.GetClient() + client := g.GetGatewayClient() dlReq := &storageprovider.InitiateFileDownloadRequest{ Ref: &storageprovider.Reference{ @@ -531,10 +530,7 @@ func (g Graph) getExtendedSpaceProperties(ctx context.Context, space *storagepro } httpReq.Header.Set(headers.TokenTransportHeader, tk) - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{ - InsecureSkipVerify: g.config.Spaces.Insecure, //nolint:gosec - } - httpClient := &http.Client{} + httpClient := g.GetHTTPClient() resp, err := httpClient.Do(httpReq) // nolint:bodyclose if err != nil { @@ -561,7 +557,19 @@ func (g Graph) getExtendedSpaceProperties(ctx context.Context, space *storagepro spaceProperties := ExtendedSpaceProperties{} if err := yaml.NewDecoder(resp.Body).Decode(&spaceProperties); err != nil { - return nil, err + g.logger.Debug().Err(err).Msg("invalid space yaml, ignoring") + + // cache an empty instance + // TODO insert an 'invalid yaml' item? how can we return an error to the user? + spacePropertiesEntry := spacePropertiesEntry{ + spaceProperties: ExtendedSpaceProperties{}, + rootMtime: space.Mtime, + } + if err := g.spacePropertiesCache.SetWithTTL(spaceRootStatKey(space.Root), spacePropertiesEntry, time.Second*time.Duration(g.config.Spaces.ExtendedSpacePropertiesCacheTTL)); err != nil { + g.logger.Error().Err(err).Msg("could not cache extended space properties") + } + + return &spacePropertiesEntry.spaceProperties, nil } // cache properties diff --git a/graph/pkg/service/v0/graph.go b/graph/pkg/service/v0/graph.go index 7127c8278..3523dd8fb 100644 --- a/graph/pkg/service/v0/graph.go +++ b/graph/pkg/service/v0/graph.go @@ -16,7 +16,7 @@ import ( //go:generate make generate -// GatewayClient is the subset of the gateway.GatewayAPIClient that's being uses to interact with the gateway +// GatewayClient is the subset of the gateway.GatewayAPIClient that is being used to interact with the gateway type GatewayClient interface { //gateway.GatewayAPIClient @@ -48,6 +48,11 @@ type GatewayClient interface { GetQuota(ctx context.Context, in *gateway.GetQuotaRequest, opts ...grpc.CallOption) (*provider.GetQuotaResponse, error) } +// HTTPClient is the subset of the http.Client that is being used to interact with the download gateway +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + // GetGatewayServiceClientFunc is a callback used to pass in a mock during testing type GetGatewayServiceClientFunc func() (GatewayClient, error) @@ -57,7 +62,8 @@ type Graph struct { mux *chi.Mux logger *log.Logger identityBackend identity.Backend - client GatewayClient + gatewayClient GatewayClient + httpClient HTTPClient spacePropertiesCache *ttlcache.Cache } @@ -67,8 +73,13 @@ func (g Graph) ServeHTTP(w http.ResponseWriter, r *http.Request) { } // GetClient returns a gateway client to talk to reva -func (g Graph) GetClient() GatewayClient { - return g.client +func (g Graph) GetGatewayClient() GatewayClient { + return g.gatewayClient +} + +// GetClient returns a gateway client to talk to reva +func (g Graph) GetHTTPClient() HTTPClient { + return g.httpClient } type listResponse struct { diff --git a/graph/pkg/service/v0/graph_test.go b/graph/pkg/service/v0/graph_test.go index 6bcf59159..ed90d6509 100644 --- a/graph/pkg/service/v0/graph_test.go +++ b/graph/pkg/service/v0/graph_test.go @@ -2,9 +2,13 @@ package svc_test import ( "context" + "fmt" + "io" "net/http" "net/http/httptest" + "strings" + gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" "github.com/cs3org/reva/pkg/rgrpc/status" . "github.com/onsi/ginkgo" @@ -13,21 +17,25 @@ import ( "github.com/owncloud/ocis/graph/pkg/config" service "github.com/owncloud/ocis/graph/pkg/service/v0" "github.com/stretchr/testify/mock" + "google.golang.org/grpc" ) var _ = Describe("Graph", func() { var ( - svc service.Service - client *mocks.GatewayClient - ctx context.Context + svc service.Service + gatewayClient *mocks.GatewayClient + httpClient *mocks.HTTPClient + ctx context.Context ) JustBeforeEach(func() { ctx = context.Background() - client = &mocks.GatewayClient{} + gatewayClient = &mocks.GatewayClient{} + httpClient = &mocks.HTTPClient{} svc = service.NewService( service.Config(config.DefaultConfig()), - service.GatewayServiceClient(client), + service.WithGatewayClient(gatewayClient), + service.WithHTTPClient(httpClient), ) }) @@ -36,9 +44,10 @@ var _ = Describe("Graph", func() { Expect(svc).ToNot(BeNil()) }) }) + Describe("drive", func() { It("can list an empty list of spaces", func() { - client.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(&provider.ListStorageSpacesResponse{ + gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(&provider.ListStorageSpacesResponse{ Status: status.NewOK(ctx), StorageSpaces: []*provider.StorageSpace{}, }, nil) @@ -48,5 +57,177 @@ var _ = Describe("Graph", func() { svc.GetDrives(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) }) + + It("can list a space without owner", func() { + gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(&provider.ListStorageSpacesResponse{ + Status: status.NewOK(ctx), + StorageSpaces: []*provider.StorageSpace{ + { + Id: &provider.StorageSpaceId{OpaqueId: "aspaceid"}, + SpaceType: "aspacetype", + Root: &provider.ResourceId{ + StorageId: "aspaceid", + OpaqueId: "anopaqueid", + }, + Name: "aspacename", + }, + }, + }, nil) + gatewayClient.On("InitiateFileDownload", mock.Anything, mock.Anything).Return(&gateway.InitiateFileDownloadResponse{ + Status: status.NewNotFound(ctx, "not found"), + }, nil) + gatewayClient.On("GetQuota", mock.Anything, mock.Anything).Return(&provider.GetQuotaResponse{ + Status: status.NewUnimplemented(ctx, fmt.Errorf("not supported"), "not supported"), + }, nil) + + r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/me/drives", nil) + rr := httptest.NewRecorder() + svc.GetDrives(rr, r) + + Expect(rr.Code).To(Equal(http.StatusOK)) + + body, _ := io.ReadAll(rr.Body) + Expect(body).To(MatchJSON(` + { + "value":[ + { + "driveType":"aspacetype", + "id":"aspaceid!anopaqueid", + "name":"aspacename", + "root":{ + "id":"aspaceid!anopaqueid", + "webDavUrl":"https://localhost:9200/dav/spaces/aspaceid!anopaqueid" + } + } + ] + } + `)) + }) + + It("can list a space with extended properties from a space.yaml", func() { + gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(&provider.ListStorageSpacesResponse{ + Status: status.NewOK(ctx), + StorageSpaces: []*provider.StorageSpace{ + { + Id: &provider.StorageSpaceId{OpaqueId: "aspaceid"}, + SpaceType: "aspacetype", + Root: &provider.ResourceId{ + StorageId: "aspaceid", + OpaqueId: "anopaqueid", + }, + Name: "aspacename", + }, + }, + }, nil) + gatewayClient.On("InitiateFileDownload", mock.Anything, mock.Anything).Return(&gateway.InitiateFileDownloadResponse{ + Status: status.NewOK(ctx), + Protocols: []*gateway.FileDownloadProtocol{ + { + Protocol: "spaces", + DownloadEndpoint: "ignored", + }, + }, + }, nil) + // mock space.yaml + httpClient.On("Do", mock.Anything, mock.Anything).Return(&http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader(`--- +version: "1.0" +description: read from yaml +special: + readme: readme2.md + image: .img/space.png +`)), + }, nil) + gatewayClient.On("GetQuota", mock.Anything, mock.Anything).Return(&provider.GetQuotaResponse{ + Status: status.NewUnimplemented(ctx, fmt.Errorf("not supported"), "not supported"), + }, nil) + gatewayClient.On("Stat", mock.Anything, mock.Anything).Return( + func(_ context.Context, req *provider.StatRequest, _ ...grpc.CallOption) *provider.StatResponse { + switch req.Ref.GetPath() { + case "./readme2.md": + return &provider.StatResponse{ + Status: status.NewOK(ctx), + Info: &provider.ResourceInfo{ + Type: provider.ResourceType_RESOURCE_TYPE_FILE, + Path: "readme2.md", + Id: &provider.ResourceId{ + StorageId: "aspaceid", + OpaqueId: "readmeid", + }, + PermissionSet: &provider.ResourcePermissions{ + Stat: true, + }, + Size: 10, + }, + } + case "./.img/space.png": + return &provider.StatResponse{ + Status: status.NewOK(ctx), + Info: &provider.ResourceInfo{ + Type: provider.ResourceType_RESOURCE_TYPE_FILE, + Path: "space.png", + Id: &provider.ResourceId{ + StorageId: "aspaceid", + OpaqueId: "imageid", + }, + PermissionSet: &provider.ResourcePermissions{ + Stat: true, + }, + Size: 20, + }, + } + default: + return &provider.StatResponse{ + Status: status.NewNotFound(ctx, "not found"), + } + } + }, + nil) + + r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/me/drives", nil) + rr := httptest.NewRecorder() + svc.GetDrives(rr, r) + + Expect(rr.Code).To(Equal(http.StatusOK)) + + body, _ := io.ReadAll(rr.Body) + Expect(body).To(MatchJSON(` + { + "value":[ + { + "driveType":"aspacetype", + "id":"aspaceid!anopaqueid", + "name":"aspacename", + "description":"read from yaml", + "root":{ + "id":"aspaceid!anopaqueid", + "webDavUrl":"https://localhost:9200/dav/spaces/aspaceid!anopaqueid" + }, + "special": [ + { + "id": "readmeid", + "name": "readme2.md", + "size": 10, + "specialFolder": { + "name": "readme" + }, + "webDavUrl": "https://localhost:9200/dav/spaces/aspaceid/readme2.md" + }, + { + "id": "imageid", + "name": "space.png", + "size": 20, + "specialFolder": { + "name": "image" + }, + "webDavUrl": "https://localhost:9200/dav/spaces/aspaceid/.img/space.png" + } + ] + } + ] + } + `)) + }) }) }) diff --git a/graph/pkg/service/v0/option.go b/graph/pkg/service/v0/option.go index 49664dde6..a60edd85a 100644 --- a/graph/pkg/service/v0/option.go +++ b/graph/pkg/service/v0/option.go @@ -12,10 +12,11 @@ type Option func(o *Options) // Options defines the available options for this package. type Options struct { - Logger log.Logger - Config *config.Config - Middleware []func(http.Handler) http.Handler - GatewayServiceClient GatewayClient + Logger log.Logger + Config *config.Config + Middleware []func(http.Handler) http.Handler + GatewayClient GatewayClient + HTTPClient HTTPClient } // newOptions initializes the available default options. @@ -50,9 +51,16 @@ func Middleware(val ...func(http.Handler) http.Handler) Option { } } -// GatewayServiceClient provides a function to set the middleware option. -func GatewayServiceClient(val GatewayClient) Option { +// WithGatewayClient provides a function to set the gateway client option. +func WithGatewayClient(val GatewayClient) Option { return func(o *Options) { - o.GatewayServiceClient = val + o.GatewayClient = val + } +} + +// WithHTTPClient provides a function to set the http client option. +func WithHTTPClient(val HTTPClient) Option { + return func(o *Options) { + o.HTTPClient = val } } diff --git a/graph/pkg/service/v0/service.go b/graph/pkg/service/v0/service.go index 990a764e9..5d62e3cdb 100644 --- a/graph/pkg/service/v0/service.go +++ b/graph/pkg/service/v0/service.go @@ -1,6 +1,7 @@ package svc import ( + "crypto/tls" "net/http" "github.com/ReneKroon/ttlcache/v2" @@ -64,15 +65,23 @@ func NewService(opts ...Option) Service { identityBackend: backend, spacePropertiesCache: ttlcache.NewCache(), } - if options.GatewayServiceClient == nil { + if options.GatewayClient == nil { var err error - svc.client, err = pool.GetGatewayServiceClient(options.Config.Reva.Address) + svc.gatewayClient, err = pool.GetGatewayServiceClient(options.Config.Reva.Address) if err != nil { options.Logger.Error().Err(err).Msg("Could not get gateway client") return nil } } else { - svc.client = options.GatewayServiceClient + svc.gatewayClient = options.GatewayClient + } + if options.HTTPClient == nil { + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{ + InsecureSkipVerify: options.Config.Spaces.Insecure, //nolint:gosec + } + svc.httpClient = &http.Client{} + } else { + svc.httpClient = options.HTTPClient } m.Route(options.Config.HTTP.Root, func(r chi.Router) { From 6e6c2a127b017b6838ab7a2e3cc78d7cec9845bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 19 Jan 2022 08:40:56 +0000 Subject: [PATCH 8/9] inline variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- graph/pkg/service/v0/driveitems.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graph/pkg/service/v0/driveitems.go b/graph/pkg/service/v0/driveitems.go index 6341446b0..0749d0a10 100644 --- a/graph/pkg/service/v0/driveitems.go +++ b/graph/pkg/service/v0/driveitems.go @@ -115,13 +115,13 @@ func cs3TimestampToTime(t *types.Timestamp) time.Time { func cs3ResourceToDriveItem(res *storageprovider.ResourceInfo) (*libregraph.DriveItem, error) { size := new(int64) *size = int64(res.Size) // uint64 -> int :boom: - name := path.Base(res.Path) driveItem := &libregraph.DriveItem{ Id: &res.Id.OpaqueId, Size: size, } - if name != "" { + + if name := path.Base(res.Path); name != "" { driveItem.Name = &name } if res.Etag != "" { From 0dfb86e80ed84b61d4c66d8ab2fdee9ef2d56121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 19 Jan 2022 08:52:47 +0000 Subject: [PATCH 9/9] address feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- graph/pkg/service/v0/driveitems.go | 5 +++-- graph/pkg/service/v0/drives.go | 6 +++--- graph/pkg/service/v0/net/headers.go | 9 +++++++++ graph/pkg/service/v0/net/headers/headers.go | 9 --------- 4 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 graph/pkg/service/v0/net/headers.go delete mode 100644 graph/pkg/service/v0/net/headers/headers.go diff --git a/graph/pkg/service/v0/driveitems.go b/graph/pkg/service/v0/driveitems.go index 0749d0a10..d77ec16cb 100644 --- a/graph/pkg/service/v0/driveitems.go +++ b/graph/pkg/service/v0/driveitems.go @@ -114,7 +114,7 @@ func cs3TimestampToTime(t *types.Timestamp) time.Time { func cs3ResourceToDriveItem(res *storageprovider.ResourceInfo) (*libregraph.DriveItem, error) { size := new(int64) - *size = int64(res.Size) // uint64 -> int :boom: + *size = int64(res.Size) // TODO lurking overflow: make size of libregraph drive item use uint64 driveItem := &libregraph.DriveItem{ Id: &res.Id.OpaqueId, @@ -132,7 +132,8 @@ func cs3ResourceToDriveItem(res *storageprovider.ResourceInfo) (*libregraph.Driv driveItem.LastModifiedDateTime = &lastModified } if res.Type == storageprovider.ResourceType_RESOURCE_TYPE_FILE && res.MimeType != "" { - driveItem.File = &libregraph.OpenGraphFile{ // FIXME We cannot use libregraph.File here because the openapi codegenerator autodetects 'File' as a go type ... + // We cannot use a libregraph.File here because the openapi codegenerator autodetects 'File' as a go type ... + driveItem.File = &libregraph.OpenGraphFile{ MimeType: &res.MimeType, } } diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index e233a9acd..0d15adc48 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -24,7 +24,7 @@ import ( "github.com/go-chi/render" libregraph "github.com/owncloud/libre-graph-api-go" "github.com/owncloud/ocis/graph/pkg/service/v0/errorcode" - "github.com/owncloud/ocis/graph/pkg/service/v0/net/headers" + "github.com/owncloud/ocis/graph/pkg/service/v0/net" "github.com/owncloud/ocis/ocis-pkg/service/grpc" sproto "github.com/owncloud/ocis/settings/pkg/proto/v0" settingsSvc "github.com/owncloud/ocis/settings/pkg/service/v0" @@ -524,11 +524,11 @@ func (g Graph) getExtendedSpaceProperties(ctx context.Context, space *storagepro return nil, fmt.Errorf("space does not support the spaces download protocol") } - httpReq, err := rhttp.NewRequest(ctx, "GET", ep, nil) + httpReq, err := rhttp.NewRequest(ctx, http.MethodGet, ep, nil) if err != nil { return nil, err } - httpReq.Header.Set(headers.TokenTransportHeader, tk) + httpReq.Header.Set(net.HeaderTokenTransport, tk) httpClient := g.GetHTTPClient() diff --git a/graph/pkg/service/v0/net/headers.go b/graph/pkg/service/v0/net/headers.go new file mode 100644 index 000000000..7886f1a1c --- /dev/null +++ b/graph/pkg/service/v0/net/headers.go @@ -0,0 +1,9 @@ +package net + +const ( + // "github.com/cs3org/reva/internal/http/services/datagateway" is internal so we redeclare it here + // HeaderTokenTransport holds the header key for the reva transfer token + HeaderTokenTransport = "X-Reva-Transfer" + // HeaderIfModifiedSince is used to mimic/pass on caching headers when using grpc + HeaderIfModifiedSince = "If-Modified-Since" +) diff --git a/graph/pkg/service/v0/net/headers/headers.go b/graph/pkg/service/v0/net/headers/headers.go deleted file mode 100644 index 4df20e10a..000000000 --- a/graph/pkg/service/v0/net/headers/headers.go +++ /dev/null @@ -1,9 +0,0 @@ -package headers - -const ( - // "github.com/cs3org/reva/internal/http/services/datagateway" is internal so we redeclare it here - // TokenTransportHeader holds the header key for the reva transfer token - TokenTransportHeader = "X-Reva-Transfer" - // IfModifiedSince is used to mimic/pass on caching headers when using grpc - IfModifiedSince = "If-Modified-Since" -)