From bce6d0ec25fdcca6e309e2efe8c1f0b3daabea5a Mon Sep 17 00:00:00 2001 From: zsz <2492127354@qq.com> Date: Fri, 28 Feb 2025 13:32:18 +0800 Subject: [PATCH] fix: update repo_list.go (Closes 30606!) Signed-off-by: zsz <2492127354@qq.com> --- pkg/cmd/repo_list.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/repo_list.go b/pkg/cmd/repo_list.go index 5b6113a13..b8cc82b8d 100644 --- a/pkg/cmd/repo_list.go +++ b/pkg/cmd/repo_list.go @@ -21,7 +21,6 @@ import ( "io" "github.com/gosuri/uitable" - "github.com/pkg/errors" "github.com/spf13/cobra" "helm.sh/helm/v4/pkg/cli/output" @@ -39,10 +38,6 @@ func newRepoListCmd(out io.Writer) *cobra.Command { ValidArgsFunction: noMoreArgsCompFunc, RunE: func(_ *cobra.Command, _ []string) error { f, _ := repo.LoadFile(settings.RepositoryConfig) - if len(f.Repositories) == 0 && !(outfmt == output.JSON || outfmt == output.YAML) { - return errors.New("no repositories to show") - } - return outfmt.Write(out, &repoListWriter{f.Repositories}) }, } @@ -62,6 +57,10 @@ type repoListWriter struct { } func (r *repoListWriter) WriteTable(out io.Writer) error { + if len(r.repos) == 0 { + _, _ = fmt.Fprintln(out, "no repositories to show") + return nil + } table := uitable.New() table.AddRow("NAME", "URL") for _, re := range r.repos {