Merge pull request #7753 from anshulvermapatel/helm/7749/helm_list_short_listing_format

Solves the issue #7749
pull/7806/head
Matt Farina 5 years ago committed by GitHub
commit 22344063d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,10 +83,29 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
}
if client.Short {
names := make([]string, 0)
for _, res := range results {
fmt.Fprintln(out, res.Name)
names = append(names, res.Name)
}
outputFlag := cmd.Flag("output")
switch outputFlag.Value.String() {
case "json":
output.EncodeJSON(out, names)
return nil
case "yaml":
output.EncodeYAML(out, names)
return nil
case "table":
for _, res := range results {
fmt.Fprintln(out, res.Name)
}
return nil
default:
return outfmt.Write(out, newReleaseListWriter(results))
}
return nil
}
return outfmt.Write(out, newReleaseListWriter(results))

@ -198,6 +198,16 @@ func TestListCmd(t *testing.T) {
cmd: "list --short",
golden: "output/list-short.txt",
rels: releaseFixture,
}, {
name: "list releases in short output format",
cmd: "list --short --output yaml",
golden: "output/list-short-yaml.txt",
rels: releaseFixture,
}, {
name: "list releases in short output format",
cmd: "list --short --output json",
golden: "output/list-short-json.txt",
rels: releaseFixture,
}, {
name: "list superseded releases",
cmd: "list --superseded",

@ -0,0 +1 @@
["hummingbird","iguana","rocket","starlord"]

@ -0,0 +1,4 @@
- hummingbird
- iguana
- rocket
- starlord
Loading…
Cancel
Save