make gateway config similar to other services

This commit is contained in:
David Christofas
2022-04-22 16:24:02 +02:00
parent 76a6588d88
commit 60bf000308
22 changed files with 253 additions and 184 deletions

View File

@@ -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)
}

View File

@@ -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
}

View File

@@ -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{}
}
}

View File

@@ -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

View File

@@ -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),

View File

@@ -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"`

View File

@@ -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(),

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)
},
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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)