diff --git a/accounts/cmd/helper/defaultconfig/main.go b/accounts/cmd/helper/defaultconfig/main.go deleted file mode 100644 index 1092497cb7..0000000000 --- a/accounts/cmd/helper/defaultconfig/main.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/owncloud/ocis/accounts/pkg/config" - "github.com/owncloud/ocis/accounts/pkg/config/parser" - "gopkg.in/yaml.v2" -) - -func main() { - - cfg := config.DefaultConfig() - - parser.EnsureDefaults(cfg) - parser.Sanitize(cfg) - - b, err := yaml.Marshal(cfg) - if err != nil { - return - } - fmt.Println(string(b)) -} diff --git a/accounts/pkg/config/parser/parse.go b/accounts/pkg/config/parser/parse.go index e437fa6a07..fb801aed28 100644 --- a/accounts/pkg/config/parser/parse.go +++ b/accounts/pkg/config/parser/parse.go @@ -17,28 +17,6 @@ func ParseConfig(cfg *config.Config) error { return err } - err = EnsureDefaults(cfg) - if err != nil { - return err - } - - // load all env variables relevant to the config in the current context. - if err := envdecode.Decode(cfg); err != nil { - // no environment variable set for this config is an expected "error" - if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) { - return err - } - } - - err = Sanitize(cfg) - if err != nil { - return err - } - - return nil -} - -func EnsureDefaults(cfg *config.Config) error { // 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 = &config.Log{ @@ -62,14 +40,19 @@ func EnsureDefaults(cfg *config.Config) error { cfg.Tracing = &config.Tracing{} } - return nil -} + // load all env variables relevant to the config in the current context. + if err := envdecode.Decode(cfg); err != nil { + // no environment variable set for this config is an expected "error" + if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) { + return err + } + } -func Sanitize(cfg *config.Config) error { // sanitize config if cfg.HTTP.Root != "/" { cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/") } cfg.Repo.Backend = strings.ToLower(cfg.Repo.Backend) + return nil }