Merge pull request #10064 from mattfarina/fix-10058

Fixing issue where helm show all fails to show crds when no readme
pull/10072/head
Matt Farina 3 years ago committed by GitHub
commit a9c957d35b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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