diff --git a/glauth/pkg/command/health.go b/glauth/pkg/command/health.go index 3deb2db70..1ee1362ec 100644 --- a/glauth/pkg/command/health.go +++ b/glauth/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/glauth/pkg/config" - "github.com/owncloud/ocis/glauth/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/glauth/pkg/flagset/flagset.go b/glauth/pkg/flagset/flagset.go deleted file mode 100644 index 447381384..000000000 --- a/glauth/pkg/flagset/flagset.go +++ /dev/null @@ -1,20 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/glauth/pkg/config" - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/urfave/cli/v2" -) - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9129"), - Usage: "Address to debug endpoint", - EnvVars: []string{"GLAUTH_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} diff --git a/graph-explorer/pkg/command/health.go b/graph-explorer/pkg/command/health.go index 2fc86dcc0..60f4cc925 100644 --- a/graph-explorer/pkg/command/health.go +++ b/graph-explorer/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/graph-explorer/pkg/config" - "github.com/owncloud/ocis/graph-explorer/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/graph-explorer/pkg/flagset/flagset.go b/graph-explorer/pkg/flagset/flagset.go deleted file mode 100644 index ef4c46e86..000000000 --- a/graph-explorer/pkg/flagset/flagset.go +++ /dev/null @@ -1,20 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/graph-explorer/pkg/config" - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/urfave/cli/v2" -) - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9136"), - Usage: "Address to debug endpoint", - EnvVars: []string{"GRAPH_EXPLORER_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} diff --git a/graph/pkg/command/health.go b/graph/pkg/command/health.go index 8fd0bef9c..509146e3f 100644 --- a/graph/pkg/command/health.go +++ b/graph/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/graph/pkg/config" - "github.com/owncloud/ocis/graph/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/graph/pkg/flagset/flagset.go b/graph/pkg/flagset/flagset.go deleted file mode 100644 index d660716e7..000000000 --- a/graph/pkg/flagset/flagset.go +++ /dev/null @@ -1,20 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/graph/pkg/config" - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/urfave/cli/v2" -) - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9124"), - Usage: "Address to debug endpoint", - EnvVars: []string{"GRAPH_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} diff --git a/idp/pkg/command/health.go b/idp/pkg/command/health.go index 7e03cabc7..813470bd4 100644 --- a/idp/pkg/command/health.go +++ b/idp/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/idp/pkg/config" - "github.com/owncloud/ocis/idp/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/idp/pkg/command/server.go b/idp/pkg/command/server.go index cc33fe911..c9f943ebc 100644 --- a/idp/pkg/command/server.go +++ b/idp/pkg/command/server.go @@ -20,26 +20,14 @@ func Server(cfg *config.Config) *cli.Command { Name: "server", Usage: "Start integrated server", Before: func(ctx *cli.Context) error { - if cfg.HTTP.Root != "/" { - cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/") - } - - //if len(ctx.StringSlice("trusted-proxy")) > 0 { - // cfg.IDP.TrustedProxy = ctx.StringSlice("trusted-proxy") - //} - // - //if len(ctx.StringSlice("allow-scope")) > 0 { - // cfg.IDP.AllowScope = ctx.StringSlice("allow-scope") - //} - // - //if len(ctx.StringSlice("signing-private-key")) > 0 { - // cfg.IDP.SigningPrivateKeyFiles = ctx.StringSlice("signing-private-key") - //} - if err := ParseConfig(ctx, cfg); err != nil { return err } + if cfg.HTTP.Root != "/" { + cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/") + } + return nil }, Action: func(c *cli.Context) error { diff --git a/idp/pkg/command/version.go b/idp/pkg/command/version.go index 5f43da132..7408d59f6 100644 --- a/idp/pkg/command/version.go +++ b/idp/pkg/command/version.go @@ -8,7 +8,6 @@ import ( tw "github.com/olekukonko/tablewriter" "github.com/owncloud/ocis/idp/pkg/config" - "github.com/owncloud/ocis/idp/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -17,7 +16,9 @@ func PrintVersion(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "version", Usage: "Print the versions of the running instances", - Flags: flagset.ListIDPWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { reg := registry.GetRegistry() services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name) diff --git a/idp/pkg/flagset/flagset.go b/idp/pkg/flagset/flagset.go deleted file mode 100644 index 5cbcde701..000000000 --- a/idp/pkg/flagset/flagset.go +++ /dev/null @@ -1,39 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/idp/pkg/config" - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/urfave/cli/v2" -) - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9134"), - Usage: "Address to debug endpoint", - EnvVars: []string{"IDP_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} - -// ListIDPWithConfig applies the config to the list commands flags -func ListIDPWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{&cli.StringFlag{ - Name: "http-namespace", - Value: flags.OverrideDefaultString(cfg.Service.Namespace, "com.owncloud.web"), - Usage: "Set the base namespace for service discovery", - EnvVars: []string{"IDP_HTTP_NAMESPACE"}, - Destination: &cfg.Service.Namespace, - }, - &cli.StringFlag{ - Name: "name", - Value: flags.OverrideDefaultString(cfg.Service.Name, "idp"), - Usage: "Service name", - EnvVars: []string{"IDP_NAME"}, - Destination: &cfg.Service.Name, - }, - } -} diff --git a/ocs/pkg/command/health.go b/ocs/pkg/command/health.go index c84b6d244..51474a3da 100644 --- a/ocs/pkg/command/health.go +++ b/ocs/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/ocs/pkg/config" - "github.com/owncloud/ocis/ocs/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/ocs/pkg/command/version.go b/ocs/pkg/command/version.go index 10c1c17df..2c1b64e0e 100644 --- a/ocs/pkg/command/version.go +++ b/ocs/pkg/command/version.go @@ -8,7 +8,6 @@ import ( tw "github.com/olekukonko/tablewriter" "github.com/owncloud/ocis/ocs/pkg/config" - "github.com/owncloud/ocis/ocs/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -17,7 +16,9 @@ func PrintVersion(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "version", Usage: "Print the versions of the running instances", - Flags: flagset.ListOcsWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { reg := registry.GetRegistry() services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name) diff --git a/ocs/pkg/flagset/flagset.go b/ocs/pkg/flagset/flagset.go deleted file mode 100644 index f210b31bc..000000000 --- a/ocs/pkg/flagset/flagset.go +++ /dev/null @@ -1,40 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/owncloud/ocis/ocs/pkg/config" - "github.com/urfave/cli/v2" -) - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9114"), - Usage: "Address to debug endpoint", - EnvVars: []string{"OCS_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} - -// ListOcsWithConfig applies the config to the list commands flagset. -func ListOcsWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "http-namespace", - 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: flags.OverrideDefaultString(cfg.Service.Name, "ocs"), - Usage: "Service name", - EnvVars: []string{"OCS_NAME"}, - Destination: &cfg.Service.Name, - }, - } -} diff --git a/proxy/pkg/command/version.go b/proxy/pkg/command/version.go index 273db559c..469abc6ef 100644 --- a/proxy/pkg/command/version.go +++ b/proxy/pkg/command/version.go @@ -8,7 +8,6 @@ import ( tw "github.com/olekukonko/tablewriter" "github.com/owncloud/ocis/proxy/pkg/config" - "github.com/owncloud/ocis/proxy/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -17,7 +16,9 @@ func PrintVersion(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "version", Usage: "Print the versions of the running instances", - Flags: flagset.ListProxyWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { reg := registry.GetRegistry() services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name) diff --git a/proxy/pkg/flagset/flagset.go b/proxy/pkg/flagset/flagset.go deleted file mode 100644 index 5b7118623..000000000 --- a/proxy/pkg/flagset/flagset.go +++ /dev/null @@ -1,27 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/owncloud/ocis/proxy/pkg/config" - "github.com/urfave/cli/v2" -) - -// ListProxyWithConfig applies the config to the list commands flags. -func ListProxyWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "service-namespace", - Value: flags.OverrideDefaultString(cfg.OIDC.Issuer, "com.owncloud.web"), - Usage: "Set the base namespace for the service namespace", - EnvVars: []string{"PROXY_SERVICE_NAMESPACE"}, - Destination: &cfg.Service.Namespace, - }, - &cli.StringFlag{ - Name: "service-name", - Value: flags.OverrideDefaultString(cfg.Service.Name, "proxy"), - Usage: "Service name", - EnvVars: []string{"PROXY_SERVICE_NAME"}, - Destination: &cfg.Service.Name, - }, - } -} diff --git a/settings/pkg/command/health.go b/settings/pkg/command/health.go index 72e9ea7f7..9b475f5e7 100644 --- a/settings/pkg/command/health.go +++ b/settings/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/settings/pkg/config" - "github.com/owncloud/ocis/settings/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/settings/pkg/command/version.go b/settings/pkg/command/version.go index fda866b62..55091cf81 100644 --- a/settings/pkg/command/version.go +++ b/settings/pkg/command/version.go @@ -8,7 +8,6 @@ import ( tw "github.com/olekukonko/tablewriter" "github.com/owncloud/ocis/settings/pkg/config" - "github.com/owncloud/ocis/settings/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -17,7 +16,9 @@ func PrintVersion(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "version", Usage: "Print the versions of the running instances", - Flags: flagset.ListSettingsWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { reg := registry.GetRegistry() services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name) diff --git a/settings/pkg/flagset/flagset.go b/settings/pkg/flagset/flagset.go deleted file mode 100644 index 73eb906a1..000000000 --- a/settings/pkg/flagset/flagset.go +++ /dev/null @@ -1,40 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/owncloud/ocis/settings/pkg/config" - "github.com/urfave/cli/v2" -) - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9194"), - Usage: "Address to debug endpoint", - EnvVars: []string{"SETTINGS_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} - -// ListSettingsWithConfig applies list command flags to cfg -func ListSettingsWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "grpc-namespace", - Value: flags.OverrideDefaultString(cfg.GRPC.Namespace, "com.owncloud.api"), - Usage: "Set the base namespace for the grpc namespace", - EnvVars: []string{"SETTINGS_GRPC_NAMESPACE"}, - Destination: &cfg.GRPC.Namespace, - }, - &cli.StringFlag{ - Name: "name", - Value: flags.OverrideDefaultString(cfg.Service.Name, "settings"), - Usage: "service name", - EnvVars: []string{"SETTINGS_NAME"}, - Destination: &cfg.Service.Name, - }, - } -} diff --git a/store/pkg/command/health.go b/store/pkg/command/health.go index 5768b00ec..38461c9ac 100644 --- a/store/pkg/command/health.go +++ b/store/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/store/pkg/config" - "github.com/owncloud/ocis/store/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/store/pkg/command/version.go b/store/pkg/command/version.go index 22b9997bb..b5bfef3b2 100644 --- a/store/pkg/command/version.go +++ b/store/pkg/command/version.go @@ -8,7 +8,6 @@ import ( tw "github.com/olekukonko/tablewriter" "github.com/owncloud/ocis/store/pkg/config" - "github.com/owncloud/ocis/store/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -17,7 +16,9 @@ func PrintVersion(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "version", Usage: "Print the versions of the running instances", - Flags: flagset.ListStoreWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { reg := registry.GetRegistry() services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name) diff --git a/store/pkg/flagset/flagset.go b/store/pkg/flagset/flagset.go deleted file mode 100644 index a2085be67..000000000 --- a/store/pkg/flagset/flagset.go +++ /dev/null @@ -1,39 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/owncloud/ocis/store/pkg/config" - "github.com/urfave/cli/v2" -) - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9464"), - Usage: "Address to debug endpoint", - EnvVars: []string{"STORE_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} - -// ListStoreWithConfig applies the config to the list commands flags. -func ListStoreWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{&cli.StringFlag{ - Name: "grpc-namespace", - Value: flags.OverrideDefaultString(cfg.Service.Namespace, "com.owncloud.api"), - Usage: "Set the base namespace for the grpc namespace", - EnvVars: []string{"STORE_GRPC_NAMESPACE"}, - Destination: &cfg.Service.Namespace, - }, - &cli.StringFlag{ - Name: "name", - Value: flags.OverrideDefaultString(cfg.Service.Name, "store"), - Usage: "Service name", - EnvVars: []string{"STORE_NAME"}, - Destination: &cfg.Service.Name, - }, - } -} diff --git a/thumbnails/pkg/command/health.go b/thumbnails/pkg/command/health.go index babd7d20a..6b5c84939 100644 --- a/thumbnails/pkg/command/health.go +++ b/thumbnails/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/thumbnails/pkg/config" - "github.com/owncloud/ocis/thumbnails/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/thumbnails/pkg/command/version.go b/thumbnails/pkg/command/version.go index 9a861db97..df3c0230f 100644 --- a/thumbnails/pkg/command/version.go +++ b/thumbnails/pkg/command/version.go @@ -8,7 +8,6 @@ import ( tw "github.com/olekukonko/tablewriter" "github.com/owncloud/ocis/thumbnails/pkg/config" - "github.com/owncloud/ocis/thumbnails/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -17,7 +16,9 @@ func PrintVersion(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "version", Usage: "Print the versions of the running instances", - Flags: flagset.ListThumbnailsWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { reg := registry.GetRegistry() services, err := reg.GetService(cfg.Server.Namespace + "." + cfg.Server.Name) diff --git a/thumbnails/pkg/flagset/flagset.go b/thumbnails/pkg/flagset/flagset.go deleted file mode 100644 index 0640c730b..000000000 --- a/thumbnails/pkg/flagset/flagset.go +++ /dev/null @@ -1,41 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/ocis-pkg/flags" - - "github.com/owncloud/ocis/thumbnails/pkg/config" - "github.com/urfave/cli/v2" -) - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9189"), - Usage: "Address to debug endpoint", - EnvVars: []string{"THUMBNAILS_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} - -// ListThumbnailsWithConfig applies the config to the flagset for listing thumbnails services. -func ListThumbnailsWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "grpc-name", - Value: flags.OverrideDefaultString(cfg.Server.Name, "thumbnails"), - Usage: "Name of the service", - EnvVars: []string{"THUMBNAILS_GRPC_NAME"}, - Destination: &cfg.Server.Name, - }, - &cli.StringFlag{ - Name: "grpc-namespace", - Value: flags.OverrideDefaultString(cfg.Server.Namespace, "com.owncloud.api"), - Usage: "Set the base namespace for the grpc namespace", - EnvVars: []string{"THUMBNAILS_GRPC_NAMESPACE"}, - Destination: &cfg.Server.Namespace, - }, - } -} diff --git a/web/pkg/command/health.go b/web/pkg/command/health.go index 4719442e3..97206879b 100644 --- a/web/pkg/command/health.go +++ b/web/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/web/pkg/config" - "github.com/owncloud/ocis/web/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/web/pkg/flagset/flagset.go b/web/pkg/flagset/flagset.go deleted file mode 100644 index c1aa3eae6..000000000 --- a/web/pkg/flagset/flagset.go +++ /dev/null @@ -1,44 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/owncloud/ocis/web/pkg/config" - "github.com/urfave/cli/v2" -) - -// RootWithConfig applies cfg to the root flagset -func RootWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "log-level", - Usage: "Set logging level", - EnvVars: []string{"OCIS_LOG_LEVEL", "WEB_LOG_LEVEL"}, - Destination: &cfg.Log.Level, - }, - &cli.BoolFlag{ - Name: "log-pretty", - Usage: "Enable pretty logging", - EnvVars: []string{"OCIS_LOG_PRETTY", "WEB_LOG_PRETTY"}, - Destination: &cfg.Log.Pretty, - }, - &cli.BoolFlag{ - Name: "log-color", - Usage: "Enable colored logging", - EnvVars: []string{"OCIS_LOG_COLOR", "WEB_LOG_COLOR"}, - Destination: &cfg.Log.Color, - }, - } -} - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9104"), - Usage: "Address to debug endpoint", - EnvVars: []string{"WEB_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} diff --git a/webdav/pkg/command/health.go b/webdav/pkg/command/health.go index 42aa7964c..58aca1e1d 100644 --- a/webdav/pkg/command/health.go +++ b/webdav/pkg/command/health.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/owncloud/ocis/webdav/pkg/config" - "github.com/owncloud/ocis/webdav/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -14,7 +13,9 @@ func Health(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "health", Usage: "Check health status", - Flags: flagset.HealthWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/webdav/pkg/command/version.go b/webdav/pkg/command/version.go index 03ef51278..813cc1c08 100644 --- a/webdav/pkg/command/version.go +++ b/webdav/pkg/command/version.go @@ -8,7 +8,6 @@ import ( tw "github.com/olekukonko/tablewriter" "github.com/owncloud/ocis/webdav/pkg/config" - "github.com/owncloud/ocis/webdav/pkg/flagset" "github.com/urfave/cli/v2" ) @@ -17,7 +16,9 @@ func PrintVersion(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "version", Usage: "Print the versions of the running instances", - Flags: flagset.ListWebdavWithConfig(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg) + }, Action: func(c *cli.Context) error { reg := registry.GetRegistry() services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name) diff --git a/webdav/pkg/flagset/flagset.go b/webdav/pkg/flagset/flagset.go deleted file mode 100644 index 87fc45824..000000000 --- a/webdav/pkg/flagset/flagset.go +++ /dev/null @@ -1,40 +0,0 @@ -package flagset - -import ( - "github.com/owncloud/ocis/ocis-pkg/flags" - "github.com/owncloud/ocis/webdav/pkg/config" - "github.com/urfave/cli/v2" -) - -// HealthWithConfig applies cfg to the root flagset -func HealthWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "debug-addr", - Value: flags.OverrideDefaultString(cfg.Debug.Addr, "127.0.0.1:9119"), - Usage: "Address to debug endpoint", - EnvVars: []string{"WEBDAV_DEBUG_ADDR"}, - Destination: &cfg.Debug.Addr, - }, - } -} - -// ListWebdavWithConfig applies the config to the list commands flagset. -func ListWebdavWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "http-namespace", - Value: flags.OverrideDefaultString(cfg.Service.Namespace, "com.owncloud.web"), - Usage: "Set the base namespace for service discovery", - EnvVars: []string{"WEBDAV_HTTP_NAMESPACE"}, - Destination: &cfg.Service.Namespace, - }, - &cli.StringFlag{ - Name: "service-name", - Value: flags.OverrideDefaultString(cfg.Service.Name, "webdav"), - Usage: "Service name", - EnvVars: []string{"WEBDAV_SERVICE_NAME"}, - Destination: &cfg.Service.Name, - }, - } -}