From 59f53390a84bd16d54d9d8abe736094b49476572 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 11 Nov 2021 15:48:00 +0100 Subject: [PATCH] fix all storages --- ocis/pkg/command/storageappprovider.go | 21 ++++--------------- ocis/pkg/command/storageauthbasic.go | 21 ++++--------------- ocis/pkg/command/storageauthbearer.go | 21 ++++--------------- ocis/pkg/command/storagefrontend.go | 21 ++++--------------- ocis/pkg/command/storagegateway.go | 21 ++++--------------- ocis/pkg/command/storagegroupprovider.go | 21 ++++--------------- ocis/pkg/command/storagehome.go | 21 ++++--------------- ocis/pkg/command/storagemetadata.go | 21 ++++--------------- ocis/pkg/command/storagepubliclink.go | 21 ++++--------------- ocis/pkg/command/storagesharing.go | 21 ++++--------------- ocis/pkg/command/storageuserprovider.go | 21 ++++--------------- ocis/pkg/command/storageusers.go | 21 ++++--------------- ocis/pkg/command/util.go | 26 ++++++++++++++++++++++++ ocis/pkg/runtime/service/service.go | 4 ++++ storage/pkg/command/root.go | 9 +++++--- storage/pkg/config/config.go | 4 +--- 16 files changed, 85 insertions(+), 210 deletions(-) create mode 100644 ocis/pkg/command/util.go diff --git a/ocis/pkg/command/storageappprovider.go b/ocis/pkg/command/storageappprovider.go index cb60828d06..6672282b6e 100644 --- a/ocis/pkg/command/storageappprovider.go +++ b/ocis/pkg/command/storageappprovider.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageAppProviderCommand(cfg *config.Config) *cli.Command { Usage: "Start storage app-provider service", Category: "Extensions", Flags: flagset.AppProviderWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.AppProvider(configureStorageAppProvider(cfg)) + origCmd := command.AppProvider(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageAppProvider(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageAppProviderCommand) } diff --git a/ocis/pkg/command/storageauthbasic.go b/ocis/pkg/command/storageauthbasic.go index fe7a87eb1f..02446b4481 100644 --- a/ocis/pkg/command/storageauthbasic.go +++ b/ocis/pkg/command/storageauthbasic.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageAuthBasicCommand(cfg *config.Config) *cli.Command { Usage: "Start storage auth-basic service", Category: "Extensions", Flags: flagset.AuthBasicWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.AuthBasic(configureStorageAuthBasic(cfg)) + origCmd := command.AuthBasic(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageAuthBasic(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageAuthBasicCommand) } diff --git a/ocis/pkg/command/storageauthbearer.go b/ocis/pkg/command/storageauthbearer.go index 004d0b7936..ab14a42368 100644 --- a/ocis/pkg/command/storageauthbearer.go +++ b/ocis/pkg/command/storageauthbearer.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageAuthBearerCommand(cfg *config.Config) *cli.Command { Usage: "Start storage auth-bearer service", Category: "Extensions", Flags: flagset.AuthBearerWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.AuthBearer(configureStorageAuthBearer(cfg)) + origCmd := command.AuthBearer(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageAuthBearer(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageAuthBearerCommand) } diff --git a/ocis/pkg/command/storagefrontend.go b/ocis/pkg/command/storagefrontend.go index 220eabc744..853a9bc44a 100644 --- a/ocis/pkg/command/storagefrontend.go +++ b/ocis/pkg/command/storagefrontend.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageFrontendCommand(cfg *config.Config) *cli.Command { Usage: "Start storage frontend", Category: "Extensions", Flags: flagset.FrontendWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.Frontend(configureStorageFrontend(cfg)) + origCmd := command.Frontend(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageFrontend(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageFrontendCommand) } diff --git a/ocis/pkg/command/storagegateway.go b/ocis/pkg/command/storagegateway.go index d0e4e61fa0..a9fe1a6f3b 100644 --- a/ocis/pkg/command/storagegateway.go +++ b/ocis/pkg/command/storagegateway.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageGatewayCommand(cfg *config.Config) *cli.Command { Usage: "Start storage gateway", Category: "Extensions", Flags: flagset.GatewayWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.Gateway(configureStorageGateway(cfg)) + origCmd := command.Gateway(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageGateway(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageGatewayCommand) } diff --git a/ocis/pkg/command/storagegroupprovider.go b/ocis/pkg/command/storagegroupprovider.go index 3f77796e38..3500780beb 100644 --- a/ocis/pkg/command/storagegroupprovider.go +++ b/ocis/pkg/command/storagegroupprovider.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageGroupProviderCommand(cfg *config.Config) *cli.Command { Usage: "Start storage groupprovider service", Category: "Extensions", Flags: flagset.GroupsWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.Groups(configureStorageGroupProvider(cfg)) + origCmd := command.Groups(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageGroupProvider(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageGroupProviderCommand) } diff --git a/ocis/pkg/command/storagehome.go b/ocis/pkg/command/storagehome.go index 9e025b2856..5ed11b581e 100644 --- a/ocis/pkg/command/storagehome.go +++ b/ocis/pkg/command/storagehome.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageHomeCommand(cfg *config.Config) *cli.Command { Usage: "Start storage and data provider for /home mount", Category: "Extensions", Flags: flagset.StorageHomeWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.StorageHome(configureStorageHome(cfg)) + origCmd := command.StorageHome(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageHome(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageHomeCommand) } diff --git a/ocis/pkg/command/storagemetadata.go b/ocis/pkg/command/storagemetadata.go index 90c56da007..0729d6e311 100644 --- a/ocis/pkg/command/storagemetadata.go +++ b/ocis/pkg/command/storagemetadata.go @@ -4,7 +4,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -16,28 +15,16 @@ func StorageMetadataCommand(cfg *config.Config) *cli.Command { Usage: "Start storage and data service for metadata", Category: "Extensions", Flags: flagset.StorageMetadata(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.StorageMetadata(configureStorageMetadata(cfg)) + origCmd := command.StorageMetadata(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageMetadata(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageMetadataCommand) } diff --git a/ocis/pkg/command/storagepubliclink.go b/ocis/pkg/command/storagepubliclink.go index 0d94d5afb6..07e7d94763 100644 --- a/ocis/pkg/command/storagepubliclink.go +++ b/ocis/pkg/command/storagepubliclink.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StoragePublicLinkCommand(cfg *config.Config) *cli.Command { Usage: "Start storage public link storage", Category: "Extensions", Flags: flagset.StoragePublicLink(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.StoragePublicLink(configureStoragePublicLink(cfg)) + origCmd := command.StoragePublicLink(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStoragePublicLink(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StoragePublicLinkCommand) } diff --git a/ocis/pkg/command/storagesharing.go b/ocis/pkg/command/storagesharing.go index d712f9e9a3..672e209e7a 100644 --- a/ocis/pkg/command/storagesharing.go +++ b/ocis/pkg/command/storagesharing.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageSharingCommand(cfg *config.Config) *cli.Command { Usage: "Start storage sharing service", Category: "Extensions", Flags: flagset.SharingWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.Sharing(configureStorageSharing(cfg)) + origCmd := command.Sharing(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageSharing(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageSharingCommand) } diff --git a/ocis/pkg/command/storageuserprovider.go b/ocis/pkg/command/storageuserprovider.go index ea701a1c3b..671d87ff9b 100644 --- a/ocis/pkg/command/storageuserprovider.go +++ b/ocis/pkg/command/storageuserprovider.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageUserProviderCommand(cfg *config.Config) *cli.Command { Usage: "Start storage userprovider service", Category: "Extensions", Flags: flagset.UsersWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.Users(configureStorageUserProvider(cfg)) + origCmd := command.Users(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageUserProvider(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageUserProviderCommand) } diff --git a/ocis/pkg/command/storageusers.go b/ocis/pkg/command/storageusers.go index 80f32e796b..c6c2b7700b 100644 --- a/ocis/pkg/command/storageusers.go +++ b/ocis/pkg/command/storageusers.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/storage/pkg/command" - svcconfig "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -19,28 +18,16 @@ func StorageUsersCommand(cfg *config.Config) *cli.Command { Usage: "Start storage and data provider for /users mount", Category: "Extensions", Flags: flagset.StorageUsersWithConfig(cfg.Storage), + Before: func(ctx *cli.Context) error { + return ParseStorageCommon(ctx, cfg) + }, Action: func(c *cli.Context) error { - origCmd := command.StorageUsers(configureStorageUsers(cfg)) + origCmd := command.StorageUsers(cfg.Storage) return handleOriginalAction(c, origCmd) }, } } -func configureStorageUsers(cfg *config.Config) *svcconfig.Config { - cfg.Storage.Log.Level = cfg.Log.Level - cfg.Storage.Log.Pretty = cfg.Log.Pretty - cfg.Storage.Log.Color = cfg.Log.Color - - if cfg.Tracing.Enabled { - cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled - cfg.Storage.Tracing.Type = cfg.Tracing.Type - cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint - cfg.Storage.Tracing.Collector = cfg.Tracing.Collector - } - - return cfg.Storage -} - func init() { register.AddCommand(StorageUsersCommand) } diff --git a/ocis/pkg/command/util.go b/ocis/pkg/command/util.go new file mode 100644 index 0000000000..a2e9b1abc0 --- /dev/null +++ b/ocis/pkg/command/util.go @@ -0,0 +1,26 @@ +package command + +import ( + "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/owncloud/ocis/ocis-pkg/shared" + "github.com/urfave/cli/v2" +) + +func ParseStorageCommon(ctx *cli.Context, cfg *config.Config) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + + if cfg.Storage.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Storage.Log = &shared.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Storage.Log == nil && cfg.Commons == nil { + cfg.Storage.Log = &shared.Log{} + } + + return nil +} diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index e272560736..a725b04bf8 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -167,6 +167,10 @@ func Start(o ...Option) error { } } + if s.cfg.Storage.Log == nil { + s.cfg.Storage.Log = &shared.Log{} + } + s.cfg.Storage.Log.Color = s.cfg.Commons.Color s.cfg.Storage.Log.Level = s.cfg.Commons.Level s.cfg.Storage.Log.Pretty = s.cfg.Commons.Pretty diff --git a/storage/pkg/command/root.go b/storage/pkg/command/root.go index a2cce06b1c..4c526e06a4 100644 --- a/storage/pkg/command/root.go +++ b/storage/pkg/command/root.go @@ -4,6 +4,8 @@ import ( "os" "strings" + "github.com/owncloud/ocis/ocis-pkg/shared" + "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/ocis-pkg/version" "github.com/owncloud/ocis/storage/pkg/config" @@ -25,10 +27,11 @@ func Execute(cfg *config.Config) error { Email: "support@owncloud.com", }, }, - - //Flags: flagset.RootWithConfig(cfg), - Before: func(c *cli.Context) error { + if cfg.Log == nil { + cfg.Log = &shared.Log{} + } + logger := NewLogger(cfg) viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index cda41e5d57..19c45739b5 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -512,7 +512,5 @@ type Config struct { // New initializes a new configuration with or without defaults. func New() *Config { - return &Config{ - Log: &shared.Log{}, - } + return &Config{} }