fix all storages

This commit is contained in:
A.Unger
2021-11-11 15:48:00 +01:00
parent 582649b7d4
commit 59f53390a8
16 changed files with 85 additions and 210 deletions

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StorageAppProviderCommand(cfg *config.Config) *cli.Command {
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(configureStorageAppProvider(cfg))
origCmd := command.AppProvider(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageAppProvider(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageAppProviderCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StorageAuthBasicCommand(cfg *config.Config) *cli.Command {
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(configureStorageAuthBasic(cfg))
origCmd := command.AuthBasic(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageAuthBasic(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageAuthBasicCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StorageAuthBearerCommand(cfg *config.Config) *cli.Command {
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(configureStorageAuthBearer(cfg))
origCmd := command.AuthBearer(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageAuthBearer(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageAuthBearerCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StorageFrontendCommand(cfg *config.Config) *cli.Command {
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(configureStorageFrontend(cfg))
origCmd := command.Frontend(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageFrontend(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageFrontendCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ 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)
},
Action: func(c *cli.Context) error {
origCmd := command.Gateway(configureStorageGateway(cfg))
origCmd := command.Gateway(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageGateway(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageGatewayCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StorageGroupProviderCommand(cfg *config.Config) *cli.Command {
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(configureStorageGroupProvider(cfg))
origCmd := command.Groups(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageGroupProvider(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageGroupProviderCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StorageHomeCommand(cfg *config.Config) *cli.Command {
Usage: "Start storage and data provider for /home mount",
Category: "Extensions",
Flags: flagset.StorageHomeWithConfig(cfg.Storage),
Before: func(ctx *cli.Context) error {
return ParseStorageCommon(ctx, cfg)
},
Action: func(c *cli.Context) error {
origCmd := command.StorageHome(configureStorageHome(cfg))
origCmd := command.StorageHome(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageHome(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageHomeCommand)
}

View File

@@ -4,7 +4,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -16,28 +15,16 @@ func StorageMetadataCommand(cfg *config.Config) *cli.Command {
Usage: "Start storage and data service for metadata",
Category: "Extensions",
Flags: flagset.StorageMetadata(cfg.Storage),
Before: func(ctx *cli.Context) error {
return ParseStorageCommon(ctx, cfg)
},
Action: func(c *cli.Context) error {
origCmd := command.StorageMetadata(configureStorageMetadata(cfg))
origCmd := command.StorageMetadata(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageMetadata(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageMetadataCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StoragePublicLinkCommand(cfg *config.Config) *cli.Command {
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(configureStoragePublicLink(cfg))
origCmd := command.StoragePublicLink(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStoragePublicLink(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StoragePublicLinkCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StorageSharingCommand(cfg *config.Config) *cli.Command {
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(configureStorageSharing(cfg))
origCmd := command.Sharing(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageSharing(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageSharingCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StorageUserProviderCommand(cfg *config.Config) *cli.Command {
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.Users(configureStorageUserProvider(cfg))
origCmd := command.Users(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageUserProvider(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageUserProviderCommand)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/storage/pkg/command"
svcconfig "github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/urfave/cli/v2"
)
@@ -19,28 +18,16 @@ func StorageUsersCommand(cfg *config.Config) *cli.Command {
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(configureStorageUsers(cfg))
origCmd := command.StorageUsers(cfg.Storage)
return handleOriginalAction(c, origCmd)
},
}
}
func configureStorageUsers(cfg *config.Config) *svcconfig.Config {
cfg.Storage.Log.Level = cfg.Log.Level
cfg.Storage.Log.Pretty = cfg.Log.Pretty
cfg.Storage.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Storage.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Storage.Tracing.Type = cfg.Tracing.Type
cfg.Storage.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Storage.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.Storage
}
func init() {
register.AddCommand(StorageUsersCommand)
}

26
ocis/pkg/command/util.go Normal file
View File

@@ -0,0 +1,26 @@
package command
import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/urfave/cli/v2"
)
func ParseStorageCommon(ctx *cli.Context, cfg *config.Config) error {
if err := ParseConfig(ctx, 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

@@ -167,6 +167,10 @@ 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.Color
s.cfg.Storage.Log.Level = s.cfg.Commons.Level
s.cfg.Storage.Log.Pretty = s.cfg.Commons.Pretty

View File

@@ -4,6 +4,8 @@ import (
"os"
"strings"
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/version"
"github.com/owncloud/ocis/storage/pkg/config"
@@ -25,10 +27,11 @@ func Execute(cfg *config.Config) error {
Email: "support@owncloud.com",
},
},
//Flags: flagset.RootWithConfig(cfg),
Before: func(c *cli.Context) error {
if cfg.Log == nil {
cfg.Log = &shared.Log{}
}
logger := NewLogger(cfg)
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))

View File

@@ -512,7 +512,5 @@ type Config struct {
// New initializes a new configuration with or without defaults.
func New() *Config {
return &Config{
Log: &shared.Log{},
}
return &Config{}
}