improve envdecode error handling

This commit is contained in:
Willy Kloucek
2022-01-03 09:43:42 +01:00
parent ea5dd75605
commit 6d0b754a86
14 changed files with 79 additions and 27 deletions
+6 -2
View File
@@ -2,6 +2,7 @@ package command
import (
"context"
"errors"
"os"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
@@ -72,8 +73,11 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
}
// 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
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
}
}
return nil
}