Merge pull request #31448 from laervn/feat/add-no-headers-option

feat(repo): add --no-headers option to 'helm repo list'
pull/31461/merge
Matt Farina 1 week ago committed by GitHub
commit 2108bc5070
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -30,6 +30,7 @@ import (
func newRepoListCmd(out io.Writer) *cobra.Command {
var outfmt output.Format
var noHeaders bool
cmd := &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
@ -46,12 +47,17 @@ func newRepoListCmd(out io.Writer) *cobra.Command {
return nil
}
return outfmt.Write(out, &repoListWriter{f.Repositories})
w := &repoListWriter{
repos: f.Repositories,
noHeaders: noHeaders,
}
return outfmt.Write(out, w)
},
}
cmd.Flags().BoolVar(&noHeaders, "no-headers", false, "suppress headers in the output")
bindOutputFlag(cmd, &outfmt)
return cmd
}
@ -61,12 +67,15 @@ type repositoryElement struct {
}
type repoListWriter struct {
repos []*repo.Entry
repos []*repo.Entry
noHeaders bool
}
func (r *repoListWriter) WriteTable(out io.Writer) error {
table := uitable.New()
table.AddRow("NAME", "URL")
if !r.noHeaders {
table.AddRow("NAME", "URL")
}
for _, re := range r.repos {
table.AddRow(re.Name, re.URL)
}

@ -48,6 +48,12 @@ func TestRepoList(t *testing.T) {
golden: "output/repo-list.txt",
wantError: false,
},
{
name: "list without headers",
cmd: fmt.Sprintf("repo list --repository-config %s --repository-cache %s --no-headers", repoFile2, rootDir),
golden: "output/repo-list-no-headers.txt",
wantError: false,
},
}
runTestCmd(t, tests)

@ -0,0 +1,3 @@
charts https://charts.helm.sh/stable
firstexample http://firstexample.com
secondexample http://secondexample.com
Loading…
Cancel
Save