From 60bf000308b1e8e5a61405ac4861756b3d516514 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Fri, 22 Apr 2022 16:24:02 +0200 Subject: [PATCH] make gateway config similar to other services --- .../pkg/command/command.go} | 159 ++++++++---------- extensions/gateway/pkg/config/config.go | 82 +++++++++ .../pkg/config/defaults/defaultconfig.go | 88 ++++++++++ extensions/ocdav/pkg/config/config.go | 2 +- extensions/storage/pkg/command/root.go | 2 +- ocis-pkg/config/config.go | 4 +- ocis-pkg/config/defaultconfig.go | 4 +- ocis/pkg/command/storageappprovider.go | 4 - ocis/pkg/command/storageauthbasic.go | 4 - ocis/pkg/command/storageauthbearer.go | 4 - ocis/pkg/command/storageauthmachine.go | 4 - ocis/pkg/command/storagefrontend.go | 4 - ocis/pkg/command/storagegateway.go | 10 +- ocis/pkg/command/storagegroupprovider.go | 4 - ocis/pkg/command/storagemetadata.go | 3 - ocis/pkg/command/storagepubliclink.go | 4 - ocis/pkg/command/storageshares.go | 3 - ocis/pkg/command/storagesharing.go | 4 - ocis/pkg/command/storageuserprovider.go | 4 - ocis/pkg/command/storageusers.go | 4 - ocis/pkg/command/util.go | 27 --- ocis/pkg/runtime/service/service.go | 13 +- 22 files changed, 253 insertions(+), 184 deletions(-) rename extensions/{storage/pkg/command/gateway.go => gateway/pkg/command/command.go} (70%) create mode 100644 extensions/gateway/pkg/config/config.go create mode 100644 extensions/gateway/pkg/config/defaults/defaultconfig.go delete mode 100644 ocis/pkg/command/util.go diff --git a/extensions/storage/pkg/command/gateway.go b/extensions/gateway/pkg/command/command.go similarity index 70% rename from extensions/storage/pkg/command/gateway.go rename to extensions/gateway/pkg/command/command.go index 944d39d750..5858cbe056 100644 --- a/extensions/storage/pkg/command/gateway.go +++ b/extensions/gateway/pkg/command/command.go @@ -13,14 +13,13 @@ import ( "github.com/gofrs/uuid" "github.com/mitchellh/mapstructure" "github.com/oklog/run" - "github.com/owncloud/ocis/extensions/storage/pkg/config" + "github.com/owncloud/ocis/extensions/gateway/pkg/config" "github.com/owncloud/ocis/extensions/storage/pkg/server/debug" "github.com/owncloud/ocis/extensions/storage/pkg/service/external" - "github.com/owncloud/ocis/extensions/storage/pkg/tracing" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" - "github.com/owncloud/ocis/ocis-pkg/shared" "github.com/owncloud/ocis/ocis-pkg/sync" + "github.com/owncloud/ocis/ocis-pkg/tracing" "github.com/owncloud/ocis/ocis-pkg/version" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" @@ -32,19 +31,25 @@ func Gateway(cfg *config.Config) *cli.Command { Name: "gateway", Usage: "start gateway", Before: func(c *cli.Context) error { - if err := ParseConfig(c, cfg, "storage-gateway"); err != nil { - return err - } + // if err := ParseConfig(c, cfg, "storage-gateway"); err != nil { + // return err + // } - if cfg.Reva.DataGateway.PublicURL == "" { - cfg.Reva.DataGateway.PublicURL = strings.TrimRight(cfg.Reva.Frontend.PublicURL, "/") + "/data" + if cfg.DataGatewayPublicURL == "" { + cfg.DataGatewayPublicURL = strings.TrimRight(cfg.FrontendPublicURL, "/") + "/data" } return nil }, Action: func(c *cli.Context) error { - logger := NewLogger(cfg) - tracing.Configure(cfg, logger) + logCfg := cfg.Logging + logger := log.NewLogger( + log.Level(logCfg.Level), + log.File(logCfg.File), + log.Pretty(logCfg.Pretty), + log.Color(logCfg.Color), + ) + tracing.Configure(cfg.Tracing.Enabled, cfg.Tracing.Type, logger) gr := run.Group{} ctx, cancel := context.WithCancel(context.Background()) uuid := uuid.Must(uuid.NewV4()) @@ -62,7 +67,7 @@ func Gateway(cfg *config.Config) *cli.Command { ctx, "com.owncloud.storage", uuid.String(), - cfg.Reva.Gateway.GRPCAddr, + cfg.GRPC.Addr, version.String, logger, ) @@ -87,10 +92,12 @@ func Gateway(cfg *config.Config) *cli.Command { debugServer, err := debug.Server( debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.Gateway.DebugAddr), + debug.Addr(cfg.Debug.Addr), debug.Logger(logger), debug.Context(ctx), - debug.Config(cfg), + debug.Pprof(cfg.Debug.Pprof), + debug.Zpages(cfg.Debug.Zpages), + debug.Token(cfg.Debug.Token), ) if err != nil { @@ -102,7 +109,7 @@ func Gateway(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Reva.Gateway.Supervised { + if !cfg.Supervised { sync.Trap(&gr, cancel) } @@ -115,56 +122,55 @@ func Gateway(cfg *config.Config) *cli.Command { func gatewayConfigFromStruct(c *cli.Context, cfg *config.Config, logger log.Logger) map[string]interface{} { rcfg := map[string]interface{}{ "core": map[string]interface{}{ - "max_cpus": cfg.Reva.Users.MaxCPUs, "tracing_enabled": cfg.Tracing.Enabled, "tracing_endpoint": cfg.Tracing.Endpoint, "tracing_collector": cfg.Tracing.Collector, "tracing_service_name": c.Command.Name, }, "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - "gatewaysvc": cfg.Reva.Gateway.Endpoint, - "skip_user_groups_in_token": cfg.Reva.SkipUserGroupsInToken, + "jwt_secret": cfg.JWTSecret, + "gatewaysvc": cfg.GatewayEndpoint, + "skip_user_groups_in_token": cfg.SkipUserGroupsInToken, }, "grpc": map[string]interface{}{ - "network": cfg.Reva.Gateway.GRPCNetwork, - "address": cfg.Reva.Gateway.GRPCAddr, + "network": cfg.GRPC.Protocol, + "address": cfg.GRPC.Addr, // TODO build services dynamically "services": map[string]interface{}{ "gateway": map[string]interface{}{ // registries is located on the gateway - "authregistrysvc": cfg.Reva.Gateway.Endpoint, - "storageregistrysvc": cfg.Reva.Gateway.Endpoint, - "appregistrysvc": cfg.Reva.Gateway.Endpoint, + "authregistrysvc": cfg.GatewayEndpoint, + "storageregistrysvc": cfg.GatewayEndpoint, + "appregistrysvc": cfg.GatewayEndpoint, // user metadata is located on the users services - "preferencessvc": cfg.Reva.Users.Endpoint, - "userprovidersvc": cfg.Reva.Users.Endpoint, - "groupprovidersvc": cfg.Reva.Groups.Endpoint, - "permissionssvc": cfg.Reva.Permissions.Endpoint, + "preferencessvc": cfg.UsersEndpoint, + "userprovidersvc": cfg.UsersEndpoint, + "groupprovidersvc": cfg.GroupsEndpoint, + "permissionssvc": cfg.PermissionsEndpoint, // sharing is located on the sharing service - "usershareprovidersvc": cfg.Reva.Sharing.Endpoint, - "publicshareprovidersvc": cfg.Reva.Sharing.Endpoint, - "ocmshareprovidersvc": cfg.Reva.Sharing.Endpoint, - "commit_share_to_storage_grant": cfg.Reva.Gateway.CommitShareToStorageGrant, - "commit_share_to_storage_ref": cfg.Reva.Gateway.CommitShareToStorageRef, - "share_folder": cfg.Reva.Gateway.ShareFolder, // ShareFolder is the location where to create shares in the recipient's storage provider. + "usershareprovidersvc": cfg.SharingEndpoint, + "publicshareprovidersvc": cfg.SharingEndpoint, + "ocmshareprovidersvc": cfg.SharingEndpoint, + "commit_share_to_storage_grant": cfg.CommitShareToStorageGrant, + "commit_share_to_storage_ref": cfg.CommitShareToStorageRef, + "share_folder": cfg.ShareFolder, // ShareFolder is the location where to create shares in the recipient's storage provider. // other - "disable_home_creation_on_login": cfg.Reva.Gateway.DisableHomeCreationOnLogin, - "datagateway": cfg.Reva.DataGateway.PublicURL, - "transfer_shared_secret": cfg.Reva.TransferSecret, - "transfer_expires": cfg.Reva.TransferExpires, - "home_mapping": cfg.Reva.Gateway.HomeMapping, - "etag_cache_ttl": cfg.Reva.Gateway.EtagCacheTTL, + "disable_home_creation_on_login": cfg.DisableHomeCreationOnLogin, + "datagateway": cfg.DataGatewayPublicURL, + "transfer_shared_secret": cfg.TransferSecret, + "transfer_expires": cfg.TransferExpires, + "home_mapping": cfg.HomeMapping, + "etag_cache_ttl": cfg.EtagCacheTTL, }, "authregistry": map[string]interface{}{ "driver": "static", "drivers": map[string]interface{}{ "static": map[string]interface{}{ "rules": map[string]interface{}{ - "basic": cfg.Reva.AuthBasic.Endpoint, - "bearer": cfg.Reva.AuthBearer.Endpoint, - "machine": cfg.Reva.AuthMachine.Endpoint, - "publicshares": cfg.Reva.StoragePublicLink.Endpoint, + "basic": cfg.AuthBasicEndpoint, + "bearer": cfg.AuthBearerEndpoint, + "machine": cfg.AuthMachineEndpoint, + "publicshares": cfg.StoragePublicLinkEndpoint, }, }, }, @@ -178,7 +184,7 @@ func gatewayConfigFromStruct(c *cli.Context, cfg *config.Config, logger log.Logg }, }, "storageregistry": map[string]interface{}{ - "driver": cfg.Reva.StorageRegistry.Driver, + "driver": cfg.StorageRegistry.Driver, "drivers": map[string]interface{}{ "spaces": map[string]interface{}{ "providers": spacesProviders(cfg, logger), @@ -194,20 +200,20 @@ func gatewayConfigFromStruct(c *cli.Context, cfg *config.Config, logger log.Logg func spacesProviders(cfg *config.Config, logger log.Logger) map[string]map[string]interface{} { // if a list of rules is given it overrides the generated rules from below - if len(cfg.Reva.StorageRegistry.Rules) > 0 { + if len(cfg.StorageRegistry.Rules) > 0 { rules := map[string]map[string]interface{}{} - for i := range cfg.Reva.StorageRegistry.Rules { - parts := strings.SplitN(cfg.Reva.StorageRegistry.Rules[i], "=", 2) + for i := range cfg.StorageRegistry.Rules { + parts := strings.SplitN(cfg.StorageRegistry.Rules[i], "=", 2) rules[parts[0]] = map[string]interface{}{"address": parts[1]} } return rules } // check if the rules have to be read from a json file - if cfg.Reva.StorageRegistry.JSON != "" { - data, err := ioutil.ReadFile(cfg.Reva.StorageRegistry.JSON) + if cfg.StorageRegistry.JSON != "" { + data, err := ioutil.ReadFile(cfg.StorageRegistry.JSON) if err != nil { - logger.Error().Err(err).Msg("Failed to read storage registry rules from JSON file: " + cfg.Reva.StorageRegistry.JSON) + logger.Error().Err(err).Msg("Failed to read storage registry rules from JSON file: " + cfg.StorageRegistry.JSON) return nil } var rules map[string]map[string]interface{} @@ -220,7 +226,7 @@ func spacesProviders(cfg *config.Config, logger log.Logger) map[string]map[strin // generate rules based on default config return map[string]map[string]interface{}{ - cfg.Reva.StorageUsers.Endpoint: { + cfg.StorageUsersEndpoint: { "spaces": map[string]interface{}{ "personal": map[string]interface{}{ "mount_point": "/users", @@ -232,7 +238,7 @@ func spacesProviders(cfg *config.Config, logger log.Logger) map[string]map[strin }, }, }, - cfg.Reva.StorageShares.Endpoint: { + cfg.StorageSharesEndpoint: { "spaces": map[string]interface{}{ "virtual": map[string]interface{}{ // The root of the share jail is mounted here @@ -251,7 +257,7 @@ func spacesProviders(cfg *config.Config, logger log.Logger) map[string]map[strin }, }, // public link storage returns the mount id of the actual storage - cfg.Reva.StoragePublicLink.Endpoint: { + cfg.StoragePublicLinkEndpoint: { "spaces": map[string]interface{}{ "grant": map[string]interface{}{ "mount_point": ".", @@ -281,10 +287,10 @@ func mimetypes(cfg *config.Config, logger log.Logger) []map[string]interface{} { var m []map[string]interface{} // load default app mimetypes from a json file - if cfg.Reva.AppRegistry.MimetypesJSON != "" { - data, err := ioutil.ReadFile(cfg.Reva.AppRegistry.MimetypesJSON) + if cfg.AppRegistry.MimetypesJSON != "" { + data, err := ioutil.ReadFile(cfg.AppRegistry.MimetypesJSON) if err != nil { - logger.Error().Err(err).Msg("Failed to read app registry mimetypes from JSON file: " + cfg.Reva.AppRegistry.MimetypesJSON) + logger.Error().Err(err).Msg("Failed to read app registry mimetypes from JSON file: " + cfg.AppRegistry.MimetypesJSON) return nil } if err = json.Unmarshal(data, &mimetypes); err != nil { @@ -385,56 +391,31 @@ type GatewaySutureService struct { // NewGatewaySutureService creates a new gateway.GatewaySutureService func NewGateway(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + cfg.Gateway.Commons = cfg.Commons return GatewaySutureService{ - cfg: cfg.Storage, + cfg: cfg.Gateway, } } func (s GatewaySutureService) Serve(ctx context.Context) error { - s.cfg.Reva.Gateway.Context = ctx + // s.cfg.Reva.Gateway.Context = ctx + cmd := Gateway(s.cfg) f := &flag.FlagSet{} - cmdFlags := Gateway(s.cfg).Flags + cmdFlags := cmd.Flags for k := range cmdFlags { if err := cmdFlags[k].Apply(f); err != nil { return err } } cliCtx := cli.NewContext(nil, f, nil) - if Gateway(s.cfg).Before != nil { - if err := Gateway(s.cfg).Before(cliCtx); err != nil { + if cmd.Before != nil { + if err := cmd.Before(cliCtx); err != nil { return err } } - if err := Gateway(s.cfg).Action(cliCtx); err != nil { + if err := cmd.Action(cliCtx); err != nil { return err } return nil } - -// ParseConfig loads accounts configuration from known paths. -func ParseConfig(c *cli.Context, cfg *config.Config, storageExtension string) error { - conf, err := ociscfg.BindSourcesToStructs(storageExtension, cfg) - if err != nil { - return err - } - - // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - cfg.Log = &shared.Log{ - Level: cfg.Commons.Log.Level, - Pretty: cfg.Commons.Log.Pretty, - Color: cfg.Commons.Log.Color, - File: cfg.Commons.Log.File, - } - } else if cfg.Log == nil { - cfg.Log = &shared.Log{} - } - - // load all env variables relevant to the config in the current context. - conf.LoadOSEnv(config.GetEnv(cfg), false) - - bindings := config.StructMappings(cfg) - return ociscfg.BindEnv(conf, bindings) -} diff --git a/extensions/gateway/pkg/config/config.go b/extensions/gateway/pkg/config/config.go new file mode 100644 index 0000000000..434e17dcee --- /dev/null +++ b/extensions/gateway/pkg/config/config.go @@ -0,0 +1,82 @@ +package config + +import "github.com/owncloud/ocis/ocis-pkg/shared" + +type Config struct { + *shared.Commons `yaml:"-"` + Service Service `yaml:"-"` + Tracing *Tracing `yaml:"tracing"` + Logging *Logging `yaml:"log"` + Debug Debug `yaml:"debug"` + Supervised bool + + GRPC GRPCConfig `yaml:"grpc"` + + JWTSecret string + GatewayEndpoint string + SkipUserGroupsInToken bool + + CommitShareToStorageGrant bool + CommitShareToStorageRef bool + ShareFolder string + DisableHomeCreationOnLogin bool + TransferSecret string + TransferExpires int + HomeMapping string + EtagCacheTTL int + + UsersEndpoint string + GroupsEndpoint string + PermissionsEndpoint string + SharingEndpoint string + DataGatewayPublicURL string + FrontendPublicURL string + AuthBasicEndpoint string + AuthBearerEndpoint string + AuthMachineEndpoint string + StoragePublicLinkEndpoint string + StorageUsersEndpoint string + StorageSharesEndpoint string + + StorageRegistry StorageRegistry + AppRegistry AppRegistry +} +type Tracing struct { + Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;GATEWAY_TRACING_ENABLED" desc:"Activates tracing."` + Type string `yaml:"type" env:"OCIS_TRACING_TYPE;GATEWAY_TRACING_TYPE"` + Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT;GATEWAY_TRACING_ENDPOINT" desc:"The endpoint to the tracing collector."` + Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;GATEWAY_TRACING_COLLECTOR"` +} + +type Logging struct { + Level string `yaml:"level" env:"OCIS_LOG_LEVEL;GATEWAY_LOG_LEVEL" desc:"The log level."` + Pretty bool `yaml:"pretty" env:"OCIS_LOG_PRETTY;GATEWAY_LOG_PRETTY" desc:"Activates pretty log output."` + Color bool `yaml:"color" env:"OCIS_LOG_COLOR;GATEWAY_LOG_COLOR" desc:"Activates colorized log output."` + File string `yaml:"file" env:"OCIS_LOG_FILE;GATEWAY_LOG_FILE" desc:"The target log file."` +} + +type Service struct { + Name string `yaml:"-"` +} + +type Debug struct { + Addr string `yaml:"addr" env:"GATEWAY_DEBUG_ADDR"` + Token string `yaml:"token" env:"GATEWAY_DEBUG_TOKEN"` + Pprof bool `yaml:"pprof" env:"GATEWAY_DEBUG_PPROF"` + Zpages bool `yaml:"zpages" env:"GATEWAY_DEBUG_ZPAGES"` +} + +type GRPCConfig struct { + Addr string `yaml:"addr" env:"GATEWAY_GRPC_ADDR" desc:"The address of the grpc service."` + Protocol string `yaml:"protocol" env:"GATEWAY_GRPC_PROTOCOL" desc:"The transport protocol of the grpc service."` +} + +type StorageRegistry struct { + Driver string + Rules []string + JSON string +} + +type AppRegistry struct { + MimetypesJSON string +} diff --git a/extensions/gateway/pkg/config/defaults/defaultconfig.go b/extensions/gateway/pkg/config/defaults/defaultconfig.go new file mode 100644 index 0000000000..b49a8d3e37 --- /dev/null +++ b/extensions/gateway/pkg/config/defaults/defaultconfig.go @@ -0,0 +1,88 @@ +package defaults + +import ( + "github.com/owncloud/ocis/extensions/gateway/pkg/config" +) + +func FullDefaultConfig() *config.Config { + cfg := DefaultConfig() + + EnsureDefaults(cfg) + + return cfg +} + +func DefaultConfig() *config.Config { + return &config.Config{ + Debug: config.Debug{ + Addr: "127.0.0.1:9143", + Token: "", + Pprof: false, + Zpages: false, + }, + GRPC: config.GRPCConfig{ + Addr: "127.0.0.1:9142", + Protocol: "tcp", + }, + Service: config.Service{ + Name: "gateway", + }, + GatewayEndpoint: "127.0.0.1:9142", + JWTSecret: "Pive-Fumkiu4", + + CommitShareToStorageGrant: true, + CommitShareToStorageRef: true, + ShareFolder: "Shares", + DisableHomeCreationOnLogin: true, + TransferSecret: "replace-me-with-a-transfer-secret", + TransferExpires: 24 * 60 * 60, + HomeMapping: "", + EtagCacheTTL: 0, + + UsersEndpoint: "localhost:9144", + GroupsEndpoint: "localhost:9160", + PermissionsEndpoint: "localhost:9191", + SharingEndpoint: "localhost:9150", + DataGatewayPublicURL: "", + FrontendPublicURL: "https://localhost:9200", + AuthBasicEndpoint: "localhost:9146", + AuthBearerEndpoint: "localhost:9148", + AuthMachineEndpoint: "localhost:9166", + StoragePublicLinkEndpoint: "localhost:9178", + StorageUsersEndpoint: "localhost:9157", + StorageSharesEndpoint: "localhost:9154", + + StorageRegistry: config.StorageRegistry{ + Driver: "spaces", + JSON: "", + }, + AppRegistry: config.AppRegistry{ + MimetypesJSON: "", + }, + } +} + +func EnsureDefaults(cfg *config.Config) { + // provide with defaults for shared logging, since we need a valid destination address for BindEnv. + if cfg.Logging == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Logging = &config.Logging{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Logging == nil { + cfg.Logging = &config.Logging{} + } + // provide with defaults for shared tracing, since we need a valid destination address for BindEnv. + if cfg.Tracing == nil && cfg.Commons != nil && cfg.Commons.Tracing != nil { + cfg.Tracing = &config.Tracing{ + Enabled: cfg.Commons.Tracing.Enabled, + Type: cfg.Commons.Tracing.Type, + Endpoint: cfg.Commons.Tracing.Endpoint, + Collector: cfg.Commons.Tracing.Collector, + } + } else if cfg.Tracing == nil { + cfg.Tracing = &config.Tracing{} + } +} diff --git a/extensions/ocdav/pkg/config/config.go b/extensions/ocdav/pkg/config/config.go index 4b141a48c5..9e008d7668 100644 --- a/extensions/ocdav/pkg/config/config.go +++ b/extensions/ocdav/pkg/config/config.go @@ -24,7 +24,7 @@ type Config struct { PublicURL string `yaml:"public_url"` // Insecure certificates allowed when making requests to the gateway - Insecure bool `yaml:"insecure"` + Insecure bool `yaml:"insecure" env:"OCIS_INSECURE;OCDAV_INSECURE"` // Timeout in seconds when making requests to the gateway Timeout int64 `yaml:"timeout"` Middleware Middleware diff --git a/extensions/storage/pkg/command/root.go b/extensions/storage/pkg/command/root.go index fc1472df0a..de87cccc1c 100644 --- a/extensions/storage/pkg/command/root.go +++ b/extensions/storage/pkg/command/root.go @@ -13,7 +13,7 @@ import ( func GetCommands(cfg *config.Config) cli.Commands { return []*cli.Command{ // Frontend(cfg), - Gateway(cfg), + // Gateway(cfg), // Users(cfg), // Groups(cfg), // AppProvider(cfg), diff --git a/ocis-pkg/config/config.go b/ocis-pkg/config/config.go index a0b6042c3d..85d7fd4632 100644 --- a/ocis-pkg/config/config.go +++ b/ocis-pkg/config/config.go @@ -10,6 +10,7 @@ import ( authbearer "github.com/owncloud/ocis/extensions/auth-bearer/pkg/config" authmachine "github.com/owncloud/ocis/extensions/auth-machine/pkg/config" frontend "github.com/owncloud/ocis/extensions/frontend/pkg/config" + gateway "github.com/owncloud/ocis/extensions/gateway/pkg/config" glauth "github.com/owncloud/ocis/extensions/glauth/pkg/config" graphExplorer "github.com/owncloud/ocis/extensions/graph-explorer/pkg/config" graph "github.com/owncloud/ocis/extensions/graph/pkg/config" @@ -27,7 +28,6 @@ import ( storagepublic "github.com/owncloud/ocis/extensions/storage-publiclink/pkg/config" storageshares "github.com/owncloud/ocis/extensions/storage-shares/pkg/config" storageusers "github.com/owncloud/ocis/extensions/storage-users/pkg/config" - storage "github.com/owncloud/ocis/extensions/storage/pkg/config" store "github.com/owncloud/ocis/extensions/store/pkg/config" thumbnails "github.com/owncloud/ocis/extensions/thumbnails/pkg/config" user "github.com/owncloud/ocis/extensions/user/pkg/config" @@ -85,7 +85,7 @@ type Config struct { Web *web.Config `yaml:"web"` Proxy *proxy.Config `yaml:"proxy"` Settings *settings.Config `yaml:"settings"` - Storage *storage.Config `yaml:"storage"` + Gateway *gateway.Config `yaml:"gateway"` Frontend *frontend.Config `yaml:"frontend"` AuthBasic *authbasic.Config `yaml:"auth_basic"` AuthBearer *authbearer.Config `yaml:"auth_bearer"` diff --git a/ocis-pkg/config/defaultconfig.go b/ocis-pkg/config/defaultconfig.go index 3435678787..0b9f0f70ab 100644 --- a/ocis-pkg/config/defaultconfig.go +++ b/ocis-pkg/config/defaultconfig.go @@ -8,6 +8,7 @@ import ( authbearer "github.com/owncloud/ocis/extensions/auth-bearer/pkg/config/defaults" authmachine "github.com/owncloud/ocis/extensions/auth-machine/pkg/config/defaults" frontend "github.com/owncloud/ocis/extensions/frontend/pkg/config/defaults" + gateway "github.com/owncloud/ocis/extensions/gateway/pkg/config/defaults" glauth "github.com/owncloud/ocis/extensions/glauth/pkg/config/defaults" graphExplorer "github.com/owncloud/ocis/extensions/graph-explorer/pkg/config/defaults" graph "github.com/owncloud/ocis/extensions/graph/pkg/config/defaults" @@ -25,7 +26,6 @@ import ( storagepublic "github.com/owncloud/ocis/extensions/storage-publiclink/pkg/config/defaults" storageshares "github.com/owncloud/ocis/extensions/storage-shares/pkg/config/defaults" storageusers "github.com/owncloud/ocis/extensions/storage-users/pkg/config/defaults" - storage "github.com/owncloud/ocis/extensions/storage/pkg/config/defaults" store "github.com/owncloud/ocis/extensions/store/pkg/config/defaults" thumbnails "github.com/owncloud/ocis/extensions/thumbnails/pkg/config/defaults" user "github.com/owncloud/ocis/extensions/user/pkg/config/defaults" @@ -58,7 +58,7 @@ func DefaultConfig() *Config { Store: store.DefaultConfig(), Thumbnails: thumbnails.DefaultConfig(), WebDAV: webdav.DefaultConfig(), - Storage: storage.DefaultConfig(), + Gateway: gateway.FullDefaultConfig(), AuthBasic: authbasic.FullDefaultConfig(), AuthBearer: authbearer.FullDefaultConfig(), AuthMachine: authmachine.FullDefaultConfig(), diff --git a/ocis/pkg/command/storageappprovider.go b/ocis/pkg/command/storageappprovider.go index 27cca4f4b5..beb494d341 100644 --- a/ocis/pkg/command/storageappprovider.go +++ b/ocis/pkg/command/storageappprovider.go @@ -13,10 +13,6 @@ func StorageAppProviderCommand(cfg *config.Config) *cli.Command { Name: "storage-app-provider", Usage: "start storage app-provider service", Category: "extensions", - //Flags: flagset.AppProviderWithConfig(cfg.Storage), - // Before: func(ctx *cli.Context) error { - // return ParseStorageCommon(ctx, cfg) - // }, Action: func(c *cli.Context) error { origCmd := command.AppProvider(cfg.AppProvider) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storageauthbasic.go b/ocis/pkg/command/storageauthbasic.go index 90ea8083cd..26164983f7 100644 --- a/ocis/pkg/command/storageauthbasic.go +++ b/ocis/pkg/command/storageauthbasic.go @@ -13,10 +13,6 @@ func StorageAuthBasicCommand(cfg *config.Config) *cli.Command { Name: "storage-auth-basic", Usage: "start storage auth-basic service", Category: "extensions", - //Flags: flagset.AuthBasicWithConfig(cfg.Storage), - Before: func(ctx *cli.Context) error { - return ParseStorageCommon(ctx, cfg) - }, Action: func(c *cli.Context) error { origCmd := command.AuthBasic(cfg.AuthBasic) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storageauthbearer.go b/ocis/pkg/command/storageauthbearer.go index 4c0ca6ccc0..c3c9855d84 100644 --- a/ocis/pkg/command/storageauthbearer.go +++ b/ocis/pkg/command/storageauthbearer.go @@ -13,10 +13,6 @@ func StorageAuthBearerCommand(cfg *config.Config) *cli.Command { Name: "storage-auth-bearer", Usage: "Start storage auth-bearer service", Category: "extensions", - //Flags: flagset.AuthBearerWithConfig(cfg.Storage), - // Before: func(ctx *cli.Context) error { - // return ParseStorageCommon(ctx, cfg) - // }, Action: func(c *cli.Context) error { origCmd := command.AuthBearer(cfg.AuthBearer) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storageauthmachine.go b/ocis/pkg/command/storageauthmachine.go index 029e96058c..bbed4b2c1e 100644 --- a/ocis/pkg/command/storageauthmachine.go +++ b/ocis/pkg/command/storageauthmachine.go @@ -13,10 +13,6 @@ func StorageAuthMachineCommand(cfg *config.Config) *cli.Command { Name: "storage-auth-machine", Usage: "start storage auth-machine service", Category: "extensions", - //Flags: flagset.AuthMachineWithConfig(cfg.Storage), - // Before: func(ctx *cli.Context) error { - // return ParseStorageCommon(ctx, cfg) - // }, Action: func(c *cli.Context) error { origCmd := command.AuthMachine(cfg.AuthMachine) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storagefrontend.go b/ocis/pkg/command/storagefrontend.go index 10ce1c2367..4d37589fee 100644 --- a/ocis/pkg/command/storagefrontend.go +++ b/ocis/pkg/command/storagefrontend.go @@ -13,10 +13,6 @@ func StorageFrontendCommand(cfg *config.Config) *cli.Command { Name: "storage-frontend", Usage: "start storage frontend", Category: "extensions", - //Flags: flagset.FrontendWithConfig(cfg.Storage), - // Before: func(ctx *cli.Context) error { - // return ParseStorageCommon(ctx, cfg) - // }, Action: func(c *cli.Context) error { origCmd := command.Frontend(cfg.Frontend) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storagegateway.go b/ocis/pkg/command/storagegateway.go index fb96d116d5..f69adc3053 100644 --- a/ocis/pkg/command/storagegateway.go +++ b/ocis/pkg/command/storagegateway.go @@ -1,7 +1,7 @@ package command import ( - "github.com/owncloud/ocis/extensions/storage/pkg/command" + "github.com/owncloud/ocis/extensions/gateway/pkg/command" "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis/pkg/register" "github.com/urfave/cli/v2" @@ -14,11 +14,11 @@ func StorageGatewayCommand(cfg *config.Config) *cli.Command { Usage: "start storage gateway", Category: "extensions", //Flags: flagset.GatewayWithConfig(cfg.Storage), - Before: func(ctx *cli.Context) error { - return ParseStorageCommon(ctx, cfg) - }, + // Before: func(ctx *cli.Context) error { + // return ParseStorageCommon(ctx, cfg) + // }, Action: func(c *cli.Context) error { - origCmd := command.Gateway(cfg.Storage) + origCmd := command.Gateway(cfg.Gateway) return handleOriginalAction(c, origCmd) }, } diff --git a/ocis/pkg/command/storagegroupprovider.go b/ocis/pkg/command/storagegroupprovider.go index c2340fede3..2e39709ee1 100644 --- a/ocis/pkg/command/storagegroupprovider.go +++ b/ocis/pkg/command/storagegroupprovider.go @@ -13,10 +13,6 @@ func StorageGroupProviderCommand(cfg *config.Config) *cli.Command { Name: "storage-groupprovider", Usage: "start storage groupprovider service", Category: "extensions", - //Flags: flagset.GroupsWithConfig(cfg.Storage), - Before: func(ctx *cli.Context) error { - return ParseStorageCommon(ctx, cfg) - }, Action: func(c *cli.Context) error { origCmd := command.Groups(cfg.Group) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storagemetadata.go b/ocis/pkg/command/storagemetadata.go index bcde8bf5c0..2e87bea4f0 100644 --- a/ocis/pkg/command/storagemetadata.go +++ b/ocis/pkg/command/storagemetadata.go @@ -13,9 +13,6 @@ func StorageMetadataCommand(cfg *config.Config) *cli.Command { Name: "storage-metadata", Usage: "start storage and data service for metadata", Category: "extensions", - // Before: func(ctx *cli.Context) error { - // return ParseStorageCommon(ctx, cfg) - // }, Action: func(c *cli.Context) error { origCmd := command.StorageMetadata(cfg.StorageMetadata) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storagepubliclink.go b/ocis/pkg/command/storagepubliclink.go index 0ad1c43fbb..06a99d0a7a 100644 --- a/ocis/pkg/command/storagepubliclink.go +++ b/ocis/pkg/command/storagepubliclink.go @@ -13,10 +13,6 @@ func StoragePublicLinkCommand(cfg *config.Config) *cli.Command { Name: "storage-public-link", Usage: "start storage public link storage", Category: "extensions", - //Flags: flagset.StoragePublicLink(cfg.Storage), - // Before: func(ctx *cli.Context) error { - // return ParseStorageCommon(ctx, cfg) - // }, Action: func(c *cli.Context) error { origCmd := command.StoragePublicLink(cfg.StoragePublicLink) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storageshares.go b/ocis/pkg/command/storageshares.go index 87224510b4..04fe859bd0 100644 --- a/ocis/pkg/command/storageshares.go +++ b/ocis/pkg/command/storageshares.go @@ -13,9 +13,6 @@ func StorageSharesCommand(cfg *config.Config) *cli.Command { Name: "storage-shares", Usage: "start storage and data provider for shares jail", Category: "extensions", - // Before: func(ctx *cli.Context) error { - // return ParseStorageCommon(ctx, cfg) - // }, Action: func(c *cli.Context) error { origCmd := command.StorageShares(cfg.StorageShares) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storagesharing.go b/ocis/pkg/command/storagesharing.go index 84d8b7b1db..fe9e3cb796 100644 --- a/ocis/pkg/command/storagesharing.go +++ b/ocis/pkg/command/storagesharing.go @@ -13,10 +13,6 @@ func StorageSharingCommand(cfg *config.Config) *cli.Command { Name: "storage-sharing", Usage: "start storage sharing service", Category: "extensions", - //Flags: flagset.SharingWithConfig(cfg.Storage), - Before: func(ctx *cli.Context) error { - return ParseStorageCommon(ctx, cfg) - }, Action: func(c *cli.Context) error { origCmd := command.Sharing(cfg.Sharing) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storageuserprovider.go b/ocis/pkg/command/storageuserprovider.go index 20450c63eb..dabef25fb0 100644 --- a/ocis/pkg/command/storageuserprovider.go +++ b/ocis/pkg/command/storageuserprovider.go @@ -13,10 +13,6 @@ func StorageUserProviderCommand(cfg *config.Config) *cli.Command { Name: "storage-userprovider", Usage: "start storage userprovider service", Category: "extensions", - //Flags: flagset.UsersWithConfig(cfg.Storage), - // Before: func(ctx *cli.Context) error { - // return ParseStorageCommon(ctx, cfg) - // }, Action: func(c *cli.Context) error { origCmd := command.User(cfg.User) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/storageusers.go b/ocis/pkg/command/storageusers.go index 372b27d852..4ca75f2061 100644 --- a/ocis/pkg/command/storageusers.go +++ b/ocis/pkg/command/storageusers.go @@ -13,10 +13,6 @@ func StorageUsersCommand(cfg *config.Config) *cli.Command { Name: "storage-users", Usage: "start storage and data provider for /users mount", Category: "extensions", - //Flags: flagset.StorageUsersWithConfig(cfg.Storage), - // Before: func(ctx *cli.Context) error { - // return ParseStorageCommon(ctx, cfg) - // }, Action: func(c *cli.Context) error { origCmd := command.StorageUsers(cfg.StorageUsers) return handleOriginalAction(c, origCmd) diff --git a/ocis/pkg/command/util.go b/ocis/pkg/command/util.go deleted file mode 100644 index 914c5a37c1..0000000000 --- a/ocis/pkg/command/util.go +++ /dev/null @@ -1,27 +0,0 @@ -package command - -import ( - "github.com/owncloud/ocis/ocis-pkg/config" - "github.com/owncloud/ocis/ocis-pkg/config/parser" - "github.com/owncloud/ocis/ocis-pkg/shared" - "github.com/urfave/cli/v2" -) - -func ParseStorageCommon(ctx *cli.Context, cfg *config.Config) error { - if err := parser.ParseConfig(cfg); err != nil { - return err - } - - if cfg.Storage.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - cfg.Storage.Log = &shared.Log{ - Level: cfg.Commons.Log.Level, - Pretty: cfg.Commons.Log.Pretty, - Color: cfg.Commons.Log.Color, - File: cfg.Commons.Log.File, - } - } else if cfg.Storage.Log == nil && cfg.Commons == nil { - cfg.Storage.Log = &shared.Log{} - } - - return nil -} diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 97871d62c2..b398083f67 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -25,6 +25,7 @@ import ( authbearer "github.com/owncloud/ocis/extensions/auth-bearer/pkg/command" authmachine "github.com/owncloud/ocis/extensions/auth-machine/pkg/command" frontend "github.com/owncloud/ocis/extensions/frontend/pkg/command" + gateway "github.com/owncloud/ocis/extensions/gateway/pkg/command" glauth "github.com/owncloud/ocis/extensions/glauth/pkg/command" graphExplorer "github.com/owncloud/ocis/extensions/graph-explorer/pkg/command" graph "github.com/owncloud/ocis/extensions/graph/pkg/command" @@ -42,7 +43,6 @@ import ( storagepublic "github.com/owncloud/ocis/extensions/storage-publiclink/pkg/command" storageshares "github.com/owncloud/ocis/extensions/storage-shares/pkg/command" storageusers "github.com/owncloud/ocis/extensions/storage-users/pkg/command" - storage "github.com/owncloud/ocis/extensions/storage/pkg/command" store "github.com/owncloud/ocis/extensions/store/pkg/command" thumbnails "github.com/owncloud/ocis/extensions/thumbnails/pkg/command" user "github.com/owncloud/ocis/extensions/user/pkg/command" @@ -121,7 +121,7 @@ func NewService(options ...Option) (*Service, error) { s.ServicesRegistry["webdav"] = webdav.NewSutureService s.ServicesRegistry["storage-frontend"] = frontend.NewFrontend s.ServicesRegistry["ocdav"] = ocdav.NewOCDav - s.ServicesRegistry["storage-gateway"] = storage.NewGateway + s.ServicesRegistry["storage-gateway"] = gateway.NewGateway s.ServicesRegistry["storage-userprovider"] = user.NewUserProvider s.ServicesRegistry["storage-groupprovider"] = group.NewGroupProvider s.ServicesRegistry["storage-authbasic"] = authbasic.NewAuthBasic @@ -184,15 +184,6 @@ func Start(o ...Option) error { } } - if s.cfg.Storage.Log == nil { - s.cfg.Storage.Log = &shared.Log{} - } - - s.cfg.Storage.Log.Color = s.cfg.Commons.Log.Color - s.cfg.Storage.Log.Level = s.cfg.Commons.Log.Level - s.cfg.Storage.Log.Pretty = s.cfg.Commons.Log.Pretty - s.cfg.Storage.Log.File = s.cfg.Commons.Log.File - if err = rpc.Register(s); err != nil { if s != nil { s.Log.Fatal().Err(err)