fix(helm): ignore file-not-found error for `helm repo list -o json`

Currently, `helm repo list -o json` returns (either `[]` or an english
"no repositories" error message, depending on whether
`$HELM_CONFIG_HOME/repositories.yaml` exists). This PR aligns the two cases
so that it always returns `[]`.

Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
pull/10519/head
Teo Klestrup Röijezon 3 years ago
parent b8d3535991
commit 94779dc99f

@ -38,8 +38,8 @@ func newRepoListCmd(out io.Writer) *cobra.Command {
Args: require.NoArgs,
ValidArgsFunction: noCompletions,
RunE: func(cmd *cobra.Command, args []string) error {
f, err := repo.LoadFile(settings.RepositoryConfig)
if isNotExist(err) || (len(f.Repositories) == 0 && !(outfmt == output.JSON || outfmt == output.YAML)) {
f, _ := repo.LoadFile(settings.RepositoryConfig)
if len(f.Repositories) == 0 && !(outfmt == output.JSON || outfmt == output.YAML) {
return errors.New("no repositories to show")
}

Loading…
Cancel
Save