From 2e28582c1bd8cc3ebeb66a44e32a74275c9875c5 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Tue, 29 Jun 2021 15:28:19 +0200 Subject: [PATCH 1/6] cherrypick extensions to start v1 --- accounts/pkg/flagset/flagset.go | 4 +++ glauth/pkg/flagset/flagset.go | 4 +++ graph-explorer/pkg/flagset/flagset.go | 4 +++ graph/pkg/flagset/flagset.go | 4 +++ idp/pkg/flagset/flagset.go | 4 +++ ocis-pkg/config/config.go | 5 +-- ocis/pkg/flagset/flagset.go | 7 ++++ ocis/pkg/runtime/service/service.go | 44 +++++++++++++++++++++-- ocs/pkg/flagset/flagset.go | 4 +++ onlyoffice/pkg/flagset/flagset.go | 4 +++ proxy/pkg/flagset/flagset.go | 4 +++ settings/pkg/flagset/flagset.go | 4 +++ storage/pkg/flagset/authbasic.go | 1 + storage/pkg/flagset/authbearer.go | 1 + storage/pkg/flagset/drivereos.go | 4 +++ storage/pkg/flagset/driverlocal.go | 4 +++ storage/pkg/flagset/driverocis.go | 4 +++ storage/pkg/flagset/driverowncloud.go | 4 +++ storage/pkg/flagset/drivers3ng.go | 4 +++ storage/pkg/flagset/frontend.go | 1 + storage/pkg/flagset/gateway.go | 1 + storage/pkg/flagset/groups.go | 1 + storage/pkg/flagset/ldap.go | 4 +++ storage/pkg/flagset/rest.go | 4 +++ storage/pkg/flagset/root.go | 4 +++ storage/pkg/flagset/runtime_extensions.go | 16 +++++++++ storage/pkg/flagset/sharing.go | 1 + storage/pkg/flagset/sharingsql.go | 4 +++ storage/pkg/flagset/storagehome.go | 1 + storage/pkg/flagset/storagemetadata.go | 2 ++ storage/pkg/flagset/storagepubliclink.go | 1 + storage/pkg/flagset/storageusers.go | 1 + storage/pkg/flagset/users.go | 1 + thumbnails/pkg/flagset/flagset.go | 4 +++ 34 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 storage/pkg/flagset/runtime_extensions.go diff --git a/accounts/pkg/flagset/flagset.go b/accounts/pkg/flagset/flagset.go index 9542d75c32..733ed3d257 100644 --- a/accounts/pkg/flagset/flagset.go +++ b/accounts/pkg/flagset/flagset.go @@ -28,6 +28,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"ACCOUNTS_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/glauth/pkg/flagset/flagset.go b/glauth/pkg/flagset/flagset.go index d3bc91a002..fc3ae3cfb9 100644 --- a/glauth/pkg/flagset/flagset.go +++ b/glauth/pkg/flagset/flagset.go @@ -30,6 +30,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"GLAUTH_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/graph-explorer/pkg/flagset/flagset.go b/graph-explorer/pkg/flagset/flagset.go index baa5723f2e..c17f9049ec 100644 --- a/graph-explorer/pkg/flagset/flagset.go +++ b/graph-explorer/pkg/flagset/flagset.go @@ -27,6 +27,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"GRAPH_EXPLORER_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/graph/pkg/flagset/flagset.go b/graph/pkg/flagset/flagset.go index 8b96cbf372..a2caad8cd5 100644 --- a/graph/pkg/flagset/flagset.go +++ b/graph/pkg/flagset/flagset.go @@ -34,6 +34,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"GRAPH_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/idp/pkg/flagset/flagset.go b/idp/pkg/flagset/flagset.go index 9b4c154377..56a8efe524 100644 --- a/idp/pkg/flagset/flagset.go +++ b/idp/pkg/flagset/flagset.go @@ -30,6 +30,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"IDP_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/ocis-pkg/config/config.go b/ocis-pkg/config/config.go index b6a652e609..5c392471a1 100644 --- a/ocis-pkg/config/config.go +++ b/ocis-pkg/config/config.go @@ -70,8 +70,9 @@ type Mode int // Runtime configures the oCIS runtime when running in supervised mode. type Runtime struct { - Port string - Host string + Port string + Host string + Extensions string } // Config combines all available configuration parts. diff --git a/ocis/pkg/flagset/flagset.go b/ocis/pkg/flagset/flagset.go index 1267d64753..e9dd545349 100644 --- a/ocis/pkg/flagset/flagset.go +++ b/ocis/pkg/flagset/flagset.go @@ -162,5 +162,12 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"OCIS_GRPC_ADDR"}, Destination: &cfg.GRPC.Addr, }, + &cli.StringFlag{ + Name: "extensions", + Aliases: []string{"e"}, + Usage: "Run specific extensions during supervised mode", + EnvVars: []string{"OCIS_RUN_EXTENSIONS"}, + Destination: &cfg.Runtime.Extensions, + }, } } diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 268d7473fd..f3ab451200 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -22,6 +22,7 @@ import ( graphExplorer "github.com/owncloud/ocis/graph-explorer/pkg/command" graph "github.com/owncloud/ocis/graph/pkg/command" idp "github.com/owncloud/ocis/idp/pkg/command" + "github.com/owncloud/ocis/ocis-pkg/config" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" ocs "github.com/owncloud/ocis/ocs/pkg/command" @@ -37,6 +38,11 @@ import ( "github.com/thejerf/suture/v4" ) +var ( + // runset keeps track of which extensions to start supervised. + runset []string +) + // Service represents a RPC service. type Service struct { Supervisor *suture.Supervisor @@ -180,7 +186,18 @@ func Start(o ...Option) error { } }() - for name := range s.ServicesRegistry { + // prepare runset + s.generateRunSet(s.cfg) + + for _, name := range runset { + + // skip delayed services for now + if _, ok := s.Delayed[name]; ok { + continue + } + + // we do this so each service has its own copy. In a perfect world a config object should NOT be edited by + // the callers because this might trigger behavioral changes up the tree. swap := deepcopy.Copy(s.cfg) s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](swap.(*ociscfg.Config)))) } @@ -198,7 +215,12 @@ func Start(o ...Option) error { time.Sleep(1 * time.Second) // add services with delayed execution. - for name := range s.Delayed { + for _, name := range runset { + // this time around only run delayed jobs + if _, ok := s.Delayed[name]; !ok { + continue + } + swap := deepcopy.Copy(s.cfg) s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](swap.(*ociscfg.Config)))) } @@ -206,6 +228,24 @@ func Start(o ...Option) error { return http.Serve(l, nil) } +func (s *Service) generateRunSet(cfg *config.Config) { + if cfg.Runtime.Extensions != "" { + e := strings.Split(strings.Replace(cfg.Runtime.Extensions, " ", "", -1), ",") + for i := range e { + runset = append(runset, e[i]) + } + return + } + + for name := range s.ServicesRegistry { + runset = append(runset, name) + } + + for name := range s.Delayed { + runset = append(runset, name) + } +} + // Start indicates the Service Controller to start a new supervised service as an OS thread. func (s *Service) Start(name string, reply *int) error { // RPC calls to a Service object will allow for parsing config. Mind that since the runtime is running on a different diff --git a/ocs/pkg/flagset/flagset.go b/ocs/pkg/flagset/flagset.go index a5e69d7fca..e3ee4e4c24 100644 --- a/ocs/pkg/flagset/flagset.go +++ b/ocs/pkg/flagset/flagset.go @@ -179,6 +179,10 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"OCS_STORAGE_USERS_DRIVER", "STORAGE_USERS_DRIVER"}, Destination: &cfg.StorageUsersDriver, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/onlyoffice/pkg/flagset/flagset.go b/onlyoffice/pkg/flagset/flagset.go index d8a59bd5ae..fe630095be 100644 --- a/onlyoffice/pkg/flagset/flagset.go +++ b/onlyoffice/pkg/flagset/flagset.go @@ -34,6 +34,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"ONLYOFFICE_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/proxy/pkg/flagset/flagset.go b/proxy/pkg/flagset/flagset.go index 87ad472d44..b2cbd818e3 100644 --- a/proxy/pkg/flagset/flagset.go +++ b/proxy/pkg/flagset/flagset.go @@ -30,6 +30,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"PROXY_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/settings/pkg/flagset/flagset.go b/settings/pkg/flagset/flagset.go index 8aa7a5aab6..b5d0f64b26 100644 --- a/settings/pkg/flagset/flagset.go +++ b/settings/pkg/flagset/flagset.go @@ -27,6 +27,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"SETTINGS_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/authbasic.go b/storage/pkg/flagset/authbasic.go index 4f5ae182b8..dbf19c67d6 100644 --- a/storage/pkg/flagset/authbasic.go +++ b/storage/pkg/flagset/authbasic.go @@ -76,6 +76,7 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) flags = append(flags, LDAPWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/authbearer.go b/storage/pkg/flagset/authbearer.go index d35e3bd2ea..863807c8ee 100644 --- a/storage/pkg/flagset/authbearer.go +++ b/storage/pkg/flagset/authbearer.go @@ -102,6 +102,7 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, TracingWithConfig(cfg)...) flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/drivereos.go b/storage/pkg/flagset/drivereos.go index 416a433ee0..da130a628e 100644 --- a/storage/pkg/flagset/drivereos.go +++ b/storage/pkg/flagset/drivereos.go @@ -131,5 +131,9 @@ func DriverEOSWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_EOS_GATEWAYSVC"}, Destination: &cfg.Reva.Storages.EOS.GatewaySVC, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/driverlocal.go b/storage/pkg/flagset/driverlocal.go index 256d117e9c..86f2e1e789 100644 --- a/storage/pkg/flagset/driverlocal.go +++ b/storage/pkg/flagset/driverlocal.go @@ -16,5 +16,9 @@ func DriverLocalWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_LOCAL_ROOT"}, Destination: &cfg.Reva.Storages.Local.Root, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/driverocis.go b/storage/pkg/flagset/driverocis.go index 75f80caaae..90cee48e05 100644 --- a/storage/pkg/flagset/driverocis.go +++ b/storage/pkg/flagset/driverocis.go @@ -37,5 +37,9 @@ func DriverOCISWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_OCIS_SERVICE_USER_UUID"}, Destination: &cfg.Reva.Storages.OCIS.ServiceUserUUID, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/driverowncloud.go b/storage/pkg/flagset/driverowncloud.go index 65dfd183ec..faf532c7d0 100644 --- a/storage/pkg/flagset/driverowncloud.go +++ b/storage/pkg/flagset/driverowncloud.go @@ -58,5 +58,9 @@ func DriverOwnCloudWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_OWNCLOUD_LAYOUT"}, Destination: &cfg.Reva.Storages.OwnCloud.UserLayout, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/drivers3ng.go b/storage/pkg/flagset/drivers3ng.go index b755ac28ea..6384b2c6be 100644 --- a/storage/pkg/flagset/drivers3ng.go +++ b/storage/pkg/flagset/drivers3ng.go @@ -65,5 +65,9 @@ func DriverS3NGWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_S3NG_BUCKET"}, Destination: &cfg.Reva.Storages.S3NG.Bucket, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/frontend.go b/storage/pkg/flagset/frontend.go index e872cfdf29..cfd6fd620c 100644 --- a/storage/pkg/flagset/frontend.go +++ b/storage/pkg/flagset/frontend.go @@ -183,6 +183,7 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, TracingWithConfig(cfg)...) flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/gateway.go b/storage/pkg/flagset/gateway.go index af603478fe..241d31bd79 100644 --- a/storage/pkg/flagset/gateway.go +++ b/storage/pkg/flagset/gateway.go @@ -264,6 +264,7 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, TracingWithConfig(cfg)...) flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/groups.go b/storage/pkg/flagset/groups.go index cde2810206..71cc96666f 100644 --- a/storage/pkg/flagset/groups.go +++ b/storage/pkg/flagset/groups.go @@ -79,6 +79,7 @@ func GroupsWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, SecretWithConfig(cfg)...) flags = append(flags, LDAPWithConfig(cfg)...) flags = append(flags, RestWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/ldap.go b/storage/pkg/flagset/ldap.go index b5f069a45b..2a2cacf281 100644 --- a/storage/pkg/flagset/ldap.go +++ b/storage/pkg/flagset/ldap.go @@ -208,5 +208,9 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_LDAP_GROUP_SCHEMA_GID_NUMBER"}, Destination: &cfg.Reva.LDAP.GroupSchema.GIDNumber, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/rest.go b/storage/pkg/flagset/rest.go index 34980637e2..977eca8b64 100644 --- a/storage/pkg/flagset/rest.go +++ b/storage/pkg/flagset/rest.go @@ -72,5 +72,9 @@ func RestWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_REST_TARGET_API"}, Destination: &cfg.Reva.UserGroupRest.TargetAPI, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/root.go b/storage/pkg/flagset/root.go index c2aaa30239..af2357bd61 100644 --- a/storage/pkg/flagset/root.go +++ b/storage/pkg/flagset/root.go @@ -33,5 +33,9 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/runtime_extensions.go b/storage/pkg/flagset/runtime_extensions.go new file mode 100644 index 0000000000..7805d96242 --- /dev/null +++ b/storage/pkg/flagset/runtime_extensions.go @@ -0,0 +1,16 @@ +package flagset + +import ( + "github.com/micro/cli/v2" + "github.com/owncloud/ocis/storage/pkg/config" +) + +// RuntimeConfig applies common debug config cfg to the flagset +func RuntimeConfig(cfg *config.Config) []cli.Flag { + return []cli.Flag{ + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, + } +} diff --git a/storage/pkg/flagset/sharing.go b/storage/pkg/flagset/sharing.go index b9a1d989e0..da1754e080 100644 --- a/storage/pkg/flagset/sharing.go +++ b/storage/pkg/flagset/sharing.go @@ -98,6 +98,7 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) flags = append(flags, SharingSQLWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/sharingsql.go b/storage/pkg/flagset/sharingsql.go index e4770b4a9a..938d24f4f1 100644 --- a/storage/pkg/flagset/sharingsql.go +++ b/storage/pkg/flagset/sharingsql.go @@ -44,5 +44,9 @@ func SharingSQLWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_SHARING_USER_SQL_NAME"}, Destination: &cfg.Reva.Sharing.UserSQLName, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/storagehome.go b/storage/pkg/flagset/storagehome.go index 1536795865..c090951ab4 100644 --- a/storage/pkg/flagset/storagehome.go +++ b/storage/pkg/flagset/storagehome.go @@ -157,6 +157,7 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, DriverOwnCloudWithConfig(cfg)...) flags = append(flags, DriverOCISWithConfig(cfg)...) flags = append(flags, DriverS3NGWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/storagemetadata.go b/storage/pkg/flagset/storagemetadata.go index fe28e00241..21edf4e2b5 100644 --- a/storage/pkg/flagset/storagemetadata.go +++ b/storage/pkg/flagset/storagemetadata.go @@ -106,6 +106,8 @@ func StorageMetadata(cfg *config.Config) []cli.Flag { f = append(f, DriverOwnCloudWithConfig(cfg)...) f = append(f, DriverOCISWithConfig(cfg)...) f = append(f, DriverS3NGWithConfig(cfg)...) + f = append(f, RuntimeConfig(cfg)...) + return f } diff --git a/storage/pkg/flagset/storagepubliclink.go b/storage/pkg/flagset/storagepubliclink.go index eefc636a3a..05eff876bd 100644 --- a/storage/pkg/flagset/storagepubliclink.go +++ b/storage/pkg/flagset/storagepubliclink.go @@ -53,6 +53,7 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag { flags = append(flags, TracingWithConfig(cfg)...) flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/storageusers.go b/storage/pkg/flagset/storageusers.go index eaf18cd184..a7618373c0 100644 --- a/storage/pkg/flagset/storageusers.go +++ b/storage/pkg/flagset/storageusers.go @@ -147,6 +147,7 @@ func StorageUsersWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, DriverOwnCloudWithConfig(cfg)...) flags = append(flags, DriverOCISWithConfig(cfg)...) flags = append(flags, DriverS3NGWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/users.go b/storage/pkg/flagset/users.go index 091cefb121..3a335f2a12 100644 --- a/storage/pkg/flagset/users.go +++ b/storage/pkg/flagset/users.go @@ -79,6 +79,7 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, SecretWithConfig(cfg)...) flags = append(flags, LDAPWithConfig(cfg)...) flags = append(flags, RestWithConfig(cfg)...) + flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/thumbnails/pkg/flagset/flagset.go b/thumbnails/pkg/flagset/flagset.go index c1c68b8aa1..b020149aa7 100644 --- a/thumbnails/pkg/flagset/flagset.go +++ b/thumbnails/pkg/flagset/flagset.go @@ -169,6 +169,10 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"}, Destination: &cfg.Thumbnail.WebdavNamespace, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } From 72f6a3613ae621e60c5a686c79ce148f973f330b Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Tue, 29 Jun 2021 15:43:59 +0200 Subject: [PATCH 2/6] fix storage subcommands --- accounts/pkg/flagset/flagset.go | 4 ++++ storage/pkg/flagset/authbasic.go | 1 - storage/pkg/flagset/authbearer.go | 1 - storage/pkg/flagset/drivereos.go | 4 ---- storage/pkg/flagset/driverlocal.go | 4 ---- storage/pkg/flagset/driverocis.go | 4 ---- storage/pkg/flagset/driverowncloud.go | 4 ---- storage/pkg/flagset/drivers3ng.go | 4 ---- storage/pkg/flagset/frontend.go | 1 - storage/pkg/flagset/gateway.go | 1 - storage/pkg/flagset/groups.go | 1 - storage/pkg/flagset/ldap.go | 4 ---- storage/pkg/flagset/rest.go | 4 ---- storage/pkg/flagset/root.go | 4 ---- storage/pkg/flagset/runtime_extensions.go | 16 ---------------- storage/pkg/flagset/sharing.go | 1 - storage/pkg/flagset/sharingsql.go | 4 ---- storage/pkg/flagset/storagehome.go | 1 - storage/pkg/flagset/storagemetadata.go | 1 - storage/pkg/flagset/storagepubliclink.go | 1 - storage/pkg/flagset/storageusers.go | 1 - storage/pkg/flagset/users.go | 1 - 22 files changed, 4 insertions(+), 63 deletions(-) delete mode 100644 storage/pkg/flagset/runtime_extensions.go diff --git a/accounts/pkg/flagset/flagset.go b/accounts/pkg/flagset/flagset.go index 733ed3d257..028e0cd5b3 100644 --- a/accounts/pkg/flagset/flagset.go +++ b/accounts/pkg/flagset/flagset.go @@ -239,6 +239,10 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"ACCOUNTS_GID_INDEX_UPPER_BOUND"}, Destination: &cfg.Index.GID.Upper, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode", + }, } } diff --git a/storage/pkg/flagset/authbasic.go b/storage/pkg/flagset/authbasic.go index dbf19c67d6..4f5ae182b8 100644 --- a/storage/pkg/flagset/authbasic.go +++ b/storage/pkg/flagset/authbasic.go @@ -76,7 +76,6 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) flags = append(flags, LDAPWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/authbearer.go b/storage/pkg/flagset/authbearer.go index 863807c8ee..d35e3bd2ea 100644 --- a/storage/pkg/flagset/authbearer.go +++ b/storage/pkg/flagset/authbearer.go @@ -102,7 +102,6 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, TracingWithConfig(cfg)...) flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/drivereos.go b/storage/pkg/flagset/drivereos.go index da130a628e..416a433ee0 100644 --- a/storage/pkg/flagset/drivereos.go +++ b/storage/pkg/flagset/drivereos.go @@ -131,9 +131,5 @@ func DriverEOSWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_EOS_GATEWAYSVC"}, Destination: &cfg.Reva.Storages.EOS.GatewaySVC, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } diff --git a/storage/pkg/flagset/driverlocal.go b/storage/pkg/flagset/driverlocal.go index 86f2e1e789..256d117e9c 100644 --- a/storage/pkg/flagset/driverlocal.go +++ b/storage/pkg/flagset/driverlocal.go @@ -16,9 +16,5 @@ func DriverLocalWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_LOCAL_ROOT"}, Destination: &cfg.Reva.Storages.Local.Root, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } diff --git a/storage/pkg/flagset/driverocis.go b/storage/pkg/flagset/driverocis.go index 90cee48e05..75f80caaae 100644 --- a/storage/pkg/flagset/driverocis.go +++ b/storage/pkg/flagset/driverocis.go @@ -37,9 +37,5 @@ func DriverOCISWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_OCIS_SERVICE_USER_UUID"}, Destination: &cfg.Reva.Storages.OCIS.ServiceUserUUID, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } diff --git a/storage/pkg/flagset/driverowncloud.go b/storage/pkg/flagset/driverowncloud.go index faf532c7d0..65dfd183ec 100644 --- a/storage/pkg/flagset/driverowncloud.go +++ b/storage/pkg/flagset/driverowncloud.go @@ -58,9 +58,5 @@ func DriverOwnCloudWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_OWNCLOUD_LAYOUT"}, Destination: &cfg.Reva.Storages.OwnCloud.UserLayout, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } diff --git a/storage/pkg/flagset/drivers3ng.go b/storage/pkg/flagset/drivers3ng.go index 6384b2c6be..b755ac28ea 100644 --- a/storage/pkg/flagset/drivers3ng.go +++ b/storage/pkg/flagset/drivers3ng.go @@ -65,9 +65,5 @@ func DriverS3NGWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_DRIVER_S3NG_BUCKET"}, Destination: &cfg.Reva.Storages.S3NG.Bucket, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } diff --git a/storage/pkg/flagset/frontend.go b/storage/pkg/flagset/frontend.go index cfd6fd620c..e872cfdf29 100644 --- a/storage/pkg/flagset/frontend.go +++ b/storage/pkg/flagset/frontend.go @@ -183,7 +183,6 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, TracingWithConfig(cfg)...) flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/gateway.go b/storage/pkg/flagset/gateway.go index 241d31bd79..af603478fe 100644 --- a/storage/pkg/flagset/gateway.go +++ b/storage/pkg/flagset/gateway.go @@ -264,7 +264,6 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, TracingWithConfig(cfg)...) flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/groups.go b/storage/pkg/flagset/groups.go index 71cc96666f..cde2810206 100644 --- a/storage/pkg/flagset/groups.go +++ b/storage/pkg/flagset/groups.go @@ -79,7 +79,6 @@ func GroupsWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, SecretWithConfig(cfg)...) flags = append(flags, LDAPWithConfig(cfg)...) flags = append(flags, RestWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/ldap.go b/storage/pkg/flagset/ldap.go index 2a2cacf281..b5f069a45b 100644 --- a/storage/pkg/flagset/ldap.go +++ b/storage/pkg/flagset/ldap.go @@ -208,9 +208,5 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_LDAP_GROUP_SCHEMA_GID_NUMBER"}, Destination: &cfg.Reva.LDAP.GroupSchema.GIDNumber, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } diff --git a/storage/pkg/flagset/rest.go b/storage/pkg/flagset/rest.go index 977eca8b64..34980637e2 100644 --- a/storage/pkg/flagset/rest.go +++ b/storage/pkg/flagset/rest.go @@ -72,9 +72,5 @@ func RestWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_REST_TARGET_API"}, Destination: &cfg.Reva.UserGroupRest.TargetAPI, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } diff --git a/storage/pkg/flagset/root.go b/storage/pkg/flagset/root.go index af2357bd61..c2aaa30239 100644 --- a/storage/pkg/flagset/root.go +++ b/storage/pkg/flagset/root.go @@ -33,9 +33,5 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } diff --git a/storage/pkg/flagset/runtime_extensions.go b/storage/pkg/flagset/runtime_extensions.go deleted file mode 100644 index 7805d96242..0000000000 --- a/storage/pkg/flagset/runtime_extensions.go +++ /dev/null @@ -1,16 +0,0 @@ -package flagset - -import ( - "github.com/micro/cli/v2" - "github.com/owncloud/ocis/storage/pkg/config" -) - -// RuntimeConfig applies common debug config cfg to the flagset -func RuntimeConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, - } -} diff --git a/storage/pkg/flagset/sharing.go b/storage/pkg/flagset/sharing.go index da1754e080..b9a1d989e0 100644 --- a/storage/pkg/flagset/sharing.go +++ b/storage/pkg/flagset/sharing.go @@ -98,7 +98,6 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) flags = append(flags, SharingSQLWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/sharingsql.go b/storage/pkg/flagset/sharingsql.go index 938d24f4f1..e4770b4a9a 100644 --- a/storage/pkg/flagset/sharingsql.go +++ b/storage/pkg/flagset/sharingsql.go @@ -44,9 +44,5 @@ func SharingSQLWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_SHARING_USER_SQL_NAME"}, Destination: &cfg.Reva.Sharing.UserSQLName, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } diff --git a/storage/pkg/flagset/storagehome.go b/storage/pkg/flagset/storagehome.go index c090951ab4..1536795865 100644 --- a/storage/pkg/flagset/storagehome.go +++ b/storage/pkg/flagset/storagehome.go @@ -157,7 +157,6 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, DriverOwnCloudWithConfig(cfg)...) flags = append(flags, DriverOCISWithConfig(cfg)...) flags = append(flags, DriverS3NGWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/storagemetadata.go b/storage/pkg/flagset/storagemetadata.go index 21edf4e2b5..581f7f1f32 100644 --- a/storage/pkg/flagset/storagemetadata.go +++ b/storage/pkg/flagset/storagemetadata.go @@ -106,7 +106,6 @@ func StorageMetadata(cfg *config.Config) []cli.Flag { f = append(f, DriverOwnCloudWithConfig(cfg)...) f = append(f, DriverOCISWithConfig(cfg)...) f = append(f, DriverS3NGWithConfig(cfg)...) - f = append(f, RuntimeConfig(cfg)...) return f diff --git a/storage/pkg/flagset/storagepubliclink.go b/storage/pkg/flagset/storagepubliclink.go index 05eff876bd..eefc636a3a 100644 --- a/storage/pkg/flagset/storagepubliclink.go +++ b/storage/pkg/flagset/storagepubliclink.go @@ -53,7 +53,6 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag { flags = append(flags, TracingWithConfig(cfg)...) flags = append(flags, DebugWithConfig(cfg)...) flags = append(flags, SecretWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/storageusers.go b/storage/pkg/flagset/storageusers.go index a7618373c0..eaf18cd184 100644 --- a/storage/pkg/flagset/storageusers.go +++ b/storage/pkg/flagset/storageusers.go @@ -147,7 +147,6 @@ func StorageUsersWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, DriverOwnCloudWithConfig(cfg)...) flags = append(flags, DriverOCISWithConfig(cfg)...) flags = append(flags, DriverS3NGWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } diff --git a/storage/pkg/flagset/users.go b/storage/pkg/flagset/users.go index 3a335f2a12..091cefb121 100644 --- a/storage/pkg/flagset/users.go +++ b/storage/pkg/flagset/users.go @@ -79,7 +79,6 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag { flags = append(flags, SecretWithConfig(cfg)...) flags = append(flags, LDAPWithConfig(cfg)...) flags = append(flags, RestWithConfig(cfg)...) - flags = append(flags, RuntimeConfig(cfg)...) return flags } From 4994d0b132ad26a51fcab1ac33a88845934e6b85 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 30 Jun 2021 10:34:44 +0200 Subject: [PATCH 3/6] correct flagset usage --- glauth/pkg/flagset/flagset.go | 8 ++--- graph-explorer/pkg/flagset/flagset.go | 8 ++--- graph/pkg/flagset/flagset.go | 8 ++--- idp/pkg/flagset/flagset.go | 9 +++--- ocis/pkg/runtime/service/service.go | 43 ++++++++++++--------------- onlyoffice/pkg/flagset/flagset.go | 8 ++--- settings/pkg/flagset/flagset.go | 8 ++--- store/pkg/flagset/flagset.go | 4 +++ web/pkg/flagset/flagset.go | 4 +++ webdav/pkg/flagset/flagset.go | 20 ++++++++----- 10 files changed, 63 insertions(+), 57 deletions(-) diff --git a/glauth/pkg/flagset/flagset.go b/glauth/pkg/flagset/flagset.go index fc3ae3cfb9..29ef1069a7 100644 --- a/glauth/pkg/flagset/flagset.go +++ b/glauth/pkg/flagset/flagset.go @@ -30,10 +30,6 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"GLAUTH_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } @@ -295,5 +291,9 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"GLAUTH_FALLBACK_USE_GRAPHAPI"}, Destination: &cfg.Fallback.UseGraphAPI, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode. This flag is set by the runtime", + }, } } diff --git a/graph-explorer/pkg/flagset/flagset.go b/graph-explorer/pkg/flagset/flagset.go index c17f9049ec..54ca8b446f 100644 --- a/graph-explorer/pkg/flagset/flagset.go +++ b/graph-explorer/pkg/flagset/flagset.go @@ -27,10 +27,6 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"GRAPH_EXPLORER_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } @@ -158,5 +154,9 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"GRAPH_EXPLORER_GRAPH_URL"}, Destination: &cfg.GraphExplorer.GraphURL, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode. This flag is set by the runtime", + }, } } diff --git a/graph/pkg/flagset/flagset.go b/graph/pkg/flagset/flagset.go index a2caad8cd5..495eb7b6b5 100644 --- a/graph/pkg/flagset/flagset.go +++ b/graph/pkg/flagset/flagset.go @@ -34,10 +34,6 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"GRAPH_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } @@ -220,5 +216,9 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"}, Destination: &cfg.WebdavNamespace, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode. This flag is set by the runtime", + }, } } diff --git a/idp/pkg/flagset/flagset.go b/idp/pkg/flagset/flagset.go index 56a8efe524..aa41ee52a1 100644 --- a/idp/pkg/flagset/flagset.go +++ b/idp/pkg/flagset/flagset.go @@ -30,10 +30,6 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"IDP_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } @@ -421,7 +417,10 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"IDP_REFRESH_TOKEN_EXPIRATION"}, Destination: &cfg.IDP.RefreshTokenDurationSeconds, Value: flags.OverrideDefaultUint64(cfg.IDP.RefreshTokenDurationSeconds, 60*60*24*365*3), // 1 year - + }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode. This flag is set by the runtime", }, } } diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index f3ab451200..7db99b1597 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -186,21 +186,11 @@ func Start(o ...Option) error { } }() - // prepare runset + // prepare the set of services to run s.generateRunSet(s.cfg) - for _, name := range runset { - - // skip delayed services for now - if _, ok := s.Delayed[name]; ok { - continue - } - - // we do this so each service has its own copy. In a perfect world a config object should NOT be edited by - // the callers because this might trigger behavioral changes up the tree. - swap := deepcopy.Copy(s.cfg) - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](swap.(*ociscfg.Config)))) - } + // schedule services that we are sure don't have interdependencies. + scheduleServiceTokens(s, s.ServicesRegistry) // there are reasons not to do this, but we have race conditions ourselves. Until we resolve them, mind the following disclaimer: // Calling ServeBackground will CORRECTLY start the supervisor running in a new goroutine. It is risky to directly run @@ -212,22 +202,27 @@ func Start(o ...Option) error { // trap will block on halt channel for interruptions. go trap(s, halt) - time.Sleep(1 * time.Second) - // add services with delayed execution. - for _, name := range runset { - // this time around only run delayed jobs - if _, ok := s.Delayed[name]; !ok { - continue - } - - swap := deepcopy.Copy(s.cfg) - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](swap.(*ociscfg.Config)))) - } + time.Sleep(1 * time.Second) + scheduleServiceTokens(s, s.Delayed) return http.Serve(l, nil) } +// scheduleServiceTokens adds service tokens to the service supervisor. +func scheduleServiceTokens(s *Service, funcSet map[string]func(*ociscfg.Config) suture.Service) { + for _, name := range runset { + if _, ok := funcSet[name]; !ok { + continue + } + + swap := deepcopy.Copy(s.cfg) + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(funcSet[name](swap.(*ociscfg.Config)))) + } +} + +// generateRunSet interprets the cfg.Runtime.Extensions config option to cherry-pick which services to start using +// the runtime. func (s *Service) generateRunSet(cfg *config.Config) { if cfg.Runtime.Extensions != "" { e := strings.Split(strings.Replace(cfg.Runtime.Extensions, " ", "", -1), ",") diff --git a/onlyoffice/pkg/flagset/flagset.go b/onlyoffice/pkg/flagset/flagset.go index fe630095be..6517b8dc0b 100644 --- a/onlyoffice/pkg/flagset/flagset.go +++ b/onlyoffice/pkg/flagset/flagset.go @@ -34,10 +34,6 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"ONLYOFFICE_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } @@ -158,5 +154,9 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"ONLYOFFICE_ASSET_PATH"}, Destination: &cfg.Asset.Path, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode. This flag is set by the runtime", + }, } } diff --git a/settings/pkg/flagset/flagset.go b/settings/pkg/flagset/flagset.go index b5d0f64b26..8a253abeb5 100644 --- a/settings/pkg/flagset/flagset.go +++ b/settings/pkg/flagset/flagset.go @@ -27,10 +27,6 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"SETTINGS_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, - &cli.StringFlag{ - Name: "extensions", - Usage: "Run specific extensions during supervised mode", - }, } } @@ -187,6 +183,10 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"SETTINGS_JWT_SECRET", "OCIS_JWT_SECRET"}, Destination: &cfg.TokenManager.JWTSecret, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode. This flag is set by the runtime", + }, } } diff --git a/store/pkg/flagset/flagset.go b/store/pkg/flagset/flagset.go index f87f08efc0..578cdf1cca 100644 --- a/store/pkg/flagset/flagset.go +++ b/store/pkg/flagset/flagset.go @@ -140,6 +140,10 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORE_DATA_PATH"}, Destination: &cfg.Datapath, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode. This flag is set by the runtime", + }, } } diff --git a/web/pkg/flagset/flagset.go b/web/pkg/flagset/flagset.go index 717663f986..10f6c79f7c 100644 --- a/web/pkg/flagset/flagset.go +++ b/web/pkg/flagset/flagset.go @@ -223,5 +223,9 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"WEB_OIDC_SCOPE"}, Destination: &cfg.Web.Config.OpenIDConnect.Scope, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode. This flag is set by the runtime", + }, } } diff --git a/webdav/pkg/flagset/flagset.go b/webdav/pkg/flagset/flagset.go index 0d8a29b955..f77bc528aa 100644 --- a/webdav/pkg/flagset/flagset.go +++ b/webdav/pkg/flagset/flagset.go @@ -142,19 +142,23 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.HTTP.Root, }, &cli.StringFlag{ - Name: "ocis-public-url", - Value: flags.OverrideDefaultString(cfg.OcisPublicURL, "https://127.0.0.1:9200"), - Usage: "The domain under which oCIS is reachable", - EnvVars: []string{"OCIS_PUBLIC_URL", "OCIS_URL"}, + Name: "ocis-public-url", + Value: flags.OverrideDefaultString(cfg.OcisPublicURL, "https://127.0.0.1:9200"), + Usage: "The domain under which oCIS is reachable", + EnvVars: []string{"OCIS_PUBLIC_URL", "OCIS_URL"}, Destination: &cfg.OcisPublicURL, }, &cli.StringFlag{ - Name: "webdav-namespace", - Value: flags.OverrideDefaultString(cfg.WebdavNamespace, "/home"), - Usage: "Namespace prefix for the /webdav endpoint", - EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"}, + Name: "webdav-namespace", + Value: flags.OverrideDefaultString(cfg.WebdavNamespace, "/home"), + Usage: "Namespace prefix for the /webdav endpoint", + EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"}, Destination: &cfg.WebdavNamespace, }, + &cli.StringFlag{ + Name: "extensions", + Usage: "Run specific extensions during supervised mode. This flag is set by the runtime", + }, } } From ed9359ddd4cfa9ad2aef014f2042102d15f259d3 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 30 Jun 2021 10:37:47 +0200 Subject: [PATCH 4/6] provide name to anonymous type --- ocis/pkg/runtime/service/service.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 7db99b1597..534584ea73 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -43,11 +43,13 @@ var ( runset []string ) +type serviceFuncMap map[string]func(*ociscfg.Config) suture.Service + // Service represents a RPC service. type Service struct { Supervisor *suture.Supervisor - ServicesRegistry map[string]func(*ociscfg.Config) suture.Service - Delayed map[string]func(*ociscfg.Config) suture.Service + ServicesRegistry serviceFuncMap + Delayed serviceFuncMap Log log.Logger serviceToken map[string][]suture.ServiceToken @@ -77,8 +79,8 @@ func NewService(options ...Option) (*Service, error) { globalCtx, cancelGlobal := context.WithCancel(context.Background()) s := &Service{ - ServicesRegistry: make(map[string]func(*ociscfg.Config) suture.Service), - Delayed: make(map[string]func(*ociscfg.Config) suture.Service), + ServicesRegistry: make(serviceFuncMap), + Delayed: make(serviceFuncMap), Log: l, serviceToken: make(map[string][]suture.ServiceToken), @@ -210,7 +212,7 @@ func Start(o ...Option) error { } // scheduleServiceTokens adds service tokens to the service supervisor. -func scheduleServiceTokens(s *Service, funcSet map[string]func(*ociscfg.Config) suture.Service) { +func scheduleServiceTokens(s *Service, funcSet serviceFuncMap) { for _, name := range runset { if _, ok := funcSet[name]; !ok { continue From 4ce54edc1ab153ea8894de1f7b9a94be549fcac4 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 1 Jul 2021 15:11:34 +0200 Subject: [PATCH 5/6] use replaceall --- ocis/pkg/runtime/service/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 534584ea73..3e9767e3a3 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -227,7 +227,7 @@ func scheduleServiceTokens(s *Service, funcSet serviceFuncMap) { // the runtime. func (s *Service) generateRunSet(cfg *config.Config) { if cfg.Runtime.Extensions != "" { - e := strings.Split(strings.Replace(cfg.Runtime.Extensions, " ", "", -1), ",") + e := strings.Split(strings.ReplaceAll(cfg.Runtime.Extensions, " ", ""), ",") for i := range e { runset = append(runset, e[i]) } From 9e81558fc9bbfe5ca6613d9e1e42b6b14ee3fbfc Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 1 Jul 2021 15:26:38 +0200 Subject: [PATCH 6/6] add changelog --- changelog/unreleased/extensions-cherrypick.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 changelog/unreleased/extensions-cherrypick.md diff --git a/changelog/unreleased/extensions-cherrypick.md b/changelog/unreleased/extensions-cherrypick.md new file mode 100644 index 0000000000..6fa4f89d9b --- /dev/null +++ b/changelog/unreleased/extensions-cherrypick.md @@ -0,0 +1,9 @@ +Enhancement: Runtime support for cherry picking extensions + +Support for running certain extensions supervised via cli flags. Example usage: + +``` +> ocis server --extensions="proxy, idp, storage-metadata, accounts" +``` + +https://github.com/owncloud/ocis/pull/2229