diff --git a/changelog/unreleased/bugfix-help-config-newline.md b/changelog/unreleased/bugfix-help-config-newline.md new file mode 100644 index 000000000..1470de3e5 --- /dev/null +++ b/changelog/unreleased/bugfix-help-config-newline.md @@ -0,0 +1,6 @@ +Bugfix: Show help for some commands when unconfigured + +We've fixed some commands to show the help also when oCIS is not yet configured. +Previously the help was not displayed to the user but instead a configuration validation error. + +https://github.com/owncloud/ocis/pull/4405 diff --git a/ocis-pkg/config/configlog/log.go b/ocis-pkg/config/configlog/log.go new file mode 100644 index 000000000..c5ff40d04 --- /dev/null +++ b/ocis-pkg/config/configlog/log.go @@ -0,0 +1,30 @@ +package configlog + +import ( + "fmt" + "os" +) + +// LogError logs the error +func LogError(err error) { + if err != nil { + fmt.Printf("%v\n", err) + } +} + +// LogError logs the error and returns it unchanged +func LogReturnError(err error) error { + if err != nil { + fmt.Printf("%v\n", err) + } + return err +} + +// LogReturnFatal logs the error and calls os.Exit(1) and returns nil if no error is passed +func LogReturnFatal(err error) error { + if err != nil { + fmt.Printf("%v\n", err) + os.Exit(1) + } + return nil +} diff --git a/ocis/pkg/command/app-provider.go b/ocis/pkg/command/app-provider.go index 89120bd57..74cdbecd4 100644 --- a/ocis/pkg/command/app-provider.go +++ b/ocis/pkg/command/app-provider.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func AppProviderCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AppProvider.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.AppProvider.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/app-registry.go b/ocis/pkg/command/app-registry.go index b16df293a..d39e08201 100644 --- a/ocis/pkg/command/app-registry.go +++ b/ocis/pkg/command/app-registry.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func AppRegistryCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AppRegistry.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.AppRegistry.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/audit.go b/ocis/pkg/command/audit.go index 58b4d4e0a..ffc8b335e 100644 --- a/ocis/pkg/command/audit.go +++ b/ocis/pkg/command/audit.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func AuditCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Audit.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Audit.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/auth-basic.go b/ocis/pkg/command/auth-basic.go index 3a850faa6..8503851d3 100644 --- a/ocis/pkg/command/auth-basic.go +++ b/ocis/pkg/command/auth-basic.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func AuthBasicCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AuthBasic.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.AuthBasic.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/auth-bearer.go b/ocis/pkg/command/auth-bearer.go index be1e36050..213146f21 100644 --- a/ocis/pkg/command/auth-bearer.go +++ b/ocis/pkg/command/auth-bearer.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func AuthBearerCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AuthBearer.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.AuthBearer.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/auth-machine.go b/ocis/pkg/command/auth-machine.go index 336823efa..4561203c0 100644 --- a/ocis/pkg/command/auth-machine.go +++ b/ocis/pkg/command/auth-machine.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func AuthMachineCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.AuthMachine.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.AuthMachine.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/frontend.go b/ocis/pkg/command/frontend.go index 741e96cdc..0ca6a4c6b 100644 --- a/ocis/pkg/command/frontend.go +++ b/ocis/pkg/command/frontend.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func FrontendCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Frontend.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Frontend.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/gateway.go b/ocis/pkg/command/gateway.go index b771d3c9e..1107587c3 100644 --- a/ocis/pkg/command/gateway.go +++ b/ocis/pkg/command/gateway.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func GatewayCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Gateway.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Gateway.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/graph-explorer.go b/ocis/pkg/command/graph-explorer.go index 4c54deec1..4d295fd82 100644 --- a/ocis/pkg/command/graph-explorer.go +++ b/ocis/pkg/command/graph-explorer.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func GraphExplorerCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.GraphExplorer.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.GraphExplorer.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/graph.go b/ocis/pkg/command/graph.go index ce0acc33e..6efc8179d 100644 --- a/ocis/pkg/command/graph.go +++ b/ocis/pkg/command/graph.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func GraphCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Graph.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Graph.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/groups.go b/ocis/pkg/command/groups.go index 503943489..edaffd982 100644 --- a/ocis/pkg/command/groups.go +++ b/ocis/pkg/command/groups.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func GroupsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Groups.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Groups.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/idm.go b/ocis/pkg/command/idm.go index 21862ade9..d1e100a05 100644 --- a/ocis/pkg/command/idm.go +++ b/ocis/pkg/command/idm.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func IDMCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.IDM.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.IDM.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/idp.go b/ocis/pkg/command/idp.go index 6b798bf43..b932f2465 100644 --- a/ocis/pkg/command/idp.go +++ b/ocis/pkg/command/idp.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func IDPCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.IDP.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.IDP.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/migrate.go b/ocis/pkg/command/migrate.go index 3f18b96ec..fa020a1af 100644 --- a/ocis/pkg/command/migrate.go +++ b/ocis/pkg/command/migrate.go @@ -2,7 +2,6 @@ package command import ( "context" - "fmt" "os" "sync" @@ -13,6 +12,7 @@ import ( "github.com/cs3org/reva/v2/pkg/share/manager/registry" "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/register" sharing "github.com/owncloud/ocis/v2/services/sharing/pkg/config" @@ -27,21 +27,6 @@ func Migrate(cfg *config.Config) *cli.Command { Name: "migrate", Usage: "migrate data from an existing to another instance", Category: "migration", - Before: func(c *cli.Context) error { - // Parse base config - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - return err - } - - // Parse sharing config - cfg.Sharing.Commons = cfg.Commons - if err := sharingparser.ParseConfig(cfg.Sharing); err != nil { - fmt.Printf("%v", err) - return err - } - return nil - }, Subcommands: []*cli.Command{ MigrateShares(cfg), MigratePublicShares(cfg), @@ -69,6 +54,16 @@ func MigrateShares(cfg *config.Config) *cli.Command { Usage: "Share manager to import the data into", }, }, + Before: func(c *cli.Context) error { + // Parse base config + if err := parser.ParseConfig(cfg, true); err != nil { + return configlog.LogReturnError(err) + } + + // Parse sharing config + cfg.Sharing.Commons = cfg.Commons + return configlog.LogReturnError(sharingparser.ParseConfig(cfg.Sharing)) + }, Action: func(c *cli.Context) error { log := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).With().Timestamp().Logger() ctx := log.WithContext(context.Background()) @@ -154,6 +149,16 @@ func MigratePublicShares(cfg *config.Config) *cli.Command { Usage: "Public share manager to import the data into", }, }, + Before: func(c *cli.Context) error { + // Parse base config + if err := parser.ParseConfig(cfg, true); err != nil { + return configlog.LogReturnError(err) + } + + // Parse sharing config + cfg.Sharing.Commons = cfg.Commons + return configlog.LogReturnError(sharingparser.ParseConfig(cfg.Sharing)) + }, Action: func(c *cli.Context) error { log := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).With().Timestamp().Logger() ctx := log.WithContext(context.Background()) diff --git a/ocis/pkg/command/nats.go b/ocis/pkg/command/nats.go index e8c60061e..a7ec22ad6 100644 --- a/ocis/pkg/command/nats.go +++ b/ocis/pkg/command/nats.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func NatsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Nats.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Nats.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/notifications.go b/ocis/pkg/command/notifications.go index 0599dc86e..1bdea39f2 100644 --- a/ocis/pkg/command/notifications.go +++ b/ocis/pkg/command/notifications.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func NotificationsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Notifications.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Notifications.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/ocdav.go b/ocis/pkg/command/ocdav.go index cc04d6488..f48683a44 100644 --- a/ocis/pkg/command/ocdav.go +++ b/ocis/pkg/command/ocdav.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func OCDavCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.OCDav.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.OCDav.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/ocs.go b/ocis/pkg/command/ocs.go index abeb8310b..1c27e1cdd 100644 --- a/ocis/pkg/command/ocs.go +++ b/ocis/pkg/command/ocs.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func OCSCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.OCS.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.OCS.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/proxy.go b/ocis/pkg/command/proxy.go index 127957bc6..7e1204248 100644 --- a/ocis/pkg/command/proxy.go +++ b/ocis/pkg/command/proxy.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func ProxyCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Proxy.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Proxy.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/search.go b/ocis/pkg/command/search.go index c649fbce4..050b8b430 100644 --- a/ocis/pkg/command/search.go +++ b/ocis/pkg/command/search.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func SearchCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Search.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Search.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/server.go b/ocis/pkg/command/server.go index c935aba9f..685d55ebf 100644 --- a/ocis/pkg/command/server.go +++ b/ocis/pkg/command/server.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/register" "github.com/owncloud/ocis/v2/ocis/pkg/runtime" @@ -17,11 +16,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: "start a fullstack server (runtime and all services in supervised mode)", Category: "fullstack", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, false); err != nil { - fmt.Printf("%v", err) - return err - } - return nil + return configlog.LogReturnError(parser.ParseConfig(cfg, false)) }, Action: func(c *cli.Context) error { r := runtime.New(cfg) diff --git a/ocis/pkg/command/settings.go b/ocis/pkg/command/settings.go index ec95cf3a1..c9609b10e 100644 --- a/ocis/pkg/command/settings.go +++ b/ocis/pkg/command/settings.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func SettingsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Settings.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Settings.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/sharing.go b/ocis/pkg/command/sharing.go index 9145f532c..1df0e1530 100644 --- a/ocis/pkg/command/sharing.go +++ b/ocis/pkg/command/sharing.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func SharingCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Sharing.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Sharing.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/storage-publiclink.go b/ocis/pkg/command/storage-publiclink.go index 04780870c..4d91368c6 100644 --- a/ocis/pkg/command/storage-publiclink.go +++ b/ocis/pkg/command/storage-publiclink.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func StoragePublicLinkCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.StoragePublicLink.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.StoragePublicLink.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/storage-shares.go b/ocis/pkg/command/storage-shares.go index e499e008f..744b20c12 100644 --- a/ocis/pkg/command/storage-shares.go +++ b/ocis/pkg/command/storage-shares.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func StorageSharesCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.StorageShares.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.StorageShares.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/storage-system.go b/ocis/pkg/command/storage-system.go index e90af4690..ed790b6c4 100644 --- a/ocis/pkg/command/storage-system.go +++ b/ocis/pkg/command/storage-system.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func StorageSystemCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.StorageSystem.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.StorageSystem.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/storage-users.go b/ocis/pkg/command/storage-users.go index f1598332b..c3745a842 100644 --- a/ocis/pkg/command/storage-users.go +++ b/ocis/pkg/command/storage-users.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func StorageUsersCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.StorageUsers.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.StorageUsers.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/store.go b/ocis/pkg/command/store.go index 617af037c..8dcc455f4 100644 --- a/ocis/pkg/command/store.go +++ b/ocis/pkg/command/store.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -19,9 +18,7 @@ func StoreCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Store.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Store.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/thumbnails.go b/ocis/pkg/command/thumbnails.go index da60a12a1..682020c7b 100644 --- a/ocis/pkg/command/thumbnails.go +++ b/ocis/pkg/command/thumbnails.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Thumbnails.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Thumbnails.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/users.go b/ocis/pkg/command/users.go index 992a04928..97b7e30be 100644 --- a/ocis/pkg/command/users.go +++ b/ocis/pkg/command/users.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func UsersCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Users.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Users.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/web.go b/ocis/pkg/command/web.go index dd826d6b9..983134f1f 100644 --- a/ocis/pkg/command/web.go +++ b/ocis/pkg/command/web.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -18,9 +17,7 @@ func WebCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.Web.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.Web.Commons = cfg.Commons return nil }, diff --git a/ocis/pkg/command/webdav.go b/ocis/pkg/command/webdav.go index 20be56b5b..ea9e42531 100644 --- a/ocis/pkg/command/webdav.go +++ b/ocis/pkg/command/webdav.go @@ -1,9 +1,8 @@ package command import ( - "fmt" - "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/config/parser" "github.com/owncloud/ocis/v2/ocis/pkg/command/helper" "github.com/owncloud/ocis/v2/ocis/pkg/register" @@ -19,9 +18,7 @@ func WebDAVCommand(cfg *config.Config) *cli.Command { Usage: helper.SubcommandDescription(cfg.WebDAV.Service.Name), Category: "services", Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg, true); err != nil { - fmt.Printf("%v", err) - } + configlog.LogError(parser.ParseConfig(cfg, true)) cfg.WebDAV.Commons = cfg.Commons return nil }, diff --git a/services/app-provider/pkg/command/health.go b/services/app-provider/pkg/command/health.go index 9344b8a9a..684c2ce42 100644 --- a/services/app-provider/pkg/command/health.go +++ b/services/app-provider/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/app-provider/pkg/config" "github.com/owncloud/ocis/v2/services/app-provider/pkg/config/parser" "github.com/owncloud/ocis/v2/services/app-provider/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index 9f4e940f7..eb399c578 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -28,12 +29,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/app-registry/pkg/command/health.go b/services/app-registry/pkg/command/health.go index d1227a054..f9b6737f1 100644 --- a/services/app-registry/pkg/command/health.go +++ b/services/app-registry/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/app-registry/pkg/config" "github.com/owncloud/ocis/v2/services/app-registry/pkg/config/parser" "github.com/owncloud/ocis/v2/services/app-registry/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index f104d405a..7339ebd3e 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/app-registry/pkg/config" @@ -27,12 +28,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/audit/pkg/command/server.go b/services/audit/pkg/command/server.go index 894231289..a3f0121d3 100644 --- a/services/audit/pkg/command/server.go +++ b/services/audit/pkg/command/server.go @@ -3,11 +3,11 @@ package command import ( "context" "fmt" - "os" "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/events/server" "github.com/go-micro/plugins/v4/events/natsjs" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/audit/pkg/config" "github.com/owncloud/ocis/v2/services/audit/pkg/config/parser" "github.com/owncloud/ocis/v2/services/audit/pkg/logging" @@ -23,12 +23,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/auth-basic/pkg/command/health.go b/services/auth-basic/pkg/command/health.go index 48f07427d..357139e60 100644 --- a/services/auth-basic/pkg/command/health.go +++ b/services/auth-basic/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/config" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/config/parser" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/auth-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index 59fd65cef..908883fca 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/ldap" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" @@ -29,12 +30,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/auth-bearer/pkg/command/health.go b/services/auth-bearer/pkg/command/health.go index 040e695b2..59c619b49 100644 --- a/services/auth-bearer/pkg/command/health.go +++ b/services/auth-bearer/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config/parser" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/auth-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index d43f0dc1e..d923a0e4c 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -28,12 +29,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/auth-machine/pkg/command/health.go b/services/auth-machine/pkg/command/health.go index cc26ea7f2..252bca77c 100644 --- a/services/auth-machine/pkg/command/health.go +++ b/services/auth-machine/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config/parser" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/auth-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index 181869372..31e3572af 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -28,12 +29,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/frontend/pkg/command/health.go b/services/frontend/pkg/command/health.go index 158586826..4feeb3d6d 100644 --- a/services/frontend/pkg/command/health.go +++ b/services/frontend/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/frontend/pkg/config" "github.com/owncloud/ocis/v2/services/frontend/pkg/config/parser" "github.com/owncloud/ocis/v2/services/frontend/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index b5309344e..8ac249221 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -28,12 +29,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/gateway/pkg/command/health.go b/services/gateway/pkg/command/health.go index 1dd8229b6..54ca2717a 100644 --- a/services/gateway/pkg/command/health.go +++ b/services/gateway/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/gateway/pkg/config" "github.com/owncloud/ocis/v2/services/gateway/pkg/config/parser" "github.com/owncloud/ocis/v2/services/gateway/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/gateway/pkg/command/server.go b/services/gateway/pkg/command/server.go index b24d05b9d..18202cf13 100644 --- a/services/gateway/pkg/command/server.go +++ b/services/gateway/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/gateway/pkg/config" @@ -27,12 +28,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/graph-explorer/pkg/command/health.go b/services/graph-explorer/pkg/command/health.go index b83a33c82..07547d98b 100644 --- a/services/graph-explorer/pkg/command/health.go +++ b/services/graph-explorer/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config" "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config/parser" "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/graph-explorer/pkg/command/server.go b/services/graph-explorer/pkg/command/server.go index 01a7a58e4..564739a53 100644 --- a/services/graph-explorer/pkg/command/server.go +++ b/services/graph-explorer/pkg/command/server.go @@ -3,9 +3,9 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config" "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config/parser" @@ -24,12 +24,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(ctx *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/graph/pkg/command/health.go b/services/graph/pkg/command/health.go index e1cbbbd64..788ef9feb 100644 --- a/services/graph/pkg/command/health.go +++ b/services/graph/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/graph/pkg/config" "github.com/owncloud/ocis/v2/services/graph/pkg/config/parser" "github.com/owncloud/ocis/v2/services/graph/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/graph/pkg/command/server.go b/services/graph/pkg/command/server.go index 636ff4544..4ad0faa3b 100644 --- a/services/graph/pkg/command/server.go +++ b/services/graph/pkg/command/server.go @@ -3,9 +3,9 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/graph/pkg/config" "github.com/owncloud/ocis/v2/services/graph/pkg/config/parser" @@ -24,12 +24,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/groups/pkg/command/health.go b/services/groups/pkg/command/health.go index 9925b7ce6..e0a87a080 100644 --- a/services/groups/pkg/command/health.go +++ b/services/groups/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/groups/pkg/config" "github.com/owncloud/ocis/v2/services/groups/pkg/config/parser" "github.com/owncloud/ocis/v2/services/groups/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index e6883793e..7652d2213 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/ldap" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" @@ -29,12 +30,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/idm/pkg/command/health.go b/services/idm/pkg/command/health.go index 1b7d5a484..1abac500c 100644 --- a/services/idm/pkg/command/health.go +++ b/services/idm/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/idm/pkg/config" "github.com/owncloud/ocis/v2/services/idm/pkg/config/parser" "github.com/owncloud/ocis/v2/services/idm/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/idm/pkg/command/resetpw.go b/services/idm/pkg/command/resetpw.go index 7fd5c52eb..a98b39946 100644 --- a/services/idm/pkg/command/resetpw.go +++ b/services/idm/pkg/command/resetpw.go @@ -11,6 +11,7 @@ import ( "github.com/go-ldap/ldap/v3" "github.com/libregraph/idm/pkg/ldbbolt" "github.com/libregraph/idm/server" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/log" "github.com/owncloud/ocis/v2/services/idm/pkg/config" "github.com/owncloud/ocis/v2/services/idm/pkg/config/parser" @@ -24,15 +25,10 @@ import ( func ResetPassword(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "resetpassword", - Usage: fmt.Sprintf("Reset admin password"), + Usage: "Reset admin password", Category: "password reset", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/idm/pkg/command/server.go b/services/idm/pkg/command/server.go index 92a30f7ba..2e0e96d2d 100644 --- a/services/idm/pkg/command/server.go +++ b/services/idm/pkg/command/server.go @@ -13,6 +13,7 @@ import ( "github.com/libregraph/idm/pkg/ldappassword" "github.com/libregraph/idm/pkg/ldbbolt" "github.com/libregraph/idm/server" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" pkgcrypto "github.com/owncloud/ocis/v2/ocis-pkg/crypto" "github.com/owncloud/ocis/v2/ocis-pkg/log" "github.com/owncloud/ocis/v2/services/idm" @@ -29,12 +30,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/idp/pkg/command/health.go b/services/idp/pkg/command/health.go index 687d806fe..108af9d28 100644 --- a/services/idp/pkg/command/health.go +++ b/services/idp/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/idp/pkg/config" "github.com/owncloud/ocis/v2/services/idp/pkg/config/parser" "github.com/owncloud/ocis/v2/services/idp/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/idp/pkg/command/server.go b/services/idp/pkg/command/server.go index 70bc123d7..c6a265868 100644 --- a/services/idp/pkg/command/server.go +++ b/services/idp/pkg/command/server.go @@ -15,6 +15,7 @@ import ( "path/filepath" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/idp/pkg/config" "github.com/owncloud/ocis/v2/services/idp/pkg/config/parser" @@ -35,11 +36,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } + configlog.LogReturnFatal(parser.ParseConfig(cfg)) if cfg.IDP.EncryptionSecretFile != "" { if err := ensureEncryptionSecretExists(cfg.IDP.EncryptionSecretFile); err != nil { @@ -49,7 +46,7 @@ func Server(cfg *config.Config) *cli.Command { return err } } - return err + return nil }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/nats/pkg/command/server.go b/services/nats/pkg/command/server.go index abb3ec7d0..1cee11ebb 100644 --- a/services/nats/pkg/command/server.go +++ b/services/nats/pkg/command/server.go @@ -3,10 +3,10 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/nats/pkg/config" "github.com/owncloud/ocis/v2/services/nats/pkg/config/parser" "github.com/owncloud/ocis/v2/services/nats/pkg/logging" @@ -21,12 +21,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/notifications/pkg/command/server.go b/services/notifications/pkg/command/server.go index 9071bee14..12f5ee543 100644 --- a/services/notifications/pkg/command/server.go +++ b/services/notifications/pkg/command/server.go @@ -2,11 +2,11 @@ package command import ( "fmt" - "os" "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/events/server" "github.com/go-micro/plugins/v4/events/natsjs" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/notifications/pkg/channels" "github.com/owncloud/ocis/v2/services/notifications/pkg/config" "github.com/owncloud/ocis/v2/services/notifications/pkg/config/parser" @@ -22,12 +22,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/ocdav/pkg/command/health.go b/services/ocdav/pkg/command/health.go index 8724a43ad..5bee1653e 100644 --- a/services/ocdav/pkg/command/health.go +++ b/services/ocdav/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/ocdav/pkg/config" "github.com/owncloud/ocis/v2/services/ocdav/pkg/config/parser" "github.com/owncloud/ocis/v2/services/ocdav/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/ocdav/pkg/command/server.go b/services/ocdav/pkg/command/server.go index 19d4a351c..1474cd9bc 100644 --- a/services/ocdav/pkg/command/server.go +++ b/services/ocdav/pkg/command/server.go @@ -3,10 +3,10 @@ package command import ( "context" "fmt" - "os" "github.com/cs3org/reva/v2/pkg/micro/ocdav" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/ocdav/pkg/config" "github.com/owncloud/ocis/v2/services/ocdav/pkg/config/parser" @@ -23,12 +23,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/ocs/pkg/command/health.go b/services/ocs/pkg/command/health.go index 197c2e1ca..dfa9f0777 100644 --- a/services/ocs/pkg/command/health.go +++ b/services/ocs/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/ocs/pkg/config" "github.com/owncloud/ocis/v2/services/ocs/pkg/config/parser" "github.com/owncloud/ocis/v2/services/ocs/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/ocs/pkg/command/server.go b/services/ocs/pkg/command/server.go index 04b3701c4..507951fb5 100644 --- a/services/ocs/pkg/command/server.go +++ b/services/ocs/pkg/command/server.go @@ -3,8 +3,8 @@ package command import ( "context" "fmt" - "os" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/ocs/pkg/config/parser" "github.com/owncloud/ocis/v2/services/ocs/pkg/logging" @@ -25,12 +25,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/proxy/pkg/command/health.go b/services/proxy/pkg/command/health.go index cb9ee814b..2646f53c6 100644 --- a/services/proxy/pkg/command/health.go +++ b/services/proxy/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/proxy/pkg/config" "github.com/owncloud/ocis/v2/services/proxy/pkg/config/parser" "github.com/owncloud/ocis/v2/services/proxy/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/proxy/pkg/command/server.go b/services/proxy/pkg/command/server.go index 16cb959d4..e5ebcaac8 100644 --- a/services/proxy/pkg/command/server.go +++ b/services/proxy/pkg/command/server.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "fmt" "net/http" - "os" "time" "github.com/coreos/go-oidc/v3/oidc" @@ -13,6 +12,7 @@ import ( chimiddleware "github.com/go-chi/chi/v5/middleware" "github.com/justinas/alice" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/log" pkgmiddleware "github.com/owncloud/ocis/v2/ocis-pkg/middleware" "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc" @@ -41,12 +41,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/search/pkg/command/server.go b/services/search/pkg/command/server.go index 3faf1e061..0e0dcd057 100644 --- a/services/search/pkg/command/server.go +++ b/services/search/pkg/command/server.go @@ -3,9 +3,9 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/search/pkg/config" "github.com/owncloud/ocis/v2/services/search/pkg/config/parser" @@ -24,12 +24,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/settings/pkg/command/health.go b/services/settings/pkg/command/health.go index 68dee3672..fc126cad1 100644 --- a/services/settings/pkg/command/health.go +++ b/services/settings/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/settings/pkg/config" "github.com/owncloud/ocis/v2/services/settings/pkg/config/parser" "github.com/owncloud/ocis/v2/services/settings/pkg/logging" @@ -16,11 +17,7 @@ func Health(cfg *config.Config) *cli.Command { Name: "health", Usage: "Check health status", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/settings/pkg/command/server.go b/services/settings/pkg/command/server.go index 4dd9b9a40..101f070ee 100644 --- a/services/settings/pkg/command/server.go +++ b/services/settings/pkg/command/server.go @@ -3,9 +3,9 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/settings/pkg/config" "github.com/owncloud/ocis/v2/services/settings/pkg/config/parser" @@ -25,12 +25,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/sharing/pkg/command/health.go b/services/sharing/pkg/command/health.go index 1c2bb37ed..00a34e5fc 100644 --- a/services/sharing/pkg/command/health.go +++ b/services/sharing/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/sharing/pkg/config" "github.com/owncloud/ocis/v2/services/sharing/pkg/config/parser" "github.com/owncloud/ocis/v2/services/sharing/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index a690f6d23..00c675fa1 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -10,6 +10,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -29,12 +30,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/storage-publiclink/pkg/command/health.go b/services/storage-publiclink/pkg/command/health.go index b2f3889f5..70a392baf 100644 --- a/services/storage-publiclink/pkg/command/health.go +++ b/services/storage-publiclink/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/config" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/config/parser" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index 80ebfaff2..257c78d8b 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -28,12 +29,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/storage-shares/pkg/command/health.go b/services/storage-shares/pkg/command/health.go index 90e68c8ba..f607aae7b 100644 --- a/services/storage-shares/pkg/command/health.go +++ b/services/storage-shares/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/config" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/config/parser" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index 7a4c208c6..8cd42e99c 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -28,12 +29,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/storage-system/pkg/command/health.go b/services/storage-system/pkg/command/health.go index 8b5d5e116..dcef0c624 100644 --- a/services/storage-system/pkg/command/health.go +++ b/services/storage-system/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/storage-system/pkg/config" "github.com/owncloud/ocis/v2/services/storage-system/pkg/config/parser" "github.com/owncloud/ocis/v2/services/storage-system/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index a9257b985..aba0df8e6 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -28,12 +29,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/storage-users/pkg/command/health.go b/services/storage-users/pkg/command/health.go index 9dcb45556..3c92b63bd 100644 --- a/services/storage-users/pkg/command/health.go +++ b/services/storage-users/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config/parser" "github.com/owncloud/ocis/v2/services/storage-users/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index caf1de68f..f7b3f6850 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -28,12 +29,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/storage-users/pkg/command/uploads.go b/services/storage-users/pkg/command/uploads.go index ea553de01..90568c97b 100644 --- a/services/storage-users/pkg/command/uploads.go +++ b/services/storage-users/pkg/command/uploads.go @@ -12,6 +12,7 @@ import ( "github.com/cs3org/reva/v2/pkg/storage" "github.com/cs3org/reva/v2/pkg/storage/fs/registry" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config/parser" "github.com/owncloud/ocis/v2/services/storage-users/pkg/revaconfig" @@ -19,16 +20,9 @@ import ( func Uploads(cfg *config.Config) *cli.Command { return &cli.Command{ - Name: "uploads", - Usage: "manage unfinished uploads", - Category: "maintenance", - Before: func(c *cli.Context) error { - if err := parser.ParseConfig(cfg); err != nil { - fmt.Printf("%v", err) - return err - } - return nil - }, + + Name: "uploads", + Usage: "manage unfinished uploads", Subcommands: []*cli.Command{ ListUploads(cfg), PurgeExpiredUploads(cfg), @@ -42,12 +36,7 @@ func ListUploads(cfg *config.Config) *cli.Command { Name: "list", Usage: "Print a list of all incomplete uploads", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { f, ok := registry.NewFuncs[cfg.Driver] @@ -88,12 +77,7 @@ func PurgeExpiredUploads(cfg *config.Config) *cli.Command { Name: "clean", Usage: "Clean up leftovers from expired uploads", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { f, ok := registry.NewFuncs[cfg.Driver] diff --git a/services/store/pkg/command/health.go b/services/store/pkg/command/health.go index e08ec2c78..7ec9a7b1f 100644 --- a/services/store/pkg/command/health.go +++ b/services/store/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/store/pkg/config" "github.com/owncloud/ocis/v2/services/store/pkg/config/parser" "github.com/owncloud/ocis/v2/services/store/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/store/pkg/command/server.go b/services/store/pkg/command/server.go index c548b786d..e472e5d81 100644 --- a/services/store/pkg/command/server.go +++ b/services/store/pkg/command/server.go @@ -3,10 +3,10 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/store/pkg/config" "github.com/owncloud/ocis/v2/services/store/pkg/config/parser" @@ -25,12 +25,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/thumbnails/pkg/command/health.go b/services/thumbnails/pkg/command/health.go index d8e1210b0..341b156f6 100644 --- a/services/thumbnails/pkg/command/health.go +++ b/services/thumbnails/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/config" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/config/parser" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/thumbnails/pkg/command/server.go b/services/thumbnails/pkg/command/server.go index 404a9815c..ebe72e8e8 100644 --- a/services/thumbnails/pkg/command/server.go +++ b/services/thumbnails/pkg/command/server.go @@ -3,9 +3,9 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/config" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/config/parser" @@ -25,12 +25,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/users/pkg/command/health.go b/services/users/pkg/command/health.go index 729dcf4d0..13841bde0 100644 --- a/services/users/pkg/command/health.go +++ b/services/users/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/users/pkg/config" "github.com/owncloud/ocis/v2/services/users/pkg/config/parser" "github.com/owncloud/ocis/v2/services/users/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/users/pkg/command/server.go b/services/users/pkg/command/server.go index 2fc836d36..008200215 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -9,6 +9,7 @@ import ( "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/ldap" "github.com/owncloud/ocis/v2/ocis-pkg/service/external" "github.com/owncloud/ocis/v2/ocis-pkg/sync" @@ -29,12 +30,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/web/pkg/command/health.go b/services/web/pkg/command/health.go index 633067f85..157e8b434 100644 --- a/services/web/pkg/command/health.go +++ b/services/web/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/web/pkg/config" "github.com/owncloud/ocis/v2/services/web/pkg/config/parser" "github.com/owncloud/ocis/v2/services/web/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/web/pkg/command/server.go b/services/web/pkg/command/server.go index 247e24963..083074bcc 100644 --- a/services/web/pkg/command/server.go +++ b/services/web/pkg/command/server.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" "io/ioutil" - "os" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/web/pkg/config" "github.com/owncloud/ocis/v2/services/web/pkg/config/parser" "github.com/owncloud/ocis/v2/services/web/pkg/logging" @@ -25,12 +25,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/webdav/pkg/command/health.go b/services/webdav/pkg/command/health.go index e0bc1d5d2..edfec5d6d 100644 --- a/services/webdav/pkg/command/health.go +++ b/services/webdav/pkg/command/health.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/services/webdav/pkg/config" "github.com/owncloud/ocis/v2/services/webdav/pkg/config/parser" "github.com/owncloud/ocis/v2/services/webdav/pkg/logging" @@ -17,11 +18,7 @@ func Health(cfg *config.Config) *cli.Command { Usage: "check health status", Category: "info", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - } - return err + return configlog.LogReturnError(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) diff --git a/services/webdav/pkg/command/server.go b/services/webdav/pkg/command/server.go index 4b2290ae1..4c505c5c4 100644 --- a/services/webdav/pkg/command/server.go +++ b/services/webdav/pkg/command/server.go @@ -3,9 +3,9 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" + "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/webdav/pkg/config" "github.com/owncloud/ocis/v2/services/webdav/pkg/config/parser" @@ -24,12 +24,7 @@ func Server(cfg *config.Config) *cli.Command { Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name), Category: "server", Before: func(c *cli.Context) error { - err := parser.ParseConfig(cfg) - if err != nil { - fmt.Printf("%v", err) - os.Exit(1) - } - return err + return configlog.LogReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log)