From 2bfdab873508ddd04a330995366912b9f898ea15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 9 Mar 2021 16:03:47 +0000 Subject: [PATCH] add remaining services MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- accounts/pkg/command/root.go | 8 +++--- glauth/pkg/command/root.go | 8 +++--- idp/pkg/command/root.go | 8 +++--- ocis/pkg/runtime/service/service.go | 32 +++++++++++++++++++++++- ocs/pkg/command/root.go | 8 +++--- onlyoffice/pkg/command/root.go | 3 +-- proxy/pkg/command/root.go | 8 +++--- settings/pkg/command/root.go | 2 +- storage/pkg/command/authbasic.go | 19 ++++---------- storage/pkg/command/authbearer.go | 19 ++++---------- storage/pkg/command/frontend.go | 19 ++++---------- storage/pkg/command/gateway.go | 19 ++++---------- storage/pkg/command/groups.go | 19 ++++---------- storage/pkg/command/sharing.go | 19 ++++---------- storage/pkg/command/storagehome.go | 19 ++++---------- storage/pkg/command/storagemetadata.go | 19 ++++---------- storage/pkg/command/storagepubliclink.go | 19 ++++---------- storage/pkg/command/storageusers.go | 19 ++++---------- storage/pkg/command/users.go | 19 ++++---------- storage/pkg/config/config.go | 4 +-- store/pkg/command/root.go | 8 +++--- thumbnails/pkg/command/root.go | 8 +++--- web/pkg/command/root.go | 8 +++--- webdav/pkg/command/root.go | 8 +++--- 24 files changed, 135 insertions(+), 187 deletions(-) diff --git a/accounts/pkg/command/root.go b/accounts/pkg/command/root.go index 6f64a6605..3b830442d 100644 --- a/accounts/pkg/command/root.go +++ b/accounts/pkg/command/root.go @@ -7,6 +7,8 @@ import ( "github.com/owncloud/ocis/accounts/pkg/flagset" + "github.com/thejerf/suture" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/micro/cli/v2" "github.com/owncloud/ocis/accounts/pkg/config" "github.com/owncloud/ocis/accounts/pkg/version" @@ -127,13 +129,13 @@ type SutureService struct { } // NewSutureService creates a new accounts.SutureService -func NewSutureService(ctx context.Context, cfg *config.Config) SutureService { +func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg.Context = sctx // propagate the context down to the go-micro services. + cfg.Accounts.Context = sctx // propagate the context down to the go-micro services. return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Accounts, } } diff --git a/glauth/pkg/command/root.go b/glauth/pkg/command/root.go index 97c9ae95d..a9fd8a7ae 100644 --- a/glauth/pkg/command/root.go +++ b/glauth/pkg/command/root.go @@ -9,8 +9,10 @@ import ( "github.com/owncloud/ocis/glauth/pkg/config" "github.com/owncloud/ocis/glauth/pkg/flagset" "github.com/owncloud/ocis/glauth/pkg/version" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/spf13/viper" + "github.com/thejerf/suture" ) // Execute is the entry point for the ocis-glauth command. @@ -115,13 +117,13 @@ type SutureService struct { } // NewSutureService creates a new glauth.SutureService -func NewSutureService(ctx context.Context, cfg *config.Config) SutureService { +func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg.Context = sctx // propagate the context down to the go-micro services. + cfg.GLAuth.Context = sctx return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.GLAuth, } } diff --git a/idp/pkg/command/root.go b/idp/pkg/command/root.go index 08e4023f3..927a7db76 100644 --- a/idp/pkg/command/root.go +++ b/idp/pkg/command/root.go @@ -9,8 +9,10 @@ import ( "github.com/owncloud/ocis/idp/pkg/config" "github.com/owncloud/ocis/idp/pkg/flagset" "github.com/owncloud/ocis/idp/pkg/version" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/spf13/viper" + "github.com/thejerf/suture" ) // Execute is the entry point for the ocis-idp command. @@ -116,13 +118,13 @@ type SutureService struct { } // NewSutureService creates a new idp.SutureService -func NewSutureService(ctx context.Context, cfg *config.Config) SutureService { +func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg.Context = sctx // propagate the context down to the go-micro services. + cfg.IDP.Context = sctx return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.IDP, } } diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 1e0dd946f..4c2ec0597 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -14,8 +14,18 @@ import ( "github.com/thejerf/suture" + accounts "github.com/owncloud/ocis/accounts/pkg/command" + glauth "github.com/owncloud/ocis/glauth/pkg/command" + idp "github.com/owncloud/ocis/idp/pkg/command" + ocs "github.com/owncloud/ocis/ocs/pkg/command" onlyoffice "github.com/owncloud/ocis/onlyoffice/pkg/command" + proxy "github.com/owncloud/ocis/proxy/pkg/command" settings "github.com/owncloud/ocis/settings/pkg/command" + storage "github.com/owncloud/ocis/storage/pkg/command" + store "github.com/owncloud/ocis/store/pkg/command" + thumbnails "github.com/owncloud/ocis/thumbnails/pkg/command" + web "github.com/owncloud/ocis/web/pkg/command" + webdav "github.com/owncloud/ocis/webdav/pkg/command" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/runtime/config" @@ -92,8 +102,28 @@ func NewService(options ...Option) (*Service, error) { cfg: opts.Config, } - s.ServicesRegistry["onlyoffice"] = onlyoffice.NewSutureService s.ServicesRegistry["settings"] = settings.NewSutureService + s.ServicesRegistry["storage-metadata"] = storage.NewStorageMetadata + s.ServicesRegistry["accounts"] = accounts.NewSutureService + s.ServicesRegistry["glauth"] = glauth.NewSutureService + s.ServicesRegistry["idp"] = idp.NewSutureService + s.ServicesRegistry["ocs"] = ocs.NewSutureService + s.ServicesRegistry["onlyoffice"] = onlyoffice.NewSutureService + s.ServicesRegistry["proxy"] = proxy.NewSutureService + s.ServicesRegistry["store"] = store.NewSutureService + s.ServicesRegistry["thumbnails"] = thumbnails.NewSutureService + s.ServicesRegistry["web"] = web.NewSutureService + s.ServicesRegistry["webdav"] = webdav.NewSutureService + s.ServicesRegistry["storage-frontend"] = storage.NewFrontend + s.ServicesRegistry["storage-gateway"] = storage.NewGateway + s.ServicesRegistry["storage-users"] = storage.NewUsersProviderService + s.ServicesRegistry["storage-groupsprovider"] = storage.NewGroupsProvider + s.ServicesRegistry["storage-authbasic"] = storage.NewAuthBasic + s.ServicesRegistry["storage-authbearer"] = storage.NewAuthBearer + s.ServicesRegistry["storage-home"] = storage.NewStorageHome + s.ServicesRegistry["storage-users"] = storage.NewStorageUsers + s.ServicesRegistry["storage-public-link"] = storage.NewStoragePublicLink + s.ServicesRegistry["storage-sharing"] = storage.NewSharing return s, nil } diff --git a/ocs/pkg/command/root.go b/ocs/pkg/command/root.go index d5b7d77d9..e09e93ab0 100644 --- a/ocs/pkg/command/root.go +++ b/ocs/pkg/command/root.go @@ -6,10 +6,12 @@ import ( "strings" "github.com/micro/cli/v2" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/ocs/pkg/config" "github.com/owncloud/ocis/ocs/pkg/version" "github.com/spf13/viper" + "github.com/thejerf/suture" ) // Execute is the entry point for the ocis-ocs command. @@ -113,13 +115,13 @@ type SutureService struct { } // NewSutureService creates a new ocs.SutureService -func NewSutureService(ctx context.Context, cfg *config.Config) SutureService { +func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg.Context = sctx // propagate the context down to the go-micro services. + cfg.OCS.Context = sctx return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.OCS, } } diff --git a/onlyoffice/pkg/command/root.go b/onlyoffice/pkg/command/root.go index c5975f658..c4e16b0d9 100644 --- a/onlyoffice/pkg/command/root.go +++ b/onlyoffice/pkg/command/root.go @@ -5,8 +5,6 @@ import ( "os" "strings" - "github.com/thejerf/suture" - "github.com/micro/cli/v2" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" @@ -14,6 +12,7 @@ import ( "github.com/owncloud/ocis/onlyoffice/pkg/flagset" "github.com/owncloud/ocis/onlyoffice/pkg/version" "github.com/spf13/viper" + "github.com/thejerf/suture" ) // Execute is the entry point for the ocis-onlyoffice command. diff --git a/proxy/pkg/command/root.go b/proxy/pkg/command/root.go index 40057a361..28a3c6145 100644 --- a/proxy/pkg/command/root.go +++ b/proxy/pkg/command/root.go @@ -6,11 +6,13 @@ import ( "strings" "github.com/micro/cli/v2" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/proxy/pkg/config" "github.com/owncloud/ocis/proxy/pkg/flagset" "github.com/owncloud/ocis/proxy/pkg/version" "github.com/spf13/viper" + "github.com/thejerf/suture" ) // Execute is the entry point for the ocis-proxy command. @@ -117,13 +119,13 @@ type SutureService struct { } // NewSutureService creates a new proxy.SutureService -func NewSutureService(ctx context.Context, cfg *config.Config) SutureService { +func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg.Context = sctx // propagate the context down to the go-micro services. + cfg.Proxy.Context = sctx return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Proxy, } } diff --git a/settings/pkg/command/root.go b/settings/pkg/command/root.go index 72c674f04..8b67b59e0 100644 --- a/settings/pkg/command/root.go +++ b/settings/pkg/command/root.go @@ -5,8 +5,8 @@ import ( "os" "strings" + "github.com/thejerf/suture" - "github.com/micro/cli/v2" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" diff --git a/storage/pkg/command/authbasic.go b/storage/pkg/command/authbasic.go index f24349a95..a9f960dcd 100644 --- a/storage/pkg/command/authbasic.go +++ b/storage/pkg/command/authbasic.go @@ -9,6 +9,8 @@ import ( "path/filepath" "time" + "github.com/thejerf/suture" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -208,24 +210,13 @@ type AuthBasicSutureService struct { } // NewAuthBasicSutureService creates a new store.AuthBasicSutureService -func NewAuthBasic(ctx context.Context, o ...Option) AuthBasicSutureService { +func NewAuthBasic(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.AuthBasic.Context = sctx return AuthBasicSutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/authbearer.go b/storage/pkg/command/authbearer.go index 44548664f..0152a7bda 100644 --- a/storage/pkg/command/authbearer.go +++ b/storage/pkg/command/authbearer.go @@ -8,6 +8,8 @@ import ( "path" "time" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -188,24 +190,13 @@ type AuthBearerSutureService struct { } // NewAuthBearerSutureService creates a new gateway.AuthBearerSutureService -func NewAuthBearer(ctx context.Context, o ...Option) AuthBearerSutureService { +func NewAuthBearer(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.AuthBearer.Context = sctx return AuthBearerSutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index bcae5e92c..9e9fb2631 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -10,6 +10,8 @@ import ( "strings" "time" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -336,24 +338,13 @@ type FrontendSutureService struct { } // NewFrontendSutureService creates a new frontend.FrontendSutureService -func NewFrontend(ctx context.Context, o ...Option) FrontendSutureService { +func NewFrontend(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.Frontend.Context = sctx return FrontendSutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/gateway.go b/storage/pkg/command/gateway.go index ba04f15dc..e1faafcb1 100644 --- a/storage/pkg/command/gateway.go +++ b/storage/pkg/command/gateway.go @@ -9,6 +9,8 @@ import ( "strings" "time" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -265,24 +267,13 @@ type GatewaySutureService struct { } // NewGatewaySutureService creates a new gateway.GatewaySutureService -func NewGateway(ctx context.Context, o ...Option) GatewaySutureService { +func NewGateway(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.Gateway.Context = sctx return GatewaySutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/groups.go b/storage/pkg/command/groups.go index ebef95c9a..1e50bd3c9 100644 --- a/storage/pkg/command/groups.go +++ b/storage/pkg/command/groups.go @@ -9,6 +9,8 @@ import ( "path/filepath" "time" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -222,24 +224,13 @@ type GroupsProvider struct { } // NewGroupsProvider creates a new storage.GroupsProvider -func NewGroupsProvider(ctx context.Context, o ...Option) GroupsProvider { +func NewGroupsProvider(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.Groups.Context = sctx return GroupsProvider{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index 38cde9801..47e4f1aca 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -9,6 +9,8 @@ import ( "path/filepath" "time" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -211,24 +213,13 @@ type SharingSutureService struct { } // NewSharingSutureService creates a new store.SharingSutureService -func NewSharing(ctx context.Context, o ...Option) SharingSutureService { +func NewSharing(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.Sharing.Context = sctx return SharingSutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/storagehome.go b/storage/pkg/command/storagehome.go index 51aad24a8..bdfe3d178 100644 --- a/storage/pkg/command/storagehome.go +++ b/storage/pkg/command/storagehome.go @@ -8,6 +8,8 @@ import ( "path" "time" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -207,24 +209,13 @@ type StorageHomeSutureService struct { } // NewStorageHomeSutureService creates a new storage.StorageHomeSutureService -func NewStorageHome(ctx context.Context, o ...Option) StorageHomeSutureService { +func NewStorageHome(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.StorageHome.Context = sctx return StorageHomeSutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/storagemetadata.go b/storage/pkg/command/storagemetadata.go index 4517efc01..64380fd92 100644 --- a/storage/pkg/command/storagemetadata.go +++ b/storage/pkg/command/storagemetadata.go @@ -10,7 +10,8 @@ import ( "github.com/gofrs/uuid" "github.com/owncloud/ocis/storage/pkg/service/external" - + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/micro/cli/v2" "github.com/oklog/run" @@ -228,23 +229,13 @@ type SutureService struct { } // NewSutureService creates a new storagemetadata.SutureService -func NewStorageMetadata(ctx context.Context, o ...Option) SutureService { +func NewStorageMetadata(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - + cfg.Storage.Reva.StorageMetadata.Context = sctx return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/storagepubliclink.go b/storage/pkg/command/storagepubliclink.go index cbd3d8e87..0cbeecd2c 100644 --- a/storage/pkg/command/storagepubliclink.go +++ b/storage/pkg/command/storagepubliclink.go @@ -8,6 +8,8 @@ import ( "path" "time" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -185,24 +187,13 @@ type StoragePublicLinkSutureService struct { } // NewStoragePublicLinkSutureService creates a new storage.StoragePublicLinkSutureService -func NewStoragePublicLink(ctx context.Context, o ...Option) StoragePublicLinkSutureService { +func NewStoragePublicLink(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.StoragePublicLink.Context = sctx return StoragePublicLinkSutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/storageusers.go b/storage/pkg/command/storageusers.go index 76036e532..72e1ea2ca 100644 --- a/storage/pkg/command/storageusers.go +++ b/storage/pkg/command/storageusers.go @@ -8,6 +8,8 @@ import ( "path" "time" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -207,24 +209,13 @@ type StorageUsersSutureService struct { } // NewStorageUsersSutureService creates a new storage.StorageUsersSutureService -func NewStorageUsers(ctx context.Context, o ...Option) StorageUsersSutureService { +func NewStorageUsers(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.StorageUsers.Context = sctx return StorageUsersSutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/command/users.go b/storage/pkg/command/users.go index f76270692..c302c2094 100644 --- a/storage/pkg/command/users.go +++ b/storage/pkg/command/users.go @@ -9,6 +9,8 @@ import ( "path/filepath" "time" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/thejerf/suture" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" @@ -223,24 +225,13 @@ type UsersProviderService struct { } // NewUsersProviderService creates a new storage.UsersProviderService -func NewUsersProviderService(ctx context.Context, o ...Option) UsersProviderService { +func NewUsersProviderService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg := config.New() - - opts := newOptions(o...) - - // merge config and options - cfg.Context = sctx - - cfg.Log.Level = opts.LogLevel - cfg.Log.Pretty = opts.LogPretty - cfg.Log.Color = opts.LogColor - - cfg.Context = sctx + cfg.Storage.Reva.Users.Context = sctx return UsersProviderService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Storage, } } diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 662566b38..5285024ad 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -76,6 +76,8 @@ type Port struct { // Config can be used to configure the reva instance. // Services and Protocol will be ignored if this is used Config map[string]interface{} + + Context context.Context } // Users defines the available users configuration. @@ -378,8 +380,6 @@ type Config struct { Reva Reva Tracing Tracing Asset Asset - - Context context.Context } // New initializes a new configuration with or without defaults. diff --git a/store/pkg/command/root.go b/store/pkg/command/root.go index bc548b5ae..65b4c1de0 100644 --- a/store/pkg/command/root.go +++ b/store/pkg/command/root.go @@ -6,11 +6,13 @@ import ( "strings" "github.com/micro/cli/v2" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/store/pkg/config" "github.com/owncloud/ocis/store/pkg/flagset" "github.com/owncloud/ocis/store/pkg/version" "github.com/spf13/viper" + "github.com/thejerf/suture" ) // Execute is the entry point for the ocis-store command. @@ -116,13 +118,13 @@ type SutureService struct { } // NewSutureService creates a new store.SutureService -func NewSutureService(ctx context.Context, cfg *config.Config) SutureService { +func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg.Context = sctx // propagate the context down to the go-micro services. + cfg.Store.Context = sctx return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Store, } } diff --git a/thumbnails/pkg/command/root.go b/thumbnails/pkg/command/root.go index 6f1228553..8db178e40 100644 --- a/thumbnails/pkg/command/root.go +++ b/thumbnails/pkg/command/root.go @@ -6,10 +6,12 @@ import ( "strings" "github.com/micro/cli/v2" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/thumbnails/pkg/config" "github.com/owncloud/ocis/thumbnails/pkg/version" "github.com/spf13/viper" + "github.com/thejerf/suture" ) // Execute is the entry point for the ocis-thumbnails command. @@ -113,13 +115,13 @@ type SutureService struct { } // NewSutureService creates a new thumbnails.SutureService -func NewSutureService(ctx context.Context, cfg *config.Config) SutureService { +func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg.Context = sctx // propagate the context down to the go-micro services. + cfg.Thumbnails.Context = sctx return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Thumbnails, } } diff --git a/web/pkg/command/root.go b/web/pkg/command/root.go index 69ae423db..0aadd47be 100644 --- a/web/pkg/command/root.go +++ b/web/pkg/command/root.go @@ -6,10 +6,12 @@ import ( "strings" "github.com/micro/cli/v2" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/web/pkg/config" "github.com/owncloud/ocis/web/pkg/version" "github.com/spf13/viper" + "github.com/thejerf/suture" ) // Execute is the entry point for the web command. @@ -109,13 +111,13 @@ type SutureService struct { } // NewSutureService creates a new web.SutureService -func NewSutureService(ctx context.Context, cfg *config.Config) SutureService { +func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg.Context = sctx // propagate the context down to the go-micro services. + cfg.Web.Context = sctx return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.Web, } } diff --git a/webdav/pkg/command/root.go b/webdav/pkg/command/root.go index 31d216264..aa26687b7 100644 --- a/webdav/pkg/command/root.go +++ b/webdav/pkg/command/root.go @@ -6,10 +6,12 @@ import ( "strings" "github.com/micro/cli/v2" + ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/webdav/pkg/config" "github.com/owncloud/ocis/webdav/pkg/version" "github.com/spf13/viper" + "github.com/thejerf/suture" ) // Execute is the entry point for the ocis-webdav command. @@ -111,13 +113,13 @@ type SutureService struct { } // NewSutureService creates a new webdav.SutureService -func NewSutureService(ctx context.Context, cfg *config.Config) SutureService { +func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { sctx, cancel := context.WithCancel(ctx) - cfg.Context = sctx // propagate the context down to the go-micro services. + cfg.WebDAV.Context = sctx return SutureService{ ctx: sctx, cancel: cancel, - cfg: cfg, + cfg: cfg.WebDAV, } }