diff --git a/ocis/pkg/command/antivirus.go b/ocis/pkg/command/antivirus.go deleted file mode 100644 index 24cd36efb..000000000 --- a/ocis/pkg/command/antivirus.go +++ /dev/null @@ -1,29 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/antivirus/pkg/command" - "github.com/urfave/cli/v2" -) - -// AntivirusCommand is the entrypoint for the antivirus command. -func AntivirusCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Antivirus.Service.Name, - Usage: helper.SubcommandDescription(cfg.Antivirus.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - return nil - }, - Subcommands: command.GetCommands(cfg.Antivirus), - } -} - -func init() { - register.AddCommand(AntivirusCommand) -} diff --git a/ocis/pkg/command/app-provider.go b/ocis/pkg/command/app-provider.go deleted file mode 100644 index 50f20ce76..000000000 --- a/ocis/pkg/command/app-provider.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/app-provider/pkg/command" - "github.com/urfave/cli/v2" -) - -// AppProviderCommand is the entrypoint for the app provider command. -func AppProviderCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.AppProvider.Service.Name, - Usage: helper.SubcommandDescription(cfg.AppProvider.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.AppProvider.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.AppProvider), - } -} - -func init() { - register.AddCommand(AppProviderCommand) -} diff --git a/ocis/pkg/command/app-registry.go b/ocis/pkg/command/app-registry.go deleted file mode 100644 index d35fcabb4..000000000 --- a/ocis/pkg/command/app-registry.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/app-registry/pkg/command" - "github.com/urfave/cli/v2" -) - -// AppRegistryCommand is the entrypoint for the AppRegistry command. -func AppRegistryCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.AppRegistry.Service.Name, - Usage: helper.SubcommandDescription(cfg.AppRegistry.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.AppRegistry.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.AppRegistry), - } -} - -func init() { - register.AddCommand(AppRegistryCommand) -} diff --git a/ocis/pkg/command/audit.go b/ocis/pkg/command/audit.go deleted file mode 100644 index 7299a71a8..000000000 --- a/ocis/pkg/command/audit.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/audit/pkg/command" - "github.com/urfave/cli/v2" -) - -// AuditCommand is the entrypoint for the Audit command. -func AuditCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Audit.Service.Name, - Usage: helper.SubcommandDescription(cfg.Audit.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Audit.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Audit), - } -} - -func init() { - register.AddCommand(AuditCommand) -} diff --git a/ocis/pkg/command/auth-basic.go b/ocis/pkg/command/auth-basic.go deleted file mode 100644 index 48a026647..000000000 --- a/ocis/pkg/command/auth-basic.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/auth-basic/pkg/command" - "github.com/urfave/cli/v2" -) - -// AuthBasicCommand is the entrypoint for the AuthBasic command. -func AuthBasicCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.AuthBasic.Service.Name, - Usage: helper.SubcommandDescription(cfg.AuthBasic.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.AuthBasic.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.AuthBasic), - } -} - -func init() { - register.AddCommand(AuthBasicCommand) -} diff --git a/ocis/pkg/command/auth-bearer.go b/ocis/pkg/command/auth-bearer.go deleted file mode 100644 index 413e15e9e..000000000 --- a/ocis/pkg/command/auth-bearer.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/command" - "github.com/urfave/cli/v2" -) - -// AuthBearerCommand is the entrypoint for the AuthBearer command. -func AuthBearerCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.AuthBearer.Service.Name, - Usage: helper.SubcommandDescription(cfg.AuthBearer.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.AuthBearer.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.AuthBearer), - } -} - -func init() { - register.AddCommand(AuthBearerCommand) -} diff --git a/ocis/pkg/command/auth-machine.go b/ocis/pkg/command/auth-machine.go deleted file mode 100644 index 17c23b632..000000000 --- a/ocis/pkg/command/auth-machine.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/auth-machine/pkg/command" - "github.com/urfave/cli/v2" -) - -// AuthMachineCommand is the entrypoint for the AuthMachine command. -func AuthMachineCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.AuthMachine.Service.Name, - Usage: helper.SubcommandDescription(cfg.AuthMachine.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.AuthMachine.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.AuthMachine), - } -} - -func init() { - register.AddCommand(AuthMachineCommand) -} diff --git a/ocis/pkg/command/eventhistory.go b/ocis/pkg/command/eventhistory.go deleted file mode 100644 index a75122210..000000000 --- a/ocis/pkg/command/eventhistory.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/eventhistory/pkg/command" - "github.com/urfave/cli/v2" -) - -// EventHistoryCommand is the entrypoint for the eventhistory command. -func EventHistoryCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.EventHistory.Service.Name, - Usage: helper.SubcommandDescription(cfg.EventHistory.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.EventHistory.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.EventHistory), - } -} - -func init() { - register.AddCommand(EventHistoryCommand) -} diff --git a/ocis/pkg/command/frontend.go b/ocis/pkg/command/frontend.go deleted file mode 100644 index ae28f4105..000000000 --- a/ocis/pkg/command/frontend.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/frontend/pkg/command" - "github.com/urfave/cli/v2" -) - -// FrontendCommand is the entrypoint for the Frontend command. -func FrontendCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Frontend.Service.Name, - Usage: helper.SubcommandDescription(cfg.Frontend.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Frontend.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Frontend), - } -} - -func init() { - register.AddCommand(FrontendCommand) -} diff --git a/ocis/pkg/command/gateway.go b/ocis/pkg/command/gateway.go deleted file mode 100644 index 3562ffade..000000000 --- a/ocis/pkg/command/gateway.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/gateway/pkg/command" - "github.com/urfave/cli/v2" -) - -// GatewayCommand is the entrypoint for the Gateway command. -func GatewayCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Gateway.Service.Name, - Usage: helper.SubcommandDescription(cfg.Gateway.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Gateway.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Gateway), - } -} - -func init() { - register.AddCommand(GatewayCommand) -} diff --git a/ocis/pkg/command/graph.go b/ocis/pkg/command/graph.go deleted file mode 100644 index 4ff45e231..000000000 --- a/ocis/pkg/command/graph.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/graph/pkg/command" - "github.com/urfave/cli/v2" -) - -// GraphCommand is the entrypoint for the graph command. -func GraphCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Graph.Service.Name, - Usage: helper.SubcommandDescription(cfg.Graph.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Graph.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Graph), - } -} - -func init() { - register.AddCommand(GraphCommand) -} diff --git a/ocis/pkg/command/groups.go b/ocis/pkg/command/groups.go deleted file mode 100644 index 630f1060e..000000000 --- a/ocis/pkg/command/groups.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/groups/pkg/command" - "github.com/urfave/cli/v2" -) - -// GroupsCommand is the entrypoint for the groups command. -func GroupsCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Groups.Service.Name, - Usage: helper.SubcommandDescription(cfg.Groups.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Groups.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Groups), - } -} - -func init() { - register.AddCommand(GroupsCommand) -} diff --git a/ocis/pkg/command/idm.go b/ocis/pkg/command/idm.go deleted file mode 100644 index 3adc83738..000000000 --- a/ocis/pkg/command/idm.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/idm/pkg/command" - "github.com/urfave/cli/v2" -) - -// IDMCommand is the entrypoint for the idm command. -func IDMCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.IDM.Service.Name, - Usage: helper.SubcommandDescription(cfg.IDM.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.IDM.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.IDM), - } -} - -func init() { - register.AddCommand(IDMCommand) -} diff --git a/ocis/pkg/command/idp.go b/ocis/pkg/command/idp.go deleted file mode 100644 index b8f0449c7..000000000 --- a/ocis/pkg/command/idp.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/idp/pkg/command" - "github.com/urfave/cli/v2" -) - -// IDPCommand is the entrypoint for the idp command. -func IDPCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.IDP.Service.Name, - Usage: helper.SubcommandDescription(cfg.IDP.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.IDP.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.IDP), - } -} - -func init() { - register.AddCommand(IDPCommand) -} diff --git a/ocis/pkg/command/invitations.go b/ocis/pkg/command/invitations.go deleted file mode 100644 index 984d8adf8..000000000 --- a/ocis/pkg/command/invitations.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/invitations/pkg/command" - "github.com/urfave/cli/v2" -) - -// InvitationsCommand is the entrypoint for the invitations command. -func InvitationsCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Invitations.Service.Name, - Usage: helper.SubcommandDescription(cfg.Invitations.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Invitations.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Invitations), - } -} - -func init() { - register.AddCommand(InvitationsCommand) -} diff --git a/ocis/pkg/command/nats.go b/ocis/pkg/command/nats.go deleted file mode 100644 index 989286c0a..000000000 --- a/ocis/pkg/command/nats.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/nats/pkg/command" - "github.com/urfave/cli/v2" -) - -// NatsCommand is the entrypoint for the Nats command. -func NatsCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Nats.Service.Name, - Usage: helper.SubcommandDescription(cfg.Nats.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Nats.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Nats), - } -} - -func init() { - register.AddCommand(NatsCommand) -} diff --git a/ocis/pkg/command/notifications.go b/ocis/pkg/command/notifications.go deleted file mode 100644 index 0fc591f14..000000000 --- a/ocis/pkg/command/notifications.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/notifications/pkg/command" - "github.com/urfave/cli/v2" -) - -// NotificationsCommand is the entrypoint for the notifications command. -func NotificationsCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Notifications.Service.Name, - Usage: helper.SubcommandDescription(cfg.Notifications.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Notifications.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Notifications), - } -} - -func init() { - register.AddCommand(NotificationsCommand) -} diff --git a/ocis/pkg/command/ocdav.go b/ocis/pkg/command/ocdav.go deleted file mode 100644 index a46cd3ecf..000000000 --- a/ocis/pkg/command/ocdav.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/ocdav/pkg/command" - "github.com/urfave/cli/v2" -) - -// OCDavCommand is the entrypoint for the OCDav command. -func OCDavCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.OCDav.Service.Name, - Usage: helper.SubcommandDescription(cfg.OCDav.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.OCDav.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.OCDav), - } -} - -func init() { - register.AddCommand(OCDavCommand) -} diff --git a/ocis/pkg/command/ocs.go b/ocis/pkg/command/ocs.go deleted file mode 100644 index 89091138c..000000000 --- a/ocis/pkg/command/ocs.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/ocs/pkg/command" - "github.com/urfave/cli/v2" -) - -// OCSCommand is the entrypoint for the ocs command. -func OCSCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.OCS.Service.Name, - Usage: helper.SubcommandDescription(cfg.OCS.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.OCS.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.OCS), - } -} - -func init() { - register.AddCommand(OCSCommand) -} diff --git a/ocis/pkg/command/policies.go b/ocis/pkg/command/policies.go deleted file mode 100644 index 69540d50b..000000000 --- a/ocis/pkg/command/policies.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/policies/pkg/command" - "github.com/urfave/cli/v2" -) - -// PoliciesCommand is the entrypoint for the policies service. -func PoliciesCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Policies.Service.Name, - Usage: helper.SubcommandDescription(cfg.Policies.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Policies.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Policies), - } -} - -func init() { - register.AddCommand(PoliciesCommand) -} diff --git a/ocis/pkg/command/postprocessing.go b/ocis/pkg/command/postprocessing.go deleted file mode 100644 index 0d35a35ac..000000000 --- a/ocis/pkg/command/postprocessing.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/postprocessing/pkg/command" - "github.com/urfave/cli/v2" -) - -// PostprocessingCommand is the entrypoint for the postprocessing command. -func PostprocessingCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Postprocessing.Service.Name, - Usage: helper.SubcommandDescription(cfg.Postprocessing.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Postprocessing.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Postprocessing), - } -} - -func init() { - register.AddCommand(PostprocessingCommand) -} diff --git a/ocis/pkg/command/proxy.go b/ocis/pkg/command/proxy.go deleted file mode 100644 index 0bdbf71e2..000000000 --- a/ocis/pkg/command/proxy.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/proxy/pkg/command" - "github.com/urfave/cli/v2" -) - -// ProxyCommand is the entry point for the proxy command. -func ProxyCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Proxy.Service.Name, - Usage: helper.SubcommandDescription(cfg.Proxy.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Proxy.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Proxy), - } -} - -func init() { - register.AddCommand(ProxyCommand) -} diff --git a/ocis/pkg/command/search.go b/ocis/pkg/command/search.go deleted file mode 100644 index 59cb691e9..000000000 --- a/ocis/pkg/command/search.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/search/pkg/command" - "github.com/urfave/cli/v2" -) - -// SearchCommand is the entry point for the search command. -func SearchCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Search.Service.Name, - Usage: helper.SubcommandDescription(cfg.Search.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Search.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Search), - } -} - -func init() { - register.AddCommand(SearchCommand) -} diff --git a/ocis/pkg/command/services.go b/ocis/pkg/command/services.go new file mode 100644 index 000000000..801ba4560 --- /dev/null +++ b/ocis/pkg/command/services.go @@ -0,0 +1,214 @@ +package command + +import ( + "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" + "github.com/urfave/cli/v2" + + antivirus "github.com/owncloud/ocis/v2/services/antivirus/pkg/command" + appprovider "github.com/owncloud/ocis/v2/services/app-provider/pkg/command" + appregistry "github.com/owncloud/ocis/v2/services/app-registry/pkg/command" + audit "github.com/owncloud/ocis/v2/services/audit/pkg/command" + authbasic "github.com/owncloud/ocis/v2/services/auth-basic/pkg/command" + authbearer "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/command" + authmachine "github.com/owncloud/ocis/v2/services/auth-machine/pkg/command" + eventhistory "github.com/owncloud/ocis/v2/services/eventhistory/pkg/command" + frontend "github.com/owncloud/ocis/v2/services/frontend/pkg/command" + gateway "github.com/owncloud/ocis/v2/services/gateway/pkg/command" + graph "github.com/owncloud/ocis/v2/services/graph/pkg/command" + groups "github.com/owncloud/ocis/v2/services/groups/pkg/command" + idm "github.com/owncloud/ocis/v2/services/idm/pkg/command" + idp "github.com/owncloud/ocis/v2/services/idp/pkg/command" + invitations "github.com/owncloud/ocis/v2/services/invitations/pkg/command" + nats "github.com/owncloud/ocis/v2/services/nats/pkg/command" + notifications "github.com/owncloud/ocis/v2/services/notifications/pkg/command" + ocdav "github.com/owncloud/ocis/v2/services/ocdav/pkg/command" + ocs "github.com/owncloud/ocis/v2/services/ocs/pkg/command" + policies "github.com/owncloud/ocis/v2/services/policies/pkg/command" + postprocessing "github.com/owncloud/ocis/v2/services/postprocessing/pkg/command" + proxy "github.com/owncloud/ocis/v2/services/proxy/pkg/command" + search "github.com/owncloud/ocis/v2/services/search/pkg/command" + settings "github.com/owncloud/ocis/v2/services/settings/pkg/command" + sharing "github.com/owncloud/ocis/v2/services/sharing/pkg/command" + storagepubliclink "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/command" + storageshares "github.com/owncloud/ocis/v2/services/storage-shares/pkg/command" + storagesystem "github.com/owncloud/ocis/v2/services/storage-system/pkg/command" + storageusers "github.com/owncloud/ocis/v2/services/storage-users/pkg/command" + store "github.com/owncloud/ocis/v2/services/store/pkg/command" + thumbnails "github.com/owncloud/ocis/v2/services/thumbnails/pkg/command" + userlog "github.com/owncloud/ocis/v2/services/userlog/pkg/command" + users "github.com/owncloud/ocis/v2/services/users/pkg/command" + web "github.com/owncloud/ocis/v2/services/web/pkg/command" + webdav "github.com/owncloud/ocis/v2/services/webdav/pkg/command" + webfinger "github.com/owncloud/ocis/v2/services/webfinger/pkg/command" +) + +var svccmds = []register.Command{ + func(cfg *config.Config) *cli.Command { + // cfg.Antivirus.Commons = cfg.Commons // antivirus needs no commons atm + return ServiceCommand(cfg, cfg.Antivirus.Service.Name, antivirus.GetCommands(cfg.Antivirus)) + }, + func(cfg *config.Config) *cli.Command { + cfg.AppProvider.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.AppProvider.Service.Name, appprovider.GetCommands(cfg.AppProvider)) + }, + func(cfg *config.Config) *cli.Command { + cfg.AppRegistry.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.AppRegistry.Service.Name, appregistry.GetCommands(cfg.AppRegistry)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Audit.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Audit.Service.Name, audit.GetCommands(cfg.Audit)) + }, + func(cfg *config.Config) *cli.Command { + cfg.AuthBasic.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.AuthBasic.Service.Name, authbasic.GetCommands(cfg.AuthBasic)) + }, + func(cfg *config.Config) *cli.Command { + cfg.AuthBearer.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.AuthBearer.Service.Name, authbearer.GetCommands(cfg.AuthBearer)) + }, + func(cfg *config.Config) *cli.Command { + cfg.AuthMachine.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.AuthMachine.Service.Name, authmachine.GetCommands(cfg.AuthMachine)) + }, + func(cfg *config.Config) *cli.Command { + cfg.EventHistory.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.EventHistory.Service.Name, eventhistory.GetCommands(cfg.EventHistory)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Frontend.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Frontend.Service.Name, frontend.GetCommands(cfg.Frontend)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Gateway.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Gateway.Service.Name, gateway.GetCommands(cfg.Gateway)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Graph.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Graph.Service.Name, graph.GetCommands(cfg.Graph)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Groups.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Groups.Service.Name, groups.GetCommands(cfg.Groups)) + }, + func(cfg *config.Config) *cli.Command { + cfg.IDM.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.IDM.Service.Name, idm.GetCommands(cfg.IDM)) + }, + func(cfg *config.Config) *cli.Command { + cfg.IDP.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.IDP.Service.Name, idp.GetCommands(cfg.IDP)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Invitations.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Invitations.Service.Name, invitations.GetCommands(cfg.Invitations)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Nats.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Nats.Service.Name, nats.GetCommands(cfg.Nats)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Notifications.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Notifications.Service.Name, notifications.GetCommands(cfg.Notifications)) + }, + func(cfg *config.Config) *cli.Command { + cfg.OCDav.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.OCDav.Service.Name, ocdav.GetCommands(cfg.OCDav)) + }, + func(cfg *config.Config) *cli.Command { + cfg.OCS.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.OCS.Service.Name, ocs.GetCommands(cfg.OCS)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Policies.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Policies.Service.Name, policies.GetCommands(cfg.Policies)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Postprocessing.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Postprocessing.Service.Name, postprocessing.GetCommands(cfg.Postprocessing)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Proxy.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Proxy.Service.Name, proxy.GetCommands(cfg.Proxy)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Search.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Search.Service.Name, search.GetCommands(cfg.Search)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Settings.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Settings.Service.Name, settings.GetCommands(cfg.Settings)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Sharing.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Sharing.Service.Name, sharing.GetCommands(cfg.Sharing)) + }, + func(cfg *config.Config) *cli.Command { + cfg.StoragePublicLink.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.StoragePublicLink.Service.Name, storagepubliclink.GetCommands(cfg.StoragePublicLink)) + }, + func(cfg *config.Config) *cli.Command { + cfg.StorageShares.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.StorageShares.Service.Name, storageshares.GetCommands(cfg.StorageShares)) + }, + func(cfg *config.Config) *cli.Command { + cfg.StorageSystem.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.StorageSystem.Service.Name, storagesystem.GetCommands(cfg.StorageSystem)) + }, + func(cfg *config.Config) *cli.Command { + cfg.StorageUsers.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.StorageUsers.Service.Name, storageusers.GetCommands(cfg.StorageUsers)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Store.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Store.Service.Name, store.GetCommands(cfg.Store)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Thumbnails.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Thumbnails.Service.Name, thumbnails.GetCommands(cfg.Thumbnails)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Userlog.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Userlog.Service.Name, userlog.GetCommands(cfg.Userlog)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Users.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Users.Service.Name, users.GetCommands(cfg.Users)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Web.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Web.Service.Name, web.GetCommands(cfg.Web)) + }, + func(cfg *config.Config) *cli.Command { + cfg.WebDAV.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.WebDAV.Service.Name, webdav.GetCommands(cfg.WebDAV)) + }, + func(cfg *config.Config) *cli.Command { + cfg.Webfinger.Commons = cfg.Commons + return ServiceCommand(cfg, cfg.Webfinger.Service.Name, webfinger.GetCommands(cfg.Webfinger)) + }, +} + +// ServiceCommand is the entry point for the all service commands. +func ServiceCommand(cfg *config.Config, servicename string, subcommands []*cli.Command) *cli.Command { + return &cli.Command{ + Name: servicename, + Usage: helper.SubcommandDescription(servicename), + Category: "services", + Before: func(c *cli.Context) error { + configlog.Error(parser.ParseConfig(cfg, true)) + return nil + }, + Subcommands: subcommands, + } +} + +func init() { + for _, c := range svccmds { + register.AddCommand(c) + } +} diff --git a/ocis/pkg/command/settings.go b/ocis/pkg/command/settings.go deleted file mode 100644 index d5950b209..000000000 --- a/ocis/pkg/command/settings.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/settings/pkg/command" - "github.com/urfave/cli/v2" -) - -// SettingsCommand is the entry point for the settings command. -func SettingsCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Settings.Service.Name, - Usage: helper.SubcommandDescription(cfg.Settings.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Settings.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Settings), - } -} - -func init() { - register.AddCommand(SettingsCommand) -} diff --git a/ocis/pkg/command/sharing.go b/ocis/pkg/command/sharing.go deleted file mode 100644 index 31ccc40ca..000000000 --- a/ocis/pkg/command/sharing.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/sharing/pkg/command" - "github.com/urfave/cli/v2" -) - -// SharingCommand is the entrypoint for the Sharing command. -func SharingCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Sharing.Service.Name, - Usage: helper.SubcommandDescription(cfg.Sharing.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Sharing.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Sharing), - } -} - -func init() { - register.AddCommand(SharingCommand) -} diff --git a/ocis/pkg/command/storage-publiclink.go b/ocis/pkg/command/storage-publiclink.go deleted file mode 100644 index 181908924..000000000 --- a/ocis/pkg/command/storage-publiclink.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/command" - "github.com/urfave/cli/v2" -) - -// StoragePublicLinkCommand is the entrypoint for the StoragePublicLink command. -func StoragePublicLinkCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.StoragePublicLink.Service.Name, - Usage: helper.SubcommandDescription(cfg.StoragePublicLink.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.StoragePublicLink.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.StoragePublicLink), - } -} - -func init() { - register.AddCommand(StoragePublicLinkCommand) -} diff --git a/ocis/pkg/command/storage-shares.go b/ocis/pkg/command/storage-shares.go deleted file mode 100644 index 6def89269..000000000 --- a/ocis/pkg/command/storage-shares.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/storage-shares/pkg/command" - "github.com/urfave/cli/v2" -) - -// StorageSharesCommand is the entrypoint for the StorageShares command. -func StorageSharesCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.StorageShares.Service.Name, - Usage: helper.SubcommandDescription(cfg.StorageShares.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.StorageShares.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.StorageShares), - } -} - -func init() { - register.AddCommand(StorageSharesCommand) -} diff --git a/ocis/pkg/command/storage-system.go b/ocis/pkg/command/storage-system.go deleted file mode 100644 index cd933eeea..000000000 --- a/ocis/pkg/command/storage-system.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/storage-system/pkg/command" - "github.com/urfave/cli/v2" -) - -// StorageSystemCommand is the entrypoint for the StorageSystem command. -func StorageSystemCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.StorageSystem.Service.Name, - Usage: helper.SubcommandDescription(cfg.StorageSystem.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.StorageSystem.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.StorageSystem), - } -} - -func init() { - register.AddCommand(StorageSystemCommand) -} diff --git a/ocis/pkg/command/storage-users.go b/ocis/pkg/command/storage-users.go deleted file mode 100644 index 980cc953d..000000000 --- a/ocis/pkg/command/storage-users.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/storage-users/pkg/command" - "github.com/urfave/cli/v2" -) - -// StorageUsersCommand is the entrypoint for the StorageUsers command. -func StorageUsersCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.StorageUsers.Service.Name, - Usage: helper.SubcommandDescription(cfg.StorageUsers.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.StorageUsers.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.StorageUsers), - } -} - -func init() { - register.AddCommand(StorageUsersCommand) -} diff --git a/ocis/pkg/command/store.go b/ocis/pkg/command/store.go deleted file mode 100644 index 947779d71..000000000 --- a/ocis/pkg/command/store.go +++ /dev/null @@ -1,31 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/store/pkg/command" - "github.com/urfave/cli/v2" -) - -// StoreCommand is the entrypoint for the ocs command. -func StoreCommand(cfg *config.Config) *cli.Command { - - return &cli.Command{ - Name: cfg.Store.Service.Name, - Usage: helper.SubcommandDescription(cfg.Store.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Store.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Store), - } -} - -func init() { - register.AddCommand(StoreCommand) -} diff --git a/ocis/pkg/command/thumbnails.go b/ocis/pkg/command/thumbnails.go deleted file mode 100644 index 235edfafb..000000000 --- a/ocis/pkg/command/thumbnails.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/thumbnails/pkg/command" - "github.com/urfave/cli/v2" -) - -// ThumbnailsCommand is the entrypoint for the thumbnails command. -func ThumbnailsCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Thumbnails.Service.Name, - Usage: helper.SubcommandDescription(cfg.Thumbnails.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Thumbnails.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Thumbnails), - } -} - -func init() { - register.AddCommand(ThumbnailsCommand) -} diff --git a/ocis/pkg/command/userlog.go b/ocis/pkg/command/userlog.go deleted file mode 100644 index 363b7d30b..000000000 --- a/ocis/pkg/command/userlog.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/userlog/pkg/command" - "github.com/urfave/cli/v2" -) - -// UserlogCommand is the entrypoint for the userlog command. -func UserlogCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Userlog.Service.Name, - Usage: helper.SubcommandDescription(cfg.Userlog.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Userlog.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Userlog), - } -} - -func init() { - register.AddCommand(UserlogCommand) -} diff --git a/ocis/pkg/command/users.go b/ocis/pkg/command/users.go deleted file mode 100644 index 905c75718..000000000 --- a/ocis/pkg/command/users.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/users/pkg/command" - "github.com/urfave/cli/v2" -) - -// UsersCommand is the entrypoint for the users command. -func UsersCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Users.Service.Name, - Usage: helper.SubcommandDescription(cfg.Users.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Users.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Users), - } -} - -func init() { - register.AddCommand(UsersCommand) -} diff --git a/ocis/pkg/command/web.go b/ocis/pkg/command/web.go deleted file mode 100644 index e7b1f001d..000000000 --- a/ocis/pkg/command/web.go +++ /dev/null @@ -1,30 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/web/pkg/command" - "github.com/urfave/cli/v2" -) - -// WebCommand is the entrypoint for the web command. -func WebCommand(cfg *config.Config) *cli.Command { - return &cli.Command{ - Name: cfg.Web.Service.Name, - Usage: helper.SubcommandDescription(cfg.Web.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Web.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Web), - } -} - -func init() { - register.AddCommand(WebCommand) -} diff --git a/ocis/pkg/command/webdav.go b/ocis/pkg/command/webdav.go deleted file mode 100644 index 6acd8ec59..000000000 --- a/ocis/pkg/command/webdav.go +++ /dev/null @@ -1,31 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/webdav/pkg/command" - "github.com/urfave/cli/v2" -) - -// WebDAVCommand is the entrypoint for the webdav command. -func WebDAVCommand(cfg *config.Config) *cli.Command { - - return &cli.Command{ - Name: cfg.WebDAV.Service.Name, - Usage: helper.SubcommandDescription(cfg.WebDAV.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.WebDAV.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.WebDAV), - } -} - -func init() { - register.AddCommand(WebDAVCommand) -} diff --git a/ocis/pkg/command/webfinger.go b/ocis/pkg/command/webfinger.go deleted file mode 100644 index e01fde864..000000000 --- a/ocis/pkg/command/webfinger.go +++ /dev/null @@ -1,31 +0,0 @@ -package command - -import ( - "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" - "github.com/owncloud/ocis/v2/services/webfinger/pkg/command" - "github.com/urfave/cli/v2" -) - -// WebfingerCommand is the entrypoint for the webfinger command. -func WebfingerCommand(cfg *config.Config) *cli.Command { - - return &cli.Command{ - Name: cfg.Webfinger.Service.Name, - Usage: helper.SubcommandDescription(cfg.Webfinger.Service.Name), - Category: "services", - Before: func(c *cli.Context) error { - configlog.Error(parser.ParseConfig(cfg, true)) - cfg.Webfinger.Commons = cfg.Commons - return nil - }, - Subcommands: command.GetCommands(cfg.Webfinger), - } -} - -func init() { - register.AddCommand(WebfingerCommand) -} diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index eec8b87e9..c8531b69b 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -109,45 +109,195 @@ func NewService(options ...Option) (*Service, error) { cfg: opts.Config, } - s.ServicesRegistry[opts.Config.Settings.Service.Name] = settings.NewSutureService - s.ServicesRegistry[opts.Config.Nats.Service.Name] = nats.NewSutureService - s.ServicesRegistry[opts.Config.StorageSystem.Service.Name] = storageSystem.NewSutureService - s.ServicesRegistry[opts.Config.Graph.Service.Name] = graph.NewSutureService - s.ServicesRegistry[opts.Config.IDM.Service.Name] = idm.NewSutureService - s.ServicesRegistry[opts.Config.Invitations.Service.Name] = invitations.NewSutureService - s.ServicesRegistry[opts.Config.OCS.Service.Name] = ocs.NewSutureService - s.ServicesRegistry[opts.Config.Store.Service.Name] = store.NewSutureService - s.ServicesRegistry[opts.Config.Thumbnails.Service.Name] = thumbnails.NewSutureService - s.ServicesRegistry[opts.Config.Web.Service.Name] = web.NewSutureService - s.ServicesRegistry[opts.Config.WebDAV.Service.Name] = webdav.NewSutureService - s.ServicesRegistry[opts.Config.Webfinger.Service.Name] = webfinger.NewSutureService - s.ServicesRegistry[opts.Config.Frontend.Service.Name] = frontend.NewSutureService - s.ServicesRegistry[opts.Config.OCDav.Service.Name] = ocdav.NewSutureService - s.ServicesRegistry[opts.Config.Gateway.Service.Name] = gateway.NewSutureService - s.ServicesRegistry[opts.Config.AppRegistry.Service.Name] = appRegistry.NewSutureService - s.ServicesRegistry[opts.Config.Users.Service.Name] = users.NewSutureService - s.ServicesRegistry[opts.Config.Groups.Service.Name] = groups.NewSutureService - s.ServicesRegistry[opts.Config.AuthBasic.Service.Name] = authbasic.NewSutureService - s.ServicesRegistry[opts.Config.AuthMachine.Service.Name] = authmachine.NewSutureService - s.ServicesRegistry[opts.Config.StorageUsers.Service.Name] = storageusers.NewSutureService - s.ServicesRegistry[opts.Config.StorageShares.Service.Name] = storageshares.NewSutureService - s.ServicesRegistry[opts.Config.StoragePublicLink.Service.Name] = storagepublic.NewSutureService - s.ServicesRegistry[opts.Config.AppProvider.Service.Name] = appProvider.NewSutureService - s.ServicesRegistry[opts.Config.Notifications.Service.Name] = notifications.NewSutureService - s.ServicesRegistry[opts.Config.Search.Service.Name] = search.NewSutureService - s.ServicesRegistry[opts.Config.Postprocessing.Service.Name] = postprocessing.NewSutureService - s.ServicesRegistry[opts.Config.EventHistory.Service.Name] = eventhistory.NewSutureService - s.ServicesRegistry[opts.Config.Userlog.Service.Name] = userlog.NewSutureService + // populate services + reg := func(name string, exec func(context.Context, *ociscfg.Config) error) { + s.ServicesRegistry[name] = NewSutureServiceBuilder(exec) + } + reg(opts.Config.AppProvider.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.AppProvider.Context = ctx + cfg.AppProvider.Commons = cfg.Commons + return appProvider.Execute(cfg.AppProvider) + }) + reg(opts.Config.AppRegistry.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.AppRegistry.Context = ctx + cfg.AppRegistry.Commons = cfg.Commons + return appRegistry.Execute(cfg.AppRegistry) + }) + reg(opts.Config.AuthBasic.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.AuthBasic.Context = ctx + cfg.AuthBasic.Commons = cfg.Commons + return authbasic.Execute(cfg.AuthBasic) + }) + reg(opts.Config.AuthMachine.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.AuthMachine.Context = ctx + cfg.AuthMachine.Commons = cfg.Commons + return authmachine.Execute(cfg.AuthMachine) + }) + reg(opts.Config.EventHistory.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.EventHistory.Context = ctx + cfg.EventHistory.Commons = cfg.Commons + return eventhistory.Execute(cfg.EventHistory) + }) + reg(opts.Config.Frontend.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Frontend.Context = ctx + cfg.Frontend.Commons = cfg.Commons + return frontend.Execute(cfg.Frontend) + }) + reg(opts.Config.Gateway.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Gateway.Context = ctx + cfg.Gateway.Commons = cfg.Commons + return gateway.Execute(cfg.Gateway) + }) + reg(opts.Config.Graph.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Graph.Context = ctx + cfg.Graph.Commons = cfg.Commons + return graph.Execute(cfg.Graph) + }) + reg(opts.Config.Groups.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Groups.Context = ctx + cfg.Groups.Commons = cfg.Commons + return groups.Execute(cfg.Groups) + }) + reg(opts.Config.IDM.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.IDM.Context = ctx + cfg.IDM.Commons = cfg.Commons + return idm.Execute(cfg.IDM) + }) + reg(opts.Config.Invitations.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Invitations.Context = ctx + cfg.Invitations.Commons = cfg.Commons + return invitations.Execute(cfg.Invitations) + }) + reg(opts.Config.Nats.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Nats.Context = ctx + cfg.Nats.Commons = cfg.Commons + return nats.Execute(cfg.Nats) + }) + reg(opts.Config.Notifications.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Notifications.Context = ctx + cfg.Notifications.Commons = cfg.Commons + return notifications.Execute(cfg.Notifications) + }) + reg(opts.Config.OCDav.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.OCDav.Context = ctx + cfg.OCDav.Commons = cfg.Commons + return ocdav.Execute(cfg.OCDav) + }) + reg(opts.Config.OCS.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.OCS.Context = ctx + cfg.OCS.Commons = cfg.Commons + return ocs.Execute(cfg.OCS) + }) + reg(opts.Config.Postprocessing.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Postprocessing.Context = ctx + cfg.Postprocessing.Commons = cfg.Commons + return postprocessing.Execute(cfg.Postprocessing) + }) + reg(opts.Config.Search.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Search.Context = ctx + cfg.Search.Commons = cfg.Commons + return search.Execute(cfg.Search) + }) + reg(opts.Config.Settings.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Settings.Context = ctx + cfg.Settings.Commons = cfg.Commons + return settings.Execute(cfg.Settings) + }) + reg(opts.Config.StoragePublicLink.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.StoragePublicLink.Context = ctx + cfg.StoragePublicLink.Commons = cfg.Commons + return storagepublic.Execute(cfg.StoragePublicLink) + }) + reg(opts.Config.StorageShares.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.StorageShares.Context = ctx + cfg.StorageShares.Commons = cfg.Commons + return storageshares.Execute(cfg.StorageShares) + }) + reg(opts.Config.StorageSystem.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.StorageSystem.Context = ctx + cfg.StorageSystem.Commons = cfg.Commons + return storageSystem.Execute(cfg.StorageSystem) + }) + reg(opts.Config.StorageUsers.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.StorageUsers.Context = ctx + cfg.StorageUsers.Commons = cfg.Commons + return storageusers.Execute(cfg.StorageUsers) + }) + reg(opts.Config.Store.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Store.Context = ctx + cfg.Store.Commons = cfg.Commons + return store.Execute(cfg.Store) + }) + reg(opts.Config.Thumbnails.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Thumbnails.Context = ctx + cfg.Thumbnails.Commons = cfg.Commons + return thumbnails.Execute(cfg.Thumbnails) + }) + reg(opts.Config.Userlog.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Userlog.Context = ctx + cfg.Userlog.Commons = cfg.Commons + return userlog.Execute(cfg.Userlog) + }) + reg(opts.Config.Users.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Users.Context = ctx + cfg.Users.Commons = cfg.Commons + return users.Execute(cfg.Users) + }) + reg(opts.Config.Web.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Web.Context = ctx + cfg.Web.Commons = cfg.Commons + return web.Execute(cfg.Web) + }) + reg(opts.Config.WebDAV.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.WebDAV.Context = ctx + cfg.WebDAV.Commons = cfg.Commons + return webdav.Execute(cfg.WebDAV) + }) + reg(opts.Config.Webfinger.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Webfinger.Context = ctx + cfg.Webfinger.Commons = cfg.Commons + return webfinger.Execute(cfg.Webfinger) + }) // populate optional services - s.Additional[opts.Config.Antivirus.Service.Name] = antivirus.NewSutureService - s.Additional[opts.Config.Audit.Service.Name] = audit.NewSutureService - s.Additional[opts.Config.Policies.Service.Name] = policies.NewSutureService + areg := func(name string, exec func(context.Context, *ociscfg.Config) error) { + s.Additional[name] = NewSutureServiceBuilder(exec) + } + areg(opts.Config.Antivirus.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Antivirus.Context = ctx + // cfg.Antivirus.Commons = cfg.Commons // antivirus holds no Commons atm + return antivirus.Execute(cfg.Antivirus) + }) + areg(opts.Config.Audit.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Audit.Context = ctx + cfg.Audit.Commons = cfg.Commons + return audit.Execute(cfg.Audit) + }) + areg(opts.Config.Policies.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Policies.Context = ctx + cfg.Policies.Commons = cfg.Commons + return policies.Execute(cfg.Policies) + }) // populate delayed services - s.Delayed[opts.Config.Sharing.Service.Name] = sharing.NewSutureService - s.Delayed[opts.Config.Proxy.Service.Name] = proxy.NewSutureService - s.Delayed[opts.Config.IDP.Service.Name] = idp.NewSutureService + dreg := func(name string, exec func(context.Context, *ociscfg.Config) error) { + s.Delayed[name] = NewSutureServiceBuilder(exec) + } + dreg(opts.Config.IDP.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.IDP.Context = ctx + cfg.IDP.Commons = cfg.Commons + return idp.Execute(cfg.IDP) + }) + dreg(opts.Config.Proxy.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Proxy.Context = ctx + cfg.Proxy.Commons = cfg.Commons + return proxy.Execute(cfg.Proxy) + }) + dreg(opts.Config.Sharing.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error { + cfg.Sharing.Context = ctx + cfg.Sharing.Commons = cfg.Commons + return sharing.Execute(cfg.Sharing) + }) return s, nil } diff --git a/ocis/pkg/runtime/service/sutureservice.go b/ocis/pkg/runtime/service/sutureservice.go new file mode 100644 index 000000000..d0bc3e3bc --- /dev/null +++ b/ocis/pkg/runtime/service/sutureservice.go @@ -0,0 +1,29 @@ +package service + +import ( + "context" + + ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" + "github.com/thejerf/suture/v4" +) + +// SutureService allows for the settings command to be embedded and supervised by a suture supervisor tree. +type SutureService struct { + exec func(ctx context.Context) error +} + +// NewSutureServiceBuilder creates a new suture service +func NewSutureServiceBuilder(f func(context.Context, *ociscfg.Config) error) func(*ociscfg.Config) suture.Service { + return func(cfg *ociscfg.Config) suture.Service { + return SutureService{ + exec: func(ctx context.Context) error { + return f(ctx, cfg) + }, + } + } +} + +// Serve to fullfil Server interface +func (s SutureService) Serve(ctx context.Context) error { + return s.exec(ctx) +} diff --git a/services/antivirus/pkg/command/root.go b/services/antivirus/pkg/command/root.go index 5f35285c7..288448274 100644 --- a/services/antivirus/pkg/command/root.go +++ b/services/antivirus/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/antivirus/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -30,25 +27,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the web command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new web.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Policies.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Antivirus, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/app-provider/pkg/command/root.go b/services/app-provider/pkg/command/root.go index b981f0d82..d7bbe2bb4 100644 --- a/services/app-provider/pkg/command/root.go +++ b/services/app-provider/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/app-provider/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the app-provider command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new app-provider.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.AppProvider.Commons = cfg.Commons - return SutureService{ - cfg: cfg.AppProvider, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/app-registry/pkg/command/root.go b/services/app-registry/pkg/command/root.go index 3d20b9fd4..9f20d6051 100644 --- a/services/app-registry/pkg/command/root.go +++ b/services/app-registry/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/app-registry/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the app-registry command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new app-registry.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.AppRegistry.Commons = cfg.Commons - return SutureService{ - cfg: cfg.AppRegistry, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/audit/pkg/command/root.go b/services/audit/pkg/command/root.go index cfe85a709..abe6054a5 100644 --- a/services/audit/pkg/command/root.go +++ b/services/audit/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/audit/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,26 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the audit command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new audit.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Audit.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Audit, - } -} - -// Serve implements Server interface -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/auth-basic/pkg/command/root.go b/services/auth-basic/pkg/command/root.go index d7ba172de..cb53a0a66 100644 --- a/services/auth-basic/pkg/command/root.go +++ b/services/auth-basic/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the auth-basic command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new auth-basic.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.AuthBasic.Commons = cfg.Commons - return SutureService{ - cfg: cfg.AuthBasic, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/auth-machine/pkg/command/root.go b/services/auth-machine/pkg/command/root.go index fb01026af..fe153cd78 100644 --- a/services/auth-machine/pkg/command/root.go +++ b/services/auth-machine/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the auth-machine command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new auth-machine.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.AuthMachine.Commons = cfg.Commons - return SutureService{ - cfg: cfg.AuthMachine, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/eventhistory/pkg/command/root.go b/services/eventhistory/pkg/command/root.go index f2cf66389..683c716a3 100644 --- a/services/eventhistory/pkg/command/root.go +++ b/services/eventhistory/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/eventhistory/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the eventhistory command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new eventhistory.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.EventHistory.Commons = cfg.Commons - return SutureService{ - cfg: cfg.EventHistory, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/frontend/pkg/command/root.go b/services/frontend/pkg/command/root.go index 4feac04e0..ab4fd0452 100644 --- a/services/frontend/pkg/command/root.go +++ b/services/frontend/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/frontend/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the frontend command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new frontend.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Frontend.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Frontend, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/gateway/pkg/command/root.go b/services/gateway/pkg/command/root.go index fe058b917..fcf6db18d 100644 --- a/services/gateway/pkg/command/root.go +++ b/services/gateway/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/gateway/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the gateway command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new gateway.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Gateway.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Gateway, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/graph/pkg/command/root.go b/services/graph/pkg/command/root.go index 73b42c6d1..5c9fae289 100644 --- a/services/graph/pkg/command/root.go +++ b/services/graph/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - "github.com/thejerf/suture/v4" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/graph/pkg/config" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { }) return app.Run(os.Args) } - -// SutureService allows for the graph command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new graph.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Graph.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Graph, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/groups/pkg/command/root.go b/services/groups/pkg/command/root.go index 4a7578fc5..fdc14e685 100644 --- a/services/groups/pkg/command/root.go +++ b/services/groups/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/groups/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the group command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new group.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Groups.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Groups, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/idm/pkg/command/root.go b/services/idm/pkg/command/root.go index ee1ccb95d..85134a437 100644 --- a/services/idm/pkg/command/root.go +++ b/services/idm/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/idm/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -36,25 +33,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the idm command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new idm.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.IDM.Commons = cfg.Commons - return SutureService{ - cfg: cfg.IDM, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/idp/pkg/command/root.go b/services/idp/pkg/command/root.go index 9b3960579..724620d7d 100644 --- a/services/idp/pkg/command/root.go +++ b/services/idp/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/idp/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the idp command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new idp.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.IDP.Commons = cfg.Commons - return SutureService{ - cfg: cfg.IDP, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/invitations/pkg/command/root.go b/services/invitations/pkg/command/root.go index dde703557..aa8c993ab 100644 --- a/services/invitations/pkg/command/root.go +++ b/services/invitations/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/invitations/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the webdav command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new webdav.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Invitations.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Invitations, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/nats/pkg/command/root.go b/services/nats/pkg/command/root.go index 583d2658d..067bd39cd 100644 --- a/services/nats/pkg/command/root.go +++ b/services/nats/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/nats/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the nats command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new nats.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Nats.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Nats, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/notifications/pkg/command/root.go b/services/notifications/pkg/command/root.go index 72c7dfda2..aa048245a 100644 --- a/services/notifications/pkg/command/root.go +++ b/services/notifications/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/notifications/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the notifications command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new notifications.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Notifications.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Notifications, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/ocdav/pkg/command/root.go b/services/ocdav/pkg/command/root.go index 95de57e24..5b1afc5b3 100644 --- a/services/ocdav/pkg/command/root.go +++ b/services/ocdav/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/ocdav/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the ocdav command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new ocdav.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.OCDav.Commons = cfg.Commons - return SutureService{ - cfg: cfg.OCDav, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/ocs/pkg/command/root.go b/services/ocs/pkg/command/root.go index 6d87fb6f2..569ff06ab 100644 --- a/services/ocs/pkg/command/root.go +++ b/services/ocs/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/ocs/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the ocs command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new ocs.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.OCS.Commons = cfg.Commons - return SutureService{ - cfg: cfg.OCS, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/policies/pkg/command/root.go b/services/policies/pkg/command/root.go index b57f8aa62..368ca7657 100644 --- a/services/policies/pkg/command/root.go +++ b/services/policies/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/policies/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -30,25 +27,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the web command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new web.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Policies.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Policies, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/postprocessing/pkg/command/root.go b/services/postprocessing/pkg/command/root.go index 0b558d9b7..4718a58bd 100644 --- a/services/postprocessing/pkg/command/root.go +++ b/services/postprocessing/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/postprocessing/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,22 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the postprocessing command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new postprocessing.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Postprocessing.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Postprocessing, - } -} - -// Serve to implement Server interface -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - return Execute(s.cfg) -} diff --git a/services/proxy/pkg/command/root.go b/services/proxy/pkg/command/root.go index 4c310fc67..65d32b575 100644 --- a/services/proxy/pkg/command/root.go +++ b/services/proxy/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/proxy/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the proxy command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new proxy.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Proxy.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Proxy, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/search/pkg/command/root.go b/services/search/pkg/command/root.go index 9bed2b315..e850b3612 100644 --- a/services/search/pkg/command/root.go +++ b/services/search/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - "github.com/thejerf/suture/v4" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/search/pkg/config" "github.com/urfave/cli/v2" ) @@ -36,25 +33,3 @@ func Execute(cfg *config.Config) error { }) return app.Run(os.Args) } - -// SutureService allows for the search command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new search.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Search.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Search, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/settings/pkg/command/root.go b/services/settings/pkg/command/root.go index 29812fe05..641cf491c 100644 --- a/services/settings/pkg/command/root.go +++ b/services/settings/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/settings/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the settings command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new settings.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Settings.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Settings, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/sharing/pkg/command/root.go b/services/sharing/pkg/command/root.go index 406e09b6f..fba13bf90 100644 --- a/services/sharing/pkg/command/root.go +++ b/services/sharing/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/sharing/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the sharing command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new sharing.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Sharing.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Sharing, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/storage-publiclink/pkg/command/root.go b/services/storage-publiclink/pkg/command/root.go index 141d7ac6d..9ca05cc71 100644 --- a/services/storage-publiclink/pkg/command/root.go +++ b/services/storage-publiclink/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the accounts command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new accounts.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.StoragePublicLink.Commons = cfg.Commons - return SutureService{ - cfg: cfg.StoragePublicLink, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/storage-shares/pkg/command/root.go b/services/storage-shares/pkg/command/root.go index faf2066e6..fd36affa1 100644 --- a/services/storage-shares/pkg/command/root.go +++ b/services/storage-shares/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the accounts command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new storage-shares.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.StorageShares.Commons = cfg.Commons - return SutureService{ - cfg: cfg.StorageShares, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/storage-system/pkg/command/root.go b/services/storage-system/pkg/command/root.go index 0f1cde0b6..92b6e757a 100644 --- a/services/storage-system/pkg/command/root.go +++ b/services/storage-system/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/storage-system/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the storage-system command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new storage-system.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.StorageSystem.Commons = cfg.Commons - return SutureService{ - cfg: cfg.StorageSystem, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/storage-users/pkg/command/root.go b/services/storage-users/pkg/command/root.go index 848e866c7..777ec6f2f 100644 --- a/services/storage-users/pkg/command/root.go +++ b/services/storage-users/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -37,25 +34,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the accounts command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new storage-users.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.StorageUsers.Commons = cfg.Commons - return SutureService{ - cfg: cfg.StorageUsers, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/store/pkg/command/root.go b/services/store/pkg/command/root.go index 795a66a74..8e208dba5 100644 --- a/services/store/pkg/command/root.go +++ b/services/store/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/store/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the store command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new store.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Store.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Store, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/thumbnails/pkg/command/root.go b/services/thumbnails/pkg/command/root.go index 28588a261..8ddf1c23d 100644 --- a/services/thumbnails/pkg/command/root.go +++ b/services/thumbnails/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the thumbnails command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new thumbnails.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Thumbnails.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Thumbnails, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/userlog/pkg/command/root.go b/services/userlog/pkg/command/root.go index 4a7e79839..dd80e5acb 100644 --- a/services/userlog/pkg/command/root.go +++ b/services/userlog/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/userlog/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the userlog command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new userlog.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Userlog.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Userlog, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/users/pkg/command/root.go b/services/users/pkg/command/root.go index c84c93603..e0039b1c3 100644 --- a/services/users/pkg/command/root.go +++ b/services/users/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/users/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the user command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new user.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Users.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Users, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/web/pkg/command/root.go b/services/web/pkg/command/root.go index 7dfe694e2..91a648c1a 100644 --- a/services/web/pkg/command/root.go +++ b/services/web/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/web/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the web command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new web.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Web.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Web, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/webdav/pkg/command/root.go b/services/webdav/pkg/command/root.go index fd1255911..8a1d46b23 100644 --- a/services/webdav/pkg/command/root.go +++ b/services/webdav/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/webdav/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the webdav command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new webdav.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.WebDAV.Commons = cfg.Commons - return SutureService{ - cfg: cfg.WebDAV, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -} diff --git a/services/webfinger/pkg/command/root.go b/services/webfinger/pkg/command/root.go index 306f33b9b..4d553a265 100644 --- a/services/webfinger/pkg/command/root.go +++ b/services/webfinger/pkg/command/root.go @@ -1,13 +1,10 @@ package command import ( - "context" "os" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" - ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/services/webfinger/pkg/config" - "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -35,25 +32,3 @@ func Execute(cfg *config.Config) error { return app.Run(os.Args) } - -// SutureService allows for the webdav command to be embedded and supervised by a suture supervisor tree. -type SutureService struct { - cfg *config.Config -} - -// NewSutureService creates a new webdav.SutureService -func NewSutureService(cfg *ociscfg.Config) suture.Service { - cfg.Webfinger.Commons = cfg.Commons - return SutureService{ - cfg: cfg.Webfinger, - } -} - -func (s SutureService) Serve(ctx context.Context) error { - s.cfg.Context = ctx - if err := Execute(s.cfg); err != nil { - return err - } - - return nil -}