diff --git a/accounts/pkg/command/root.go b/accounts/pkg/command/root.go index a0d264fde4..fb0bf28831 100644 --- a/accounts/pkg/command/root.go +++ b/accounts/pkg/command/root.go @@ -5,7 +5,6 @@ import ( "os" "github.com/owncloud/ocis/accounts/pkg/config" - "github.com/owncloud/ocis/accounts/pkg/config/parser" "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/thejerf/suture/v4" @@ -35,11 +34,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-accounts command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "ocis-accounts", - Usage: "Provide accounts and groups for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "ocis-accounts", + Usage: "Provide accounts and groups for oCIS", Commands: GetCommands(cfg), }) diff --git a/accounts/pkg/command/server.go b/accounts/pkg/command/server.go index e945287024..7c8f3832e4 100644 --- a/accounts/pkg/command/server.go +++ b/accounts/pkg/command/server.go @@ -23,12 +23,8 @@ func Server(cfg *config.Config) *cli.Command { Name: "server", Usage: "Start ocis accounts service", Description: "uses an LDAP server as the storage backend", - Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/glauth/pkg/command/root.go b/glauth/pkg/command/root.go index 4ba8e95be3..7b1dc51d9c 100644 --- a/glauth/pkg/command/root.go +++ b/glauth/pkg/command/root.go @@ -5,7 +5,6 @@ import ( "os" "github.com/owncloud/ocis/glauth/pkg/config" - "github.com/owncloud/ocis/glauth/pkg/config/parser" "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/thejerf/suture/v4" @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-glauth command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "ocis-glauth", - Usage: "Serve GLAuth API for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "ocis-glauth", + Usage: "Serve GLAuth API for oCIS", Commands: GetCommands(cfg), }) diff --git a/glauth/pkg/command/server.go b/glauth/pkg/command/server.go index 459d8a0eb5..08f1879e02 100644 --- a/glauth/pkg/command/server.go +++ b/glauth/pkg/command/server.go @@ -24,13 +24,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/graph-explorer/pkg/command/root.go b/graph-explorer/pkg/command/root.go index cf997cc6f0..f2acd3460a 100644 --- a/graph-explorer/pkg/command/root.go +++ b/graph-explorer/pkg/command/root.go @@ -5,7 +5,6 @@ import ( "os" "github.com/owncloud/ocis/graph-explorer/pkg/config" - "github.com/owncloud/ocis/graph-explorer/pkg/config/parser" "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/thejerf/suture/v4" @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the graph-explorer command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "graph-explorer", - Usage: "Serve Graph-Explorer for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "graph-explorer", + Usage: "Serve Graph-Explorer for oCIS", Commands: GetCommands(cfg), }) diff --git a/graph/pkg/command/root.go b/graph/pkg/command/root.go index 2318c610b7..60c389880d 100644 --- a/graph/pkg/command/root.go +++ b/graph/pkg/command/root.go @@ -4,7 +4,6 @@ import ( "context" "os" - "github.com/owncloud/ocis/graph/pkg/config/parser" "github.com/owncloud/ocis/ocis-pkg/clihelper" "github.com/thejerf/suture/v4" @@ -30,11 +29,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-graph command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "ocis-graph", - Usage: "Serve Graph API for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "ocis-graph", + Usage: "Serve Graph API for oCIS", Commands: GetCommands(cfg), }) cli.HelpFlag = &cli.BoolFlag{ diff --git a/graph/pkg/command/server.go b/graph/pkg/command/server.go index 8c9276cffb..c246b23e41 100644 --- a/graph/pkg/command/server.go +++ b/graph/pkg/command/server.go @@ -20,13 +20,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/idp/pkg/command/root.go b/idp/pkg/command/root.go index 9bb2df16e0..787381c7e8 100644 --- a/idp/pkg/command/root.go +++ b/idp/pkg/command/root.go @@ -5,7 +5,6 @@ import ( "os" "github.com/owncloud/ocis/idp/pkg/config" - "github.com/owncloud/ocis/idp/pkg/config/parser" "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/thejerf/suture/v4" @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-idp command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "ocis-idp", - Usage: "Serve IDP API for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "ocis-idp", + Usage: "Serve IDP API for oCIS", Commands: GetCommands(cfg), }) diff --git a/idp/pkg/command/server.go b/idp/pkg/command/server.go index d807289114..a5be7abcce 100644 --- a/idp/pkg/command/server.go +++ b/idp/pkg/command/server.go @@ -20,12 +20,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/ocis/pkg/command/accounts.go b/ocis/pkg/command/accounts.go index 719b08062c..672dcd6a32 100644 --- a/ocis/pkg/command/accounts.go +++ b/ocis/pkg/command/accounts.go @@ -15,15 +15,7 @@ func AccountsCommand(cfg *config.Config) *cli.Command { Usage: "Start accounts server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.Accounts.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.Accounts), } diff --git a/ocis/pkg/command/glauth.go b/ocis/pkg/command/glauth.go index 23b45f9dbf..3e58bbeefb 100644 --- a/ocis/pkg/command/glauth.go +++ b/ocis/pkg/command/glauth.go @@ -15,15 +15,7 @@ func GLAuthCommand(cfg *config.Config) *cli.Command { Usage: "Start glauth server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.GLAuth.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.GLAuth), } diff --git a/ocis/pkg/command/graph.go b/ocis/pkg/command/graph.go index 0e1d4e2955..a482ef6813 100644 --- a/ocis/pkg/command/graph.go +++ b/ocis/pkg/command/graph.go @@ -15,15 +15,7 @@ func GraphCommand(cfg *config.Config) *cli.Command { Usage: "Start graph server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.Accounts.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.Graph), } diff --git a/ocis/pkg/command/graphexplorer.go b/ocis/pkg/command/graphexplorer.go index db65c6b1d6..fa2eee4c3d 100644 --- a/ocis/pkg/command/graphexplorer.go +++ b/ocis/pkg/command/graphexplorer.go @@ -15,15 +15,7 @@ func GraphExplorerCommand(cfg *config.Config) *cli.Command { Usage: "Start graph-explorer server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.GraphExplorer.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.GraphExplorer), } diff --git a/ocis/pkg/command/idp.go b/ocis/pkg/command/idp.go index 8f996f493e..d71e574383 100644 --- a/ocis/pkg/command/idp.go +++ b/ocis/pkg/command/idp.go @@ -15,15 +15,7 @@ func IDPCommand(cfg *config.Config) *cli.Command { Usage: "Start idp server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.IDP.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.IDP), } diff --git a/ocis/pkg/command/ocs.go b/ocis/pkg/command/ocs.go index eb29b3d25f..657bc2969d 100644 --- a/ocis/pkg/command/ocs.go +++ b/ocis/pkg/command/ocs.go @@ -15,15 +15,7 @@ func OCSCommand(cfg *config.Config) *cli.Command { Usage: "Start ocs server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.OCS.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.OCS), } diff --git a/ocis/pkg/command/proxy.go b/ocis/pkg/command/proxy.go index 423794d91a..d52e667b4e 100644 --- a/ocis/pkg/command/proxy.go +++ b/ocis/pkg/command/proxy.go @@ -15,15 +15,7 @@ func ProxyCommand(cfg *config.Config) *cli.Command { Usage: "Start proxy server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.Proxy.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.Proxy), } diff --git a/ocis/pkg/command/root.go b/ocis/pkg/command/root.go index e0c77c0f69..7fb3551afd 100644 --- a/ocis/pkg/command/root.go +++ b/ocis/pkg/command/root.go @@ -5,7 +5,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/clihelper" "github.com/owncloud/ocis/ocis-pkg/config" - "github.com/owncloud/ocis/ocis-pkg/config/parser" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/urfave/cli/v2" ) @@ -17,9 +16,6 @@ func Execute() error { app := clihelper.DefaultApp(&cli.App{ Name: "ocis", Usage: "ownCloud Infinite Scale Stack", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, }) for _, fn := range register.Commands { diff --git a/ocis/pkg/command/settings.go b/ocis/pkg/command/settings.go index 0cf950c4cb..2803c13983 100644 --- a/ocis/pkg/command/settings.go +++ b/ocis/pkg/command/settings.go @@ -15,15 +15,7 @@ func SettingsCommand(cfg *config.Config) *cli.Command { Usage: "Start settings server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.Settings.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.Settings), } diff --git a/ocis/pkg/command/store.go b/ocis/pkg/command/store.go index 71ecb35d94..a12412c95f 100644 --- a/ocis/pkg/command/store.go +++ b/ocis/pkg/command/store.go @@ -16,15 +16,7 @@ func StoreCommand(cfg *config.Config) *cli.Command { Usage: "Start a go-micro store", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.Store.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.Store), } diff --git a/ocis/pkg/command/thumbnails.go b/ocis/pkg/command/thumbnails.go index 171b781431..140b6a1c57 100644 --- a/ocis/pkg/command/thumbnails.go +++ b/ocis/pkg/command/thumbnails.go @@ -15,15 +15,7 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command { Usage: "Start thumbnails server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.Thumbnails.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { origCmd := command.Server(cfg.Thumbnails) diff --git a/ocis/pkg/command/web.go b/ocis/pkg/command/web.go index a95cc94aec..6ef8a2095f 100644 --- a/ocis/pkg/command/web.go +++ b/ocis/pkg/command/web.go @@ -15,15 +15,7 @@ func WebCommand(cfg *config.Config) *cli.Command { Usage: "Start web server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.Web.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.Web), } diff --git a/ocis/pkg/command/webdav.go b/ocis/pkg/command/webdav.go index 2b7ed2dea4..fb171ad145 100644 --- a/ocis/pkg/command/webdav.go +++ b/ocis/pkg/command/webdav.go @@ -16,15 +16,7 @@ func WebDAVCommand(cfg *config.Config) *cli.Command { Usage: "Start webdav server", Category: "Extensions", Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Commons != nil { - cfg.WebDAV.Commons = cfg.Commons - } - - return nil + return parser.ParseConfig(cfg) }, Subcommands: command.GetCommands(cfg.WebDAV), } diff --git a/ocs/pkg/command/root.go b/ocs/pkg/command/root.go index 1d10a9847f..cac620e67a 100644 --- a/ocs/pkg/command/root.go +++ b/ocs/pkg/command/root.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocs/pkg/config" - "github.com/owncloud/ocis/ocs/pkg/config/parser" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-ocs command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "ocis-ocs", - Usage: "Serve OCS API for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "ocis-ocs", + Usage: "Serve OCS API for oCIS", Commands: GetCommands(cfg), }) diff --git a/ocs/pkg/command/server.go b/ocs/pkg/command/server.go index a5081a3cfb..4126133a11 100644 --- a/ocs/pkg/command/server.go +++ b/ocs/pkg/command/server.go @@ -21,12 +21,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/proxy/pkg/command/health.go b/proxy/pkg/command/health.go index 3f904bda1b..0d10d16ece 100644 --- a/proxy/pkg/command/health.go +++ b/proxy/pkg/command/health.go @@ -5,6 +5,7 @@ import ( "net/http" "github.com/owncloud/ocis/proxy/pkg/config" + "github.com/owncloud/ocis/proxy/pkg/config/parser" "github.com/owncloud/ocis/proxy/pkg/logging" "github.com/urfave/cli/v2" ) @@ -14,7 +15,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 parser.ParseConfig(cfg) + }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/proxy/pkg/command/root.go b/proxy/pkg/command/root.go index b2c82bf0a7..cfc2afa629 100644 --- a/proxy/pkg/command/root.go +++ b/proxy/pkg/command/root.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/proxy/pkg/config" - "github.com/owncloud/ocis/proxy/pkg/config/parser" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-proxy command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "ocis-proxy", - Usage: "proxy for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "ocis-proxy", + Usage: "proxy for oCIS", Commands: GetCommands(cfg), }) diff --git a/proxy/pkg/command/server.go b/proxy/pkg/command/server.go index 8d8045ab90..9f992d6d7d 100644 --- a/proxy/pkg/command/server.go +++ b/proxy/pkg/command/server.go @@ -38,11 +38,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/settings/pkg/command/root.go b/settings/pkg/command/root.go index 938a3f26be..4e65d6391c 100644 --- a/settings/pkg/command/root.go +++ b/settings/pkg/command/root.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/settings/pkg/config" - "github.com/owncloud/ocis/settings/pkg/config/parser" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-settings command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "ocis-settings", - Usage: "Provide settings and permissions for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "ocis-settings", + Usage: "Provide settings and permissions for oCIS", Commands: GetCommands(cfg), }) diff --git a/settings/pkg/command/server.go b/settings/pkg/command/server.go index 0728ef2921..9c08299f1e 100644 --- a/settings/pkg/command/server.go +++ b/settings/pkg/command/server.go @@ -21,12 +21,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/store/pkg/command/root.go b/store/pkg/command/root.go index 44451c48be..add49da6f1 100644 --- a/store/pkg/command/root.go +++ b/store/pkg/command/root.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/store/pkg/config" - "github.com/owncloud/ocis/store/pkg/config/parser" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-store command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "ocis-store", - Usage: "Service to store values for ocis extensions", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "ocis-store", + Usage: "Service to store values for ocis extensions", Commands: GetCommands(cfg), }) diff --git a/store/pkg/command/server.go b/store/pkg/command/server.go index cf9a4ad20b..77df9d87bb 100644 --- a/store/pkg/command/server.go +++ b/store/pkg/command/server.go @@ -21,12 +21,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/thumbnails/pkg/command/root.go b/thumbnails/pkg/command/root.go index 1cdb5c4944..83b3111967 100644 --- a/thumbnails/pkg/command/root.go +++ b/thumbnails/pkg/command/root.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/thumbnails/pkg/config" - "github.com/owncloud/ocis/thumbnails/pkg/config/parser" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-thumbnails command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "ocis-thumbnails", - Usage: "Example usage", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "ocis-thumbnails", + Usage: "Example usage", Commands: GetCommands(cfg), }) diff --git a/thumbnails/pkg/command/server.go b/thumbnails/pkg/command/server.go index 4b7444c655..c475057053 100644 --- a/thumbnails/pkg/command/server.go +++ b/thumbnails/pkg/command/server.go @@ -21,11 +21,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/web/pkg/command/root.go b/web/pkg/command/root.go index 2c22ed570d..2dbe61c1b3 100644 --- a/web/pkg/command/root.go +++ b/web/pkg/command/root.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/web/pkg/config" - "github.com/owncloud/ocis/web/pkg/config/parser" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the web command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "web", - Usage: "Serve ownCloud Web for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "web", + Usage: "Serve ownCloud Web for oCIS", Commands: GetCommands(cfg), }) diff --git a/web/pkg/command/server.go b/web/pkg/command/server.go index fbacd1cccb..016246d1e8 100644 --- a/web/pkg/command/server.go +++ b/web/pkg/command/server.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "io/ioutil" - "strings" "github.com/oklog/run" "github.com/owncloud/ocis/web/pkg/config" @@ -22,21 +21,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - if cfg.HTTP.Root != "/" { - cfg.HTTP.Root = strings.TrimRight(cfg.HTTP.Root, "/") - } - - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - // build well known openid-configuration endpoint if it is not set - if cfg.Web.Config.OpenIDConnect.MetadataURL == "" { - cfg.Web.Config.OpenIDConnect.MetadataURL = strings.TrimRight(cfg.Web.Config.OpenIDConnect.Authority, "/") + "/.well-known/openid-configuration" - } - - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/web/pkg/config/parser/parse.go b/web/pkg/config/parser/parse.go index ed22078282..71870c8ce6 100644 --- a/web/pkg/config/parser/parse.go +++ b/web/pkg/config/parser/parse.go @@ -2,6 +2,7 @@ package parser import ( "errors" + "strings" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/web/pkg/config" @@ -37,6 +38,13 @@ func ParseConfig(cfg *config.Config) error { } // sanitize config + if cfg.HTTP.Root != "/" { + cfg.HTTP.Root = strings.TrimRight(cfg.HTTP.Root, "/") + } + // build well known openid-configuration endpoint if it is not set + if cfg.Web.Config.OpenIDConnect.MetadataURL == "" { + cfg.Web.Config.OpenIDConnect.MetadataURL = strings.TrimRight(cfg.Web.Config.OpenIDConnect.Authority, "/") + "/.well-known/openid-configuration" + } return nil } diff --git a/webdav/pkg/command/root.go b/webdav/pkg/command/root.go index 45e2564921..3a3a3432bd 100644 --- a/webdav/pkg/command/root.go +++ b/webdav/pkg/command/root.go @@ -7,7 +7,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/clihelper" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/webdav/pkg/config" - "github.com/owncloud/ocis/webdav/pkg/config/parser" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -29,11 +28,8 @@ func GetCommands(cfg *config.Config) cli.Commands { // Execute is the entry point for the ocis-webdav command. func Execute(cfg *config.Config) error { app := clihelper.DefaultApp(&cli.App{ - Name: "webdav", - Usage: "Serve WebDAV API for oCIS", - Before: func(c *cli.Context) error { - return parser.ParseConfig(cfg) - }, + Name: "webdav", + Usage: "Serve WebDAV API for oCIS", Commands: GetCommands(cfg), }) diff --git a/webdav/pkg/command/server.go b/webdav/pkg/command/server.go index 720729efbc..10dd88abf8 100644 --- a/webdav/pkg/command/server.go +++ b/webdav/pkg/command/server.go @@ -20,13 +20,8 @@ func Server(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "server", Usage: "Start integrated server", - Before: func(ctx *cli.Context) error { - - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - return nil + Before: func(c *cli.Context) error { + return parser.ParseConfig(cfg) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log)