migrate ocis-pkg to envdecode
This commit is contained in:
committed by
Jörn Friedrich Dreyer
parent
412dadac45
commit
21ed07d90b
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
"github.com/owncloud/ocis/ocis/pkg/register"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/wkloucek/envdecode"
|
||||
)
|
||||
|
||||
// Execute is the entry point for the ocis command.
|
||||
@@ -55,15 +56,15 @@ func Execute() error {
|
||||
|
||||
// ParseConfig loads ocis configuration.
|
||||
func ParseConfig(c *cli.Context, cfg *config.Config) error {
|
||||
conf, err := ociscfg.BindSourcesToStructs("ocis", cfg)
|
||||
_, err := ociscfg.BindSourcesToStructs("ocis", cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: use envconfig here too
|
||||
// load all env variables relevant to the config in the current context.
|
||||
if err := envdecode.Decode(cfg); err != nil && err.Error() != "none of the target fields were set from environment variables" {
|
||||
return err
|
||||
}
|
||||
|
||||
conf.LoadOSEnv(config.GetEnv(), false)
|
||||
|
||||
bindings := config.StructMappings(cfg)
|
||||
return ociscfg.BindEnv(conf, bindings)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -168,10 +168,10 @@ func Start(o ...Option) error {
|
||||
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
|
||||
s.cfg.Storage.Log.File = s.cfg.Commons.File
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user