From 8797cf3b5a0d1026270d8ddada850de87148ac29 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Mon, 22 Nov 2021 22:27:29 +0100 Subject: [PATCH] Revert "removed redundant ocis config parsing" This reverts commit c700ccab1f808520f816f8e90c34d193359def21. --- ocis/pkg/command/accounts.go | 4 ++++ ocis/pkg/command/glauth.go | 4 ++++ ocis/pkg/command/health.go | 3 +++ ocis/pkg/command/idp.go | 4 ++++ ocis/pkg/command/ocs.go | 4 ++++ ocis/pkg/command/proxy.go | 4 ++++ ocis/pkg/command/server.go | 2 +- ocis/pkg/command/settings.go | 4 ++++ ocis/pkg/command/store.go | 18 ++++++++++++++++++ ocis/pkg/command/thumbnails.go | 4 ++++ ocis/pkg/command/web.go | 4 ++++ ocis/pkg/command/webdav.go | 4 ++++ 12 files changed, 58 insertions(+), 1 deletion(-) diff --git a/ocis/pkg/command/accounts.go b/ocis/pkg/command/accounts.go index 7597ae2a2..1cacd70d0 100644 --- a/ocis/pkg/command/accounts.go +++ b/ocis/pkg/command/accounts.go @@ -25,6 +25,10 @@ func AccountsCommand(cfg *config.Config) *cli.Command { command.PrintVersion(cfg.Accounts), }, Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + if cfg.Commons != nil { cfg.Accounts.Commons = cfg.Commons } diff --git a/ocis/pkg/command/glauth.go b/ocis/pkg/command/glauth.go index da059c0cf..c6baacfde 100644 --- a/ocis/pkg/command/glauth.go +++ b/ocis/pkg/command/glauth.go @@ -14,6 +14,10 @@ func GLAuthCommand(cfg *config.Config) *cli.Command { Usage: "Start glauth server", Category: "Extensions", Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + if cfg.Commons != nil { cfg.GLAuth.Commons = cfg.Commons } diff --git a/ocis/pkg/command/health.go b/ocis/pkg/command/health.go index c5d46ceac..f293dbf8f 100644 --- a/ocis/pkg/command/health.go +++ b/ocis/pkg/command/health.go @@ -14,6 +14,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/ocis/pkg/command/idp.go b/ocis/pkg/command/idp.go index c6d9c86be..7b35c15ba 100644 --- a/ocis/pkg/command/idp.go +++ b/ocis/pkg/command/idp.go @@ -17,6 +17,10 @@ func IDPCommand(cfg *config.Config) *cli.Command { command.PrintVersion(cfg.IDP), }, Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + if cfg.Commons != nil { cfg.IDP.Commons = cfg.Commons } diff --git a/ocis/pkg/command/ocs.go b/ocis/pkg/command/ocs.go index e53f01fa7..17f2d927e 100644 --- a/ocis/pkg/command/ocs.go +++ b/ocis/pkg/command/ocs.go @@ -17,6 +17,10 @@ func OCSCommand(cfg *config.Config) *cli.Command { Usage: "Start ocs server", Category: "Extensions", Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + if cfg.Commons != nil { cfg.OCS.Commons = cfg.Commons } diff --git a/ocis/pkg/command/proxy.go b/ocis/pkg/command/proxy.go index 570a45046..321298689 100644 --- a/ocis/pkg/command/proxy.go +++ b/ocis/pkg/command/proxy.go @@ -20,6 +20,10 @@ func ProxyCommand(cfg *config.Config) *cli.Command { command.PrintVersion(cfg.Proxy), }, Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + if cfg.Commons != nil { cfg.Proxy.Commons = cfg.Commons } diff --git a/ocis/pkg/command/server.go b/ocis/pkg/command/server.go index 728ca9f85..336a39e87 100644 --- a/ocis/pkg/command/server.go +++ b/ocis/pkg/command/server.go @@ -25,7 +25,7 @@ func Server(cfg *config.Config) *cli.Command { cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/") } - return nil + return ParseConfig(c, cfg) }, Action: func(c *cli.Context) error { diff --git a/ocis/pkg/command/settings.go b/ocis/pkg/command/settings.go index b7fe0c09b..adb37be5b 100644 --- a/ocis/pkg/command/settings.go +++ b/ocis/pkg/command/settings.go @@ -20,6 +20,10 @@ func SettingsCommand(cfg *config.Config) *cli.Command { command.PrintVersion(cfg.Settings), }, Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + if cfg.Commons != nil { cfg.Settings.Commons = cfg.Commons } diff --git a/ocis/pkg/command/store.go b/ocis/pkg/command/store.go index b41c37b51..639462117 100644 --- a/ocis/pkg/command/store.go +++ b/ocis/pkg/command/store.go @@ -5,6 +5,7 @@ package command import ( "github.com/owncloud/ocis/ocis-pkg/config" + "github.com/owncloud/ocis/ocis-pkg/shared" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/owncloud/ocis/store/pkg/command" "github.com/urfave/cli/v2" @@ -12,6 +13,8 @@ import ( // StoreCommand is the entrypoint for the ocs command. func StoreCommand(cfg *config.Config) *cli.Command { + var globalLog shared.Log + return &cli.Command{ Name: "store", Usage: "Start a go-micro store", @@ -19,7 +22,22 @@ func StoreCommand(cfg *config.Config) *cli.Command { Subcommands: []*cli.Command{ command.PrintVersion(cfg.Store), }, + Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + + globalLog = cfg.Log + + return nil + }, Action: func(c *cli.Context) error { + // if accounts logging is empty in ocis.yaml + if (cfg.Store.Log == shared.Log{}) && (globalLog != shared.Log{}) { + // we can safely inherit the global logging values. + cfg.Store.Log = globalLog + } + origCmd := command.Server(cfg.Store) return handleOriginalAction(c, origCmd) }, diff --git a/ocis/pkg/command/thumbnails.go b/ocis/pkg/command/thumbnails.go index 480ca4dcb..0562b5d61 100644 --- a/ocis/pkg/command/thumbnails.go +++ b/ocis/pkg/command/thumbnails.go @@ -20,6 +20,10 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command { command.PrintVersion(cfg.Thumbnails), }, Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + if cfg.Commons != nil { cfg.Thumbnails.Commons = cfg.Commons } diff --git a/ocis/pkg/command/web.go b/ocis/pkg/command/web.go index 8085e0dd6..c3f2df2ea 100644 --- a/ocis/pkg/command/web.go +++ b/ocis/pkg/command/web.go @@ -14,6 +14,10 @@ func WebCommand(cfg *config.Config) *cli.Command { Usage: "Start web server", Category: "Extensions", Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + if cfg.Commons != nil { cfg.Web.Commons = cfg.Commons } diff --git a/ocis/pkg/command/webdav.go b/ocis/pkg/command/webdav.go index 2dee0070b..0502642bb 100644 --- a/ocis/pkg/command/webdav.go +++ b/ocis/pkg/command/webdav.go @@ -21,6 +21,10 @@ func WebDAVCommand(cfg *config.Config) *cli.Command { command.PrintVersion(cfg.WebDAV), }, Before: func(ctx *cli.Context) error { + if err := ParseConfig(ctx, cfg); err != nil { + return err + } + if cfg.Commons != nil { cfg.WebDAV.Commons = cfg.Commons }