diff --git a/accounts/pkg/command/root.go b/accounts/pkg/command/root.go index a0d264fde..fb0bf2883 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 e94528702..7c8f3832e 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 4ba8e95be..7b1dc51d9 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 459d8a0eb..08f1879e0 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 cf997cc6f..f2acd3460 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 2318c610b..60c389880 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 8c9276cff..c246b23e4 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 9bb2df16e..787381c7e 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 d80728911..a5be7abcc 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 719b08062..672dcd6a3 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 23b45f9db..3e58bbeef 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 0e1d4e295..a482ef681 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 db65c6b1d..fa2eee4c3 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 8f996f493..d71e57438 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 eb29b3d25..657bc2969 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 423794d91..d52e667b4 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 e0c77c0f6..7fb3551af 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 0cf950c4c..2803c1398 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 71ecb35d9..a12412c95 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 171b78143..140b6a1c5 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 a95cc94ae..6ef8a2095 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 2b7ed2dea..fb171ad14 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 1d10a9847..cac620e67 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 a5081a3cf..4126133a1 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 3f904bda1..0d10d16ec 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 b2c82bf0a..cfc2afa62 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 8d8045ab9..9f992d6d7 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 938a3f26b..4e65d6391 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 0728ef292..9c08299f1 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 44451c48b..add49da6f 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 cf9a4ad20..77df9d87b 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 1cdb5c494..83b311196 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 4b7444c65..c47505705 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 2c22ed570..2dbe61c1b 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 fbacd1ccc..016246d1e 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 ed2207828..71870c8ce 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 45e256492..3a3a3432b 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 720729efb..10dd88abf 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)