From 27b2fbe7e0b5131180bca7c1f2a8922374d6c52d Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Thu, 2 Jun 2022 09:55:56 +0200 Subject: [PATCH] fix configuration validation for extensions' server commands --- .../unreleased/fix-skip-validate-for-non-fullstack.md | 11 +++++++++++ ocis-pkg/config/parser/parse.go | 6 +++++- ocis/pkg/command/app-provider.go | 2 +- ocis/pkg/command/app-registry.go | 2 +- ocis/pkg/command/audit.go | 2 +- ocis/pkg/command/auth-basic.go | 2 +- ocis/pkg/command/auth-bearer.go | 2 +- ocis/pkg/command/auth-machine.go | 2 +- ocis/pkg/command/frontend.go | 2 +- ocis/pkg/command/gateway.go | 2 +- ocis/pkg/command/graph-explorer.go | 2 +- ocis/pkg/command/graph.go | 2 +- ocis/pkg/command/groups.go | 2 +- ocis/pkg/command/idm.go | 2 +- ocis/pkg/command/idp.go | 2 +- ocis/pkg/command/nats.go | 2 +- ocis/pkg/command/notifications.go | 2 +- ocis/pkg/command/ocdav.go | 2 +- ocis/pkg/command/ocs.go | 2 +- ocis/pkg/command/proxy.go | 2 +- ocis/pkg/command/search.go | 2 +- ocis/pkg/command/server.go | 2 +- ocis/pkg/command/settings.go | 2 +- ocis/pkg/command/sharing.go | 2 +- ocis/pkg/command/storage-publiclink.go | 2 +- ocis/pkg/command/storage-shares.go | 2 +- ocis/pkg/command/storage-system.go | 2 +- ocis/pkg/command/storage-users.go | 2 +- ocis/pkg/command/store.go | 2 +- ocis/pkg/command/thumbnails.go | 2 +- ocis/pkg/command/users.go | 2 +- ocis/pkg/command/web.go | 2 +- ocis/pkg/command/webdav.go | 2 +- 33 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 changelog/unreleased/fix-skip-validate-for-non-fullstack.md diff --git a/changelog/unreleased/fix-skip-validate-for-non-fullstack.md b/changelog/unreleased/fix-skip-validate-for-non-fullstack.md new file mode 100644 index 000000000..898f9e668 --- /dev/null +++ b/changelog/unreleased/fix-skip-validate-for-non-fullstack.md @@ -0,0 +1,11 @@ +Bugfix: Fix configuration validation for extensions' server commands + +We've fixed the configuration validation for the extensions' server commands. +Before that fix error messages have occurred when started services which don't need +certain configuration values, that are needed for the oCIS fullstack command. + +We now no longer do the common oCIS configuration validation for extensions' server +commands and now rely only on the extensions' validation function. + + +https://github.com/owncloud/ocis/pull/3911 diff --git a/ocis-pkg/config/parser/parse.go b/ocis-pkg/config/parser/parse.go index e10ca0b6c..0354b222b 100644 --- a/ocis-pkg/config/parser/parse.go +++ b/ocis-pkg/config/parser/parse.go @@ -11,7 +11,7 @@ import ( // ParseConfig loads the ocis configuration and // copies applicable parts into the commons part, from // where the extensions can copy it into their own config -func ParseConfig(cfg *config.Config) error { +func ParseConfig(cfg *config.Config, skipValidate bool) error { _, err := config.BindSourcesToStructs("ocis", cfg) if err != nil { return err @@ -29,6 +29,10 @@ func ParseConfig(cfg *config.Config) error { EnsureCommons(cfg) + if skipValidate { + return nil + } + return Validate(cfg) } diff --git a/ocis/pkg/command/app-provider.go b/ocis/pkg/command/app-provider.go index 38716eb7d..0ebd02724 100644 --- a/ocis/pkg/command/app-provider.go +++ b/ocis/pkg/command/app-provider.go @@ -18,7 +18,7 @@ func AppProviderCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AppProvider.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.AppProvider.Commons = cfg.Commons diff --git a/ocis/pkg/command/app-registry.go b/ocis/pkg/command/app-registry.go index c366edf83..a859f0352 100644 --- a/ocis/pkg/command/app-registry.go +++ b/ocis/pkg/command/app-registry.go @@ -18,7 +18,7 @@ func AppRegistryCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AppRegistry.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.AppRegistry.Commons = cfg.Commons diff --git a/ocis/pkg/command/audit.go b/ocis/pkg/command/audit.go index 0ad70292e..3978adf51 100644 --- a/ocis/pkg/command/audit.go +++ b/ocis/pkg/command/audit.go @@ -18,7 +18,7 @@ func AuditCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Audit.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Audit.Commons = cfg.Commons diff --git a/ocis/pkg/command/auth-basic.go b/ocis/pkg/command/auth-basic.go index ae36c5cdc..1a61993d3 100644 --- a/ocis/pkg/command/auth-basic.go +++ b/ocis/pkg/command/auth-basic.go @@ -18,7 +18,7 @@ func AuthBasicCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AuthBasic.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.AuthBasic.Commons = cfg.Commons diff --git a/ocis/pkg/command/auth-bearer.go b/ocis/pkg/command/auth-bearer.go index 7681feb74..d30be5f6d 100644 --- a/ocis/pkg/command/auth-bearer.go +++ b/ocis/pkg/command/auth-bearer.go @@ -18,7 +18,7 @@ func AuthBearerCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AuthBearer.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.AuthBearer.Commons = cfg.Commons diff --git a/ocis/pkg/command/auth-machine.go b/ocis/pkg/command/auth-machine.go index 3d8b820b4..485e7ddd0 100644 --- a/ocis/pkg/command/auth-machine.go +++ b/ocis/pkg/command/auth-machine.go @@ -18,7 +18,7 @@ func AuthMachineCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AuthMachine.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.AuthMachine.Commons = cfg.Commons diff --git a/ocis/pkg/command/frontend.go b/ocis/pkg/command/frontend.go index a452acfdb..cd31c90bb 100644 --- a/ocis/pkg/command/frontend.go +++ b/ocis/pkg/command/frontend.go @@ -18,7 +18,7 @@ func FrontendCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Frontend.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Frontend.Commons = cfg.Commons diff --git a/ocis/pkg/command/gateway.go b/ocis/pkg/command/gateway.go index b8ef9d66b..2e7e8b08d 100644 --- a/ocis/pkg/command/gateway.go +++ b/ocis/pkg/command/gateway.go @@ -18,7 +18,7 @@ func GatewayCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Gateway.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Gateway.Commons = cfg.Commons diff --git a/ocis/pkg/command/graph-explorer.go b/ocis/pkg/command/graph-explorer.go index ded382c6a..0f7a8f2cf 100644 --- a/ocis/pkg/command/graph-explorer.go +++ b/ocis/pkg/command/graph-explorer.go @@ -18,7 +18,7 @@ func GraphExplorerCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.GraphExplorer.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.GraphExplorer.Commons = cfg.Commons diff --git a/ocis/pkg/command/graph.go b/ocis/pkg/command/graph.go index 6e9230039..fd604075c 100644 --- a/ocis/pkg/command/graph.go +++ b/ocis/pkg/command/graph.go @@ -18,7 +18,7 @@ func GraphCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Graph.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Graph.Commons = cfg.Commons diff --git a/ocis/pkg/command/groups.go b/ocis/pkg/command/groups.go index 4be4fe6c9..efce3edcf 100644 --- a/ocis/pkg/command/groups.go +++ b/ocis/pkg/command/groups.go @@ -18,7 +18,7 @@ func GroupsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Groups.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Groups.Commons = cfg.Commons diff --git a/ocis/pkg/command/idm.go b/ocis/pkg/command/idm.go index d5cec2a23..70d116f41 100644 --- a/ocis/pkg/command/idm.go +++ b/ocis/pkg/command/idm.go @@ -18,7 +18,7 @@ func IDMCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.IDM.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.IDM.Commons = cfg.Commons diff --git a/ocis/pkg/command/idp.go b/ocis/pkg/command/idp.go index e81f3f899..71923b108 100644 --- a/ocis/pkg/command/idp.go +++ b/ocis/pkg/command/idp.go @@ -18,7 +18,7 @@ func IDPCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.IDP.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.IDP.Commons = cfg.Commons diff --git a/ocis/pkg/command/nats.go b/ocis/pkg/command/nats.go index 0fec2f10a..31575f5e0 100644 --- a/ocis/pkg/command/nats.go +++ b/ocis/pkg/command/nats.go @@ -18,7 +18,7 @@ func NatsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Nats.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Nats.Commons = cfg.Commons diff --git a/ocis/pkg/command/notifications.go b/ocis/pkg/command/notifications.go index de65b4a89..a5580bde5 100644 --- a/ocis/pkg/command/notifications.go +++ b/ocis/pkg/command/notifications.go @@ -18,7 +18,7 @@ func NotificationsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Notifications.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Notifications.Commons = cfg.Commons diff --git a/ocis/pkg/command/ocdav.go b/ocis/pkg/command/ocdav.go index 1c5573152..57f5e7314 100644 --- a/ocis/pkg/command/ocdav.go +++ b/ocis/pkg/command/ocdav.go @@ -18,7 +18,7 @@ func OCDavCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.OCDav.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.OCDav.Commons = cfg.Commons diff --git a/ocis/pkg/command/ocs.go b/ocis/pkg/command/ocs.go index ca1bfd40d..8b5065a4f 100644 --- a/ocis/pkg/command/ocs.go +++ b/ocis/pkg/command/ocs.go @@ -18,7 +18,7 @@ func OCSCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.OCS.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.OCS.Commons = cfg.Commons diff --git a/ocis/pkg/command/proxy.go b/ocis/pkg/command/proxy.go index 9b43562d8..51eb65b2a 100644 --- a/ocis/pkg/command/proxy.go +++ b/ocis/pkg/command/proxy.go @@ -18,7 +18,7 @@ func ProxyCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Proxy.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Proxy.Commons = cfg.Commons diff --git a/ocis/pkg/command/search.go b/ocis/pkg/command/search.go index 0998b8cf3..f19e6a607 100644 --- a/ocis/pkg/command/search.go +++ b/ocis/pkg/command/search.go @@ -18,7 +18,7 @@ func SearchCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Search.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Search.Commons = cfg.Commons diff --git a/ocis/pkg/command/server.go b/ocis/pkg/command/server.go index d54834983..2ca639900 100644 --- a/ocis/pkg/command/server.go +++ b/ocis/pkg/command/server.go @@ -17,7 +17,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: "start a fullstack server (runtime and all extensions in supervised mode)", Category: "fullstack", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, false); err != nil { fmt.Printf("%v", err) return err } diff --git a/ocis/pkg/command/settings.go b/ocis/pkg/command/settings.go index 9b732823d..4c6257f5d 100644 --- a/ocis/pkg/command/settings.go +++ b/ocis/pkg/command/settings.go @@ -18,7 +18,7 @@ func SettingsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Settings.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Settings.Commons = cfg.Commons diff --git a/ocis/pkg/command/sharing.go b/ocis/pkg/command/sharing.go index 84ece22a2..a3feca244 100644 --- a/ocis/pkg/command/sharing.go +++ b/ocis/pkg/command/sharing.go @@ -18,7 +18,7 @@ func SharingCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Sharing.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Sharing.Commons = cfg.Commons diff --git a/ocis/pkg/command/storage-publiclink.go b/ocis/pkg/command/storage-publiclink.go index e858d2935..a120d71e6 100644 --- a/ocis/pkg/command/storage-publiclink.go +++ b/ocis/pkg/command/storage-publiclink.go @@ -18,7 +18,7 @@ func StoragePublicLinkCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.StoragePublicLink.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.StoragePublicLink.Commons = cfg.Commons diff --git a/ocis/pkg/command/storage-shares.go b/ocis/pkg/command/storage-shares.go index 955284098..8c066096b 100644 --- a/ocis/pkg/command/storage-shares.go +++ b/ocis/pkg/command/storage-shares.go @@ -18,7 +18,7 @@ func StorageSharesCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.StorageShares.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.StorageShares.Commons = cfg.Commons diff --git a/ocis/pkg/command/storage-system.go b/ocis/pkg/command/storage-system.go index 639f68e51..72d61cf0f 100644 --- a/ocis/pkg/command/storage-system.go +++ b/ocis/pkg/command/storage-system.go @@ -18,7 +18,7 @@ func StorageSystemCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.StorageSystem.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.StorageSystem.Commons = cfg.Commons diff --git a/ocis/pkg/command/storage-users.go b/ocis/pkg/command/storage-users.go index 79ab201e7..44a148612 100644 --- a/ocis/pkg/command/storage-users.go +++ b/ocis/pkg/command/storage-users.go @@ -18,7 +18,7 @@ func StorageUsersCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.StorageUsers.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.StorageUsers.Commons = cfg.Commons diff --git a/ocis/pkg/command/store.go b/ocis/pkg/command/store.go index f0ca9e55c..addde0baf 100644 --- a/ocis/pkg/command/store.go +++ b/ocis/pkg/command/store.go @@ -19,7 +19,7 @@ func StoreCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Store.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Store.Commons = cfg.Commons diff --git a/ocis/pkg/command/thumbnails.go b/ocis/pkg/command/thumbnails.go index 3c7a288f9..82ec98f28 100644 --- a/ocis/pkg/command/thumbnails.go +++ b/ocis/pkg/command/thumbnails.go @@ -18,7 +18,7 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Thumbnails.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Thumbnails.Commons = cfg.Commons diff --git a/ocis/pkg/command/users.go b/ocis/pkg/command/users.go index fd93235c7..f1cce21b6 100644 --- a/ocis/pkg/command/users.go +++ b/ocis/pkg/command/users.go @@ -18,7 +18,7 @@ func UsersCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Users.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Users.Commons = cfg.Commons diff --git a/ocis/pkg/command/web.go b/ocis/pkg/command/web.go index 35c2d9dd3..1255b71c7 100644 --- a/ocis/pkg/command/web.go +++ b/ocis/pkg/command/web.go @@ -18,7 +18,7 @@ func WebCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Web.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.Web.Commons = cfg.Commons diff --git a/ocis/pkg/command/webdav.go b/ocis/pkg/command/webdav.go index a8919b23b..d747f567b 100644 --- a/ocis/pkg/command/webdav.go +++ b/ocis/pkg/command/webdav.go @@ -19,7 +19,7 @@ func WebDAVCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.WebDAV.Service.Name), Category: "extensions", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { + if err := parser.ParseConfig(cfg, true); err != nil { fmt.Printf("%v", err) } cfg.WebDAV.Commons = cfg.Commons