Skip to content

Commit

Permalink
fix(helm): ignore file-not-found error for helm repo list -o json
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nightkr committed Jan 4, 2022
1 parent b8d3535 commit 94779dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/helm/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit 94779dc

Please sign in to comment.