switch all other services to struct tag based env config

This commit is contained in:
Willy Kloucek
2022-01-03 07:49:24 +01:00
parent 30656c5a32
commit ee57288309
115 changed files with 1023 additions and 1989 deletions
+2 -1
View File
@@ -12,6 +12,7 @@ import (
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
@@ -27,7 +28,7 @@ func AppProvider(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-app-provider")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
gr := run.Group{}
ctx, cancel := context.WithCancel(context.Background())
+2 -1
View File
@@ -13,6 +13,7 @@ import (
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
@@ -28,7 +29,7 @@ func AuthBasic(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-auth-basic")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
gr := run.Group{}
ctx, cancel := context.WithCancel(context.Background())
+2 -1
View File
@@ -12,6 +12,7 @@ import (
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
@@ -27,7 +28,7 @@ func AuthBearer(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-auth-bearer")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
gr := run.Group{}
ctx, cancel := context.WithCancel(context.Background())
+2 -1
View File
@@ -12,6 +12,7 @@ import (
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
@@ -27,7 +28,7 @@ func AuthMachine(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-auth-machine")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
gr := run.Group{}
ctx, cancel := context.WithCancel(context.Background())
+2 -1
View File
@@ -16,6 +16,7 @@ import (
"github.com/owncloud/ocis/ocis-pkg/conversions"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
@@ -34,7 +35,7 @@ func Frontend(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-frontend")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
+12 -12
View File
@@ -15,10 +15,10 @@ import (
"github.com/oklog/run"
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/version"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/service/external"
"github.com/owncloud/ocis/storage/pkg/tracing"
@@ -43,7 +43,7 @@ func Gateway(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
gr := run.Group{}
ctx, cancel := context.WithCancel(context.Background())
@@ -388,16 +388,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config, storageExtension string) er
}
// 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.Commons == nil {
cfg.Log = &shared.Log{}
}
//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.Commons == nil {
// cfg.Log = &shared.Log{}
//}
// load all env variables relevant to the config in the current context.
conf.LoadOSEnv(config.GetEnv(cfg), false)
+2 -1
View File
@@ -13,6 +13,7 @@ import (
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
@@ -28,7 +29,7 @@ func Groups(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-groups")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
gr := run.Group{}
ctx, cancel := context.WithCancel(context.Background())
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"net/http"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/urfave/cli/v2"
)
@@ -17,7 +18,7 @@ func Health(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
resp, err := http.Get(
fmt.Sprintf(
+3 -13
View File
@@ -3,7 +3,6 @@ package command
import (
"os"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/version"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/urfave/cli/v2"
@@ -23,8 +22,10 @@ func Execute(cfg *config.Config) error {
Email: "support@owncloud.com",
},
},
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage")
cfg.Service.Version = version.String
return ParseConfig(c, cfg, "_")
},
Commands: []*cli.Command{
@@ -57,14 +58,3 @@ func Execute(cfg *config.Config) error {
return app.Run(os.Args)
}
// NewLogger initializes a service-specific logger instance.
func NewLogger(cfg *config.Config) log.Logger {
return log.NewLogger(
log.Name("storage"),
log.Level(cfg.Log.Level),
log.Pretty(cfg.Log.Pretty),
log.Color(cfg.Log.Color),
log.File(cfg.Log.File),
)
}
+2 -1
View File
@@ -7,6 +7,7 @@ import (
"path"
"path/filepath"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/owncloud/ocis/ocis-pkg/sync"
@@ -30,7 +31,7 @@ func Sharing(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-sharing")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
+2 -1
View File
@@ -7,6 +7,7 @@ import (
"path"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
@@ -29,7 +30,7 @@ func StorageHome(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-home")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
+2 -1
View File
@@ -7,6 +7,7 @@ import (
"path"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
@@ -34,7 +35,7 @@ func StorageMetadata(cfg *config.Config) *cli.Command {
},
Category: "Extensions",
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
gr := run.Group{}
+2 -1
View File
@@ -12,6 +12,7 @@ import (
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
@@ -28,7 +29,7 @@ func StoragePublicLink(cfg *config.Config) *cli.Command {
},
Category: "Extensions",
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
gr := run.Group{}
ctx, cancel := context.WithCancel(context.Background())
+2 -1
View File
@@ -13,6 +13,7 @@ import (
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/command/storagedrivers"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
@@ -28,7 +29,7 @@ func StorageUsers(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-userprovider")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)
+2 -1
View File
@@ -13,6 +13,7 @@ import (
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/logging"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/owncloud/ocis/storage/pkg/tracing"
"github.com/thejerf/suture/v4"
@@ -28,7 +29,7 @@ func Users(cfg *config.Config) *cli.Command {
return ParseConfig(c, cfg, "storage-users")
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
tracing.Configure(cfg, logger)