diff options
| author | James Elliott <james-d-elliott@users.noreply.github.com> | 2023-04-11 20:52:04 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-11 20:52:04 +1000 |
| commit | 569af0fef0168e60cb7b56697fb1f000bef8f34c (patch) | |
| tree | f9afe0105459be82e9182226e0eb068977dc90e3 /internal/commands/util.go | |
| parent | 0312defcd74bc9d9c5d7d981f1555b7258e10f62 (diff) | |
fix(commands): storage cmd fail when implicit config absent (#5213)
This fixes an issue where if the implicit config location of configuration.yml does not exist that an error is returned. This does not affect the behavior when the method was either implicit or environment.
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Diffstat (limited to 'internal/commands/util.go')
| -rw-r--r-- | internal/commands/util.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/internal/commands/util.go b/internal/commands/util.go index 4950c271b..bab9c70c9 100644 --- a/internal/commands/util.go +++ b/internal/commands/util.go @@ -215,13 +215,14 @@ const ( func loadXEnvCLIConfigValues(cmd *cobra.Command) (configs []string, filters []configuration.FileFilter, err error) { var ( filterNames []string + result XEnvCLIResult ) - if configs, _, err = loadXEnvCLIStringSliceValue(cmd, cmdFlagEnvNameConfig, cmdFlagNameConfig); err != nil { + if configs, result, err = loadXEnvCLIStringSliceValue(cmd, cmdFlagEnvNameConfig, cmdFlagNameConfig); err != nil { return nil, nil, err } - if configs, err = loadXNormalizedPaths(configs); err != nil { + if configs, err = loadXNormalizedPaths(configs, result); err != nil { return nil, nil, err } @@ -236,7 +237,7 @@ func loadXEnvCLIConfigValues(cmd *cobra.Command) (configs []string, filters []co return } -func loadXNormalizedPaths(paths []string) ([]string, error) { +func loadXNormalizedPaths(paths []string, result XEnvCLIResult) ([]string, error) { var ( configs, files, dirs []string err error @@ -258,10 +259,15 @@ func loadXNormalizedPaths(paths []string) ([]string, error) { files = append(files, path) default: if os.IsNotExist(err) { - configs = append(configs, path) - files = append(files, path) - - continue + switch result { + case XEnvCLIResultCLIImplicit: + continue + default: + configs = append(configs, path) + files = append(files, path) + + continue + } } return nil, fmt.Errorf("error occurred stating file at path '%s': %w", path, err) |
