diff --git a/pkg/action/show.go b/pkg/action/show.go index 9ba85234d..78fbbdc76 100644 --- a/pkg/action/show.go +++ b/pkg/action/show.go @@ -133,10 +133,10 @@ func (s *Show) Run(chartpath string) (string, error) { if s.OutputFormat == ShowCRDs || s.OutputFormat == ShowAll { crds := s.chart.CRDObjects() if len(crds) > 0 { - if s.OutputFormat == ShowAll && !bytes.HasPrefix(crds[0].File.Data, []byte("---")) { - fmt.Fprintln(&out, "---") - } for _, crd := range crds { + if !bytes.HasPrefix(crd.File.Data, []byte("---")) { + fmt.Fprintln(&out, "---") + } fmt.Fprintf(&out, "%s\n", string(crd.File.Data)) } } diff --git a/pkg/action/show_test.go b/pkg/action/show_test.go index 8b617ea85..5a92bb976 100644 --- a/pkg/action/show_test.go +++ b/pkg/action/show_test.go @@ -102,6 +102,7 @@ func TestShowCRDs(t *testing.T) { {Name: "crds/ignoreme.txt", Data: []byte("error")}, {Name: "crds/foo.yaml", Data: []byte("---\nfoo\n")}, {Name: "crds/bar.json", Data: []byte("---\nbar\n")}, + {Name: "crds/baz.yaml", Data: []byte("\nbaz\n")}, }, } @@ -116,6 +117,10 @@ foo --- bar +--- + +baz + ` if output != expect { t.Errorf("Expected\n%q\nGot\n%q\n", expect, output)