package command import ( "fmt" "github.com/qsfera/server/qsfera/pkg/register" "github.com/qsfera/server/pkg/config" "github.com/qsfera/server/pkg/config/configlog" "github.com/qsfera/server/pkg/config/parser" activitylog "github.com/qsfera/server/services/activitylog/pkg/command" antivirus "github.com/qsfera/server/services/antivirus/pkg/command" appprovider "github.com/qsfera/server/services/app-provider/pkg/command" appregistry "github.com/qsfera/server/services/app-registry/pkg/command" audit "github.com/qsfera/server/services/audit/pkg/command" authapp "github.com/qsfera/server/services/auth-app/pkg/command" authbasic "github.com/qsfera/server/services/auth-basic/pkg/command" authbearer "github.com/qsfera/server/services/auth-bearer/pkg/command" authmachine "github.com/qsfera/server/services/auth-machine/pkg/command" authservice "github.com/qsfera/server/services/auth-service/pkg/command" clientlog "github.com/qsfera/server/services/clientlog/pkg/command" collaboration "github.com/qsfera/server/services/collaboration/pkg/command" eventhistory "github.com/qsfera/server/services/eventhistory/pkg/command" frontend "github.com/qsfera/server/services/frontend/pkg/command" gateway "github.com/qsfera/server/services/gateway/pkg/command" graph "github.com/qsfera/server/services/graph/pkg/command" groups "github.com/qsfera/server/services/groups/pkg/command" idm "github.com/qsfera/server/services/idm/pkg/command" idp "github.com/qsfera/server/services/idp/pkg/command" invitations "github.com/qsfera/server/services/invitations/pkg/command" nats "github.com/qsfera/server/services/nats/pkg/command" notifications "github.com/qsfera/server/services/notifications/pkg/command" ocm "github.com/qsfera/server/services/ocm/pkg/command" ocs "github.com/qsfera/server/services/ocs/pkg/command" policies "github.com/qsfera/server/services/policies/pkg/command" postprocessing "github.com/qsfera/server/services/postprocessing/pkg/command" proxy "github.com/qsfera/server/services/proxy/pkg/command" search "github.com/qsfera/server/services/search/pkg/command" settings "github.com/qsfera/server/services/settings/pkg/command" sharing "github.com/qsfera/server/services/sharing/pkg/command" sse "github.com/qsfera/server/services/sse/pkg/command" storagepubliclink "github.com/qsfera/server/services/storage-publiclink/pkg/command" storageshares "github.com/qsfera/server/services/storage-shares/pkg/command" storagesystem "github.com/qsfera/server/services/storage-system/pkg/command" storageusers "github.com/qsfera/server/services/storage-users/pkg/command" thumbnails "github.com/qsfera/server/services/thumbnails/pkg/command" userlog "github.com/qsfera/server/services/userlog/pkg/command" users "github.com/qsfera/server/services/users/pkg/command" web "github.com/qsfera/server/services/web/pkg/command" webdav "github.com/qsfera/server/services/webdav/pkg/command" webfinger "github.com/qsfera/server/services/webfinger/pkg/command" "github.com/spf13/cobra" ) var serviceCommands = []register.Command{ func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Activitylog.Service.Name, activitylog.GetCommands(cfg.Activitylog), func(c *config.Config) { cfg.Activitylog.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Antivirus.Service.Name, antivirus.GetCommands(cfg.Antivirus), func(c *config.Config) { cfg.Antivirus.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.AppProvider.Service.Name, appprovider.GetCommands(cfg.AppProvider), func(c *config.Config) { cfg.AppProvider.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.AppRegistry.Service.Name, appregistry.GetCommands(cfg.AppRegistry), func(c *config.Config) { cfg.AppRegistry.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Audit.Service.Name, audit.GetCommands(cfg.Audit), func(c *config.Config) { cfg.Audit.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.AuthApp.Service.Name, authapp.GetCommands(cfg.AuthApp), func(_ *config.Config) { cfg.AuthApp.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.AuthBasic.Service.Name, authbasic.GetCommands(cfg.AuthBasic), func(c *config.Config) { cfg.AuthBasic.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.AuthBearer.Service.Name, authbearer.GetCommands(cfg.AuthBearer), func(c *config.Config) { cfg.AuthBearer.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.AuthMachine.Service.Name, authmachine.GetCommands(cfg.AuthMachine), func(c *config.Config) { cfg.AuthMachine.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.AuthService.Service.Name, authservice.GetCommands(cfg.AuthService), func(c *config.Config) { cfg.AuthService.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Clientlog.Service.Name, clientlog.GetCommands(cfg.Clientlog), func(c *config.Config) { cfg.Clientlog.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Collaboration.Service.Name, collaboration.GetCommands(cfg.Collaboration), func(c *config.Config) { cfg.Collaboration.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.EventHistory.Service.Name, eventhistory.GetCommands(cfg.EventHistory), func(c *config.Config) { cfg.EventHistory.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Frontend.Service.Name, frontend.GetCommands(cfg.Frontend), func(c *config.Config) { cfg.Frontend.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Gateway.Service.Name, gateway.GetCommands(cfg.Gateway), func(c *config.Config) { cfg.Gateway.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Graph.Service.Name, graph.GetCommands(cfg.Graph), func(c *config.Config) { cfg.Graph.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Groups.Service.Name, groups.GetCommands(cfg.Groups), func(c *config.Config) { cfg.Groups.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.IDM.Service.Name, idm.GetCommands(cfg.IDM), func(c *config.Config) { cfg.IDM.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.IDP.Service.Name, idp.GetCommands(cfg.IDP), func(c *config.Config) { cfg.IDP.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Invitations.Service.Name, invitations.GetCommands(cfg.Invitations), func(c *config.Config) { cfg.Invitations.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Nats.Service.Name, nats.GetCommands(cfg.Nats), func(c *config.Config) { cfg.Nats.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Notifications.Service.Name, notifications.GetCommands(cfg.Notifications), func(c *config.Config) { cfg.Notifications.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.OCM.Service.Name, ocm.GetCommands(cfg.OCM), func(c *config.Config) { cfg.OCM.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.OCS.Service.Name, ocs.GetCommands(cfg.OCS), func(c *config.Config) { cfg.OCS.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Policies.Service.Name, policies.GetCommands(cfg.Policies), func(c *config.Config) { cfg.Policies.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Postprocessing.Service.Name, postprocessing.GetCommands(cfg.Postprocessing), func(c *config.Config) { cfg.Postprocessing.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Proxy.Service.Name, proxy.GetCommands(cfg.Proxy), func(c *config.Config) { cfg.Proxy.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Search.Service.Name, search.GetCommands(cfg.Search), func(c *config.Config) { cfg.Search.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Settings.Service.Name, settings.GetCommands(cfg.Settings), func(c *config.Config) { cfg.Settings.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Sharing.Service.Name, sharing.GetCommands(cfg.Sharing), func(c *config.Config) { cfg.Sharing.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.SSE.Service.Name, sse.GetCommands(cfg.SSE), func(c *config.Config) { cfg.SSE.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.StoragePublicLink.Service.Name, storagepubliclink.GetCommands(cfg.StoragePublicLink), func(c *config.Config) { cfg.StoragePublicLink.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.StorageShares.Service.Name, storageshares.GetCommands(cfg.StorageShares), func(c *config.Config) { cfg.StorageShares.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.StorageSystem.Service.Name, storagesystem.GetCommands(cfg.StorageSystem), func(c *config.Config) { cfg.StorageSystem.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.StorageUsers.Service.Name, storageusers.GetCommands(cfg.StorageUsers), func(c *config.Config) { cfg.StorageUsers.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Thumbnails.Service.Name, thumbnails.GetCommands(cfg.Thumbnails), func(c *config.Config) { cfg.Thumbnails.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Userlog.Service.Name, userlog.GetCommands(cfg.Userlog), func(c *config.Config) { cfg.Userlog.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Users.Service.Name, users.GetCommands(cfg.Users), func(c *config.Config) { cfg.Users.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Web.Service.Name, web.GetCommands(cfg.Web), func(c *config.Config) { cfg.Web.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.WebDAV.Service.Name, webdav.GetCommands(cfg.WebDAV), func(c *config.Config) { cfg.WebDAV.Commons = cfg.Commons }) }, func(cfg *config.Config) *cobra.Command { return ServiceCommand(cfg, cfg.Webfinger.Service.Name, webfinger.GetCommands(cfg.Webfinger), func(c *config.Config) { cfg.Webfinger.Commons = cfg.Commons }) }, } // ServiceCommand composes a cobra command from the given inputs. func ServiceCommand(cfg *config.Config, serviceName string, subCommands []*cobra.Command, f func(*config.Config)) *cobra.Command { command := &cobra.Command{ Use: serviceName, Short: fmt.Sprintf("%s service commands", serviceName), GroupID: CommandGroupServices, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { configlog.Error(parser.ParseConfig(cfg, true)) f(cfg) return nil }, } command.AddCommand(subCommands...) return command } func init() { for _, c := range serviceCommands { register.AddCommand(c) } }