Fixing issue where helm show all fails to show crds when no readme

Closes #10058

Signed-off-by: Matt Farina <matt.farina@suse.com>
pull/10064/head
Matt Farina 4 years ago
parent c635f66103
commit 0ff53945bf
No known key found for this signature in database
GPG Key ID: 92C44A3D421FF7F9

@ -109,14 +109,13 @@ func (s *Show) Run(chartpath string) (string, error) {
}
if s.OutputFormat == ShowReadme || s.OutputFormat == ShowAll {
if s.OutputFormat == ShowAll {
fmt.Fprintln(&out, "---")
}
readme := findReadme(s.chart.Files)
if readme == nil {
return out.String(), nil
if readme != nil {
if s.OutputFormat == ShowAll {
fmt.Fprintln(&out, "---")
}
fmt.Fprintf(&out, "%s\n", readme.Data)
}
fmt.Fprintf(&out, "%s\n", readme.Data)
}
if s.OutputFormat == ShowCRDs || s.OutputFormat == ShowAll {

@ -120,3 +120,33 @@ bar
t.Errorf("Expected\n%q\nGot\n%q\n", expect, output)
}
}
func TestShowNoReadme(t *testing.T) {
client := NewShow(ShowAll)
client.chart = &chart.Chart{
Metadata: &chart.Metadata{Name: "alpine"},
Files: []*chart.File{
{Name: "crds/ignoreme.txt", Data: []byte("error")},
{Name: "crds/foo.yaml", Data: []byte("---\nfoo\n")},
{Name: "crds/bar.json", Data: []byte("---\nbar\n")},
},
}
output, err := client.Run("")
if err != nil {
t.Fatal(err)
}
expect := `name: alpine
---
foo
---
bar
`
if output != expect {
t.Errorf("Expected\n%q\nGot\n%q\n", expect, output)
}
}

Loading…
Cancel
Save