diff --git a/ocis/pkg/command/ocs.go b/ocis/pkg/command/ocs.go index fcf0b57b0e..80e02a9f4e 100644 --- a/ocis/pkg/command/ocs.go +++ b/ocis/pkg/command/ocs.go @@ -22,6 +22,9 @@ func OCSCommand(cfg *config.Config) *cli.Command { Subcommands: []*cli.Command{ command.PrintVersion(cfg.OCS), }, + Before: func(ctx *cli.Context) error { + return ParseConfig(ctx, cfg) + }, Action: func(c *cli.Context) error { origCmd := command.Server(configureOCS(cfg)) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/onlyoffice.go b/ocis/pkg/command/onlyoffice.go index 6468a501ed..b0889c72b3 100644 --- a/ocis/pkg/command/onlyoffice.go +++ b/ocis/pkg/command/onlyoffice.go @@ -16,6 +16,9 @@ func OnlyofficeCommand(cfg *config.Config) *cli.Command { Usage: "Start onlyoffice server", Category: "Extensions", Flags: flagset.ServerWithConfig(cfg.Onlyoffice), + Before: func(ctx *cli.Context) error { + return ParseConfig(ctx, cfg) + }, Action: func(c *cli.Context) error { origCmd := command.Server(configureOnlyoffice(cfg)) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/settings.go b/ocis/pkg/command/settings.go index 28d4c43d89..1da359c11d 100644 --- a/ocis/pkg/command/settings.go +++ b/ocis/pkg/command/settings.go @@ -22,6 +22,9 @@ func SettingsCommand(cfg *config.Config) *cli.Command { Subcommands: []*cli.Command{ command.PrintVersion(cfg.Settings), }, + Before: func(ctx *cli.Context) error { + return ParseConfig(ctx, cfg) + }, Action: func(c *cli.Context) error { origCmd := command.Server(configureSettings(cfg)) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/store.go b/ocis/pkg/command/store.go index fac98f78f1..6a0403eb24 100644 --- a/ocis/pkg/command/store.go +++ b/ocis/pkg/command/store.go @@ -22,6 +22,9 @@ func StoreCommand(cfg *config.Config) *cli.Command { Subcommands: []*cli.Command{ command.PrintVersion(cfg.Store), }, + Before: func(ctx *cli.Context) error { + return ParseConfig(ctx, cfg) + }, Action: func(c *cli.Context) error { origCmd := command.Server(configureStore(cfg)) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/thumbnails.go b/ocis/pkg/command/thumbnails.go index 75e2024754..f071e5cd8c 100644 --- a/ocis/pkg/command/thumbnails.go +++ b/ocis/pkg/command/thumbnails.go @@ -23,6 +23,9 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command { Subcommands: []*cli.Command{ command.PrintVersion(cfg.Thumbnails), }, + Before: func(ctx *cli.Context) error { + return ParseConfig(ctx, cfg) + }, Action: func(c *cli.Context) error { origCmd := command.Server(configureThumbnails(cfg)) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/web.go b/ocis/pkg/command/web.go index 0aa3b6d145..199a50d3aa 100644 --- a/ocis/pkg/command/web.go +++ b/ocis/pkg/command/web.go @@ -16,6 +16,9 @@ func WebCommand(cfg *config.Config) *cli.Command { Usage: "Start web server", Category: "Extensions", Flags: flagset.ServerWithConfig(cfg.Web), + Before: func(ctx *cli.Context) error { + return ParseConfig(ctx, cfg) + }, Action: func(c *cli.Context) error { origCmd := command.Server(configureWeb(cfg)) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/webdav.go b/ocis/pkg/command/webdav.go index 1e3cc19a31..94a6fadb88 100644 --- a/ocis/pkg/command/webdav.go +++ b/ocis/pkg/command/webdav.go @@ -22,6 +22,9 @@ func WebDAVCommand(cfg *config.Config) *cli.Command { Subcommands: []*cli.Command{ command.PrintVersion(cfg.WebDAV), }, + Before: func(ctx *cli.Context) error { + return ParseConfig(ctx, cfg) + }, Action: func(c *cli.Context) error { origCmd := command.Server(configureWebDAV(cfg)) return handleOriginalAction(c, origCmd) diff --git a/ocs/pkg/flagset/flagset.go b/ocs/pkg/flagset/flagset.go index dc260c9820..a8b1fc7c49 100644 --- a/ocs/pkg/flagset/flagset.go +++ b/ocs/pkg/flagset/flagset.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/ocs/pkg/config" ) @@ -10,7 +11,7 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9114", + Value: flags.OverrideDefaultString(cfg.Debug.Addr, "0.0.0.0:9114"), Usage: "Address to debug endpoint", EnvVars: []string{"OCS_DEBUG_ADDR"}, Destination: &cfg.Debug.Addr, @@ -48,49 +49,49 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { }, &cli.BoolFlag{ Name: "tracing-enabled", - Value: false, + Value: flags.OverrideDefaultBool(cfg.Tracing.Enabled, false), Usage: "Enable sending traces", EnvVars: []string{"OCS_TRACING_ENABLED"}, Destination: &cfg.Tracing.Enabled, }, &cli.StringFlag{ Name: "tracing-type", - Value: "jaeger", + Value: flags.OverrideDefaultString(cfg.Tracing.Type, "jaeger"), Usage: "Tracing backend type", EnvVars: []string{"OCS_TRACING_TYPE"}, Destination: &cfg.Tracing.Type, }, &cli.StringFlag{ Name: "tracing-endpoint", - Value: "", + Value: flags.OverrideDefaultString(cfg.Tracing.Endpoint, ""), Usage: "Endpoint for the agent", EnvVars: []string{"OCS_TRACING_ENDPOINT"}, Destination: &cfg.Tracing.Endpoint, }, &cli.StringFlag{ Name: "tracing-collector", - Value: "", + Value: flags.OverrideDefaultString(cfg.Tracing.Collector, ""), Usage: "Endpoint for the collector", EnvVars: []string{"OCS_TRACING_COLLECTOR"}, Destination: &cfg.Tracing.Collector, }, &cli.StringFlag{ Name: "tracing-service", - Value: "ocs", + Value: flags.OverrideDefaultString(cfg.Tracing.Service, "ocs"), Usage: "Service name for tracing", EnvVars: []string{"OCS_TRACING_SERVICE"}, Destination: &cfg.Tracing.Service, }, &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9114", + Value: flags.OverrideDefaultString(cfg.Debug.Addr, "0.0.0.0:9114"), Usage: "Address to bind debug server", EnvVars: []string{"OCS_DEBUG_ADDR"}, Destination: &cfg.Debug.Addr, }, &cli.StringFlag{ Name: "debug-token", - Value: "", + Value: flags.OverrideDefaultString(cfg.Debug.Token, ""), Usage: "Token to grant metrics access", EnvVars: []string{"OCS_DEBUG_TOKEN"}, Destination: &cfg.Debug.Token, @@ -109,28 +110,28 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "http-addr", - Value: "0.0.0.0:9110", + Value: flags.OverrideDefaultString(cfg.HTTP.Addr, "0.0.0.0:9110"), Usage: "Address to bind http server", EnvVars: []string{"OCS_HTTP_ADDR"}, Destination: &cfg.HTTP.Addr, }, &cli.StringFlag{ Name: "http-namespace", - Value: "com.owncloud.web", + Value: flags.OverrideDefaultString(cfg.Service.Namespace, "com.owncloud.web"), Usage: "Set the base namespace for the http namespace", EnvVars: []string{"OCS_NAMESPACE"}, Destination: &cfg.Service.Namespace, }, &cli.StringFlag{ Name: "name", - Value: "ocs", + Value: flags.OverrideDefaultString(cfg.Service.Name, "ocs"), Usage: "Service name", EnvVars: []string{"OCS_NAME"}, Destination: &cfg.Service.Name, }, &cli.StringFlag{ Name: "http-root", - Value: "/ocs", + Value: flags.OverrideDefaultString(cfg.HTTP.Root, "/ocs"), Usage: "Root path of http server", EnvVars: []string{"OCS_HTTP_ROOT"}, Destination: &cfg.HTTP.Root, @@ -138,7 +139,7 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "jwt-secret", - Value: "Pive-Fumkiu4", + Value: flags.OverrideDefaultString(cfg.TokenManager.JWTSecret, "Pive-Fumkiu4"), Usage: "Used to dismantle the access token, should equal reva's jwt-secret", EnvVars: []string{"OCS_JWT_SECRET", "OCIS_JWT_SECRET"}, Destination: &cfg.TokenManager.JWTSecret, @@ -151,14 +152,14 @@ func ListOcsWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "http-namespace", - Value: "com.owncloud.web", + Value: flags.OverrideDefaultString(cfg.Service.Namespace, "com.owncloud.web"), Usage: "Set the base namespace for the http namespace", EnvVars: []string{"OCS_NAMESPACE"}, Destination: &cfg.Service.Namespace, }, &cli.StringFlag{ Name: "name", - Value: "ocs", + Value: flags.OverrideDefaultString(cfg.Service.Name, "ocs"), Usage: "Service name", EnvVars: []string{"OCS_NAME"}, Destination: &cfg.Service.Name,