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
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
+5 -12
View File
@@ -5,7 +5,6 @@ import (
"github.com/owncloud/ocis/ocis-pkg/config"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/version"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
@@ -20,9 +19,12 @@ func Execute() error {
Version: version.String,
Usage: "ownCloud Infinite Scale Stack",
Compiled: version.Compiled(),
Before: func(c *cli.Context) error {
//cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
@@ -51,17 +53,6 @@ func Execute() 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("ocis"),
log.Level(cfg.Log.Level),
log.Pretty(cfg.Log.Pretty),
log.Color(cfg.Log.Color),
log.File(cfg.Log.File),
)
}
// ParseConfig loads ocis configuration.
func ParseConfig(c *cli.Context, cfg *config.Config) error {
conf, err := ociscfg.BindSourcesToStructs("ocis", cfg)
@@ -69,6 +60,8 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
return err
}
// TODO: use envconfig here too
conf.LoadOSEnv(config.GetEnv(), false)
bindings := config.StructMappings(cfg)
+3 -8
View File
@@ -1,11 +1,6 @@
//go:build !simple
// +build !simple
package command
import (
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/ocis/pkg/runtime"
@@ -23,9 +18,9 @@ func Server(cfg *config.Config) *cli.Command {
},
Action: func(c *cli.Context) error {
cfg.Commons = &shared.Commons{
Log: &cfg.Log,
}
//cfg.Commons = &shared.Commons{
// Log: &cfg.Log,
//}
r := runtime.New(cfg)
return r.Start()
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
+6 -10
View File
@@ -1,11 +1,7 @@
//go:build !simple
// +build !simple
package command
import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/store/pkg/command"
"github.com/urfave/cli/v2"
@@ -13,7 +9,7 @@ import (
// StoreCommand is the entrypoint for the ocs command.
func StoreCommand(cfg *config.Config) *cli.Command {
var globalLog shared.Log
//var globalLog shared.Log
return &cli.Command{
Name: "store",
@@ -27,16 +23,16 @@ func StoreCommand(cfg *config.Config) *cli.Command {
return err
}
globalLog = cfg.Log
//globalLog = cfg.Log
return nil
},
Action: func(c *cli.Context) error {
// if accounts logging is empty in ocis.yaml
if (cfg.Store.Log == shared.Log{}) && (globalLog != shared.Log{}) {
// we can safely inherit the global logging values.
cfg.Store.Log = globalLog
}
//if (cfg.Store.Log == shared.Log{}) && (globalLog != shared.Log{}) {
// // we can safely inherit the global logging values.
// cfg.Store.Log = globalLog
//}
origCmd := command.Server(cfg.Store)
return handleOriginalAction(c, origCmd)
+3 -6
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (
@@ -24,9 +21,9 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command {
return err
}
if cfg.Commons != nil {
cfg.Thumbnails.Commons = cfg.Commons
}
//if cfg.Commons != nil {
// cfg.Thumbnails.Commons = cfg.Commons
//}
return nil
},
+10 -11
View File
@@ -2,7 +2,6 @@ package command
import (
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/urfave/cli/v2"
)
@@ -11,16 +10,16 @@ func ParseStorageCommon(ctx *cli.Context, cfg *config.Config) error {
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{}
}
//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
}
+3 -3
View File
@@ -18,9 +18,9 @@ func WebCommand(cfg *config.Config) *cli.Command {
return err
}
if cfg.Commons != nil {
cfg.Web.Commons = cfg.Commons
}
//if cfg.Commons != nil {
// cfg.Web.Commons = cfg.Commons
//}
return nil
},
-3
View File
@@ -1,6 +1,3 @@
//go:build !simple
// +build !simple
package command
import (