diff --git a/pkg/action/install.go b/pkg/action/install.go index 37ead9940..0f48be6ad 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -168,7 +168,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. // Pre-install anything in the crd/ directory. We do this before Helm // contacts the upstream server and builds the capabilities object. - if crds := chrt.CRDs(); !i.ClientOnly && !i.SkipCRDs && len(crds) > 0 { + if crds := chrt.CRDObjects(); !i.ClientOnly && !i.SkipCRDs && len(crds) > 0 { // On dry run, bail here if i.DryRun { i.cfg.Log("WARNING: This chart or one of its subcharts contains CRDs. Rendering may fail or contain inaccuracies.") @@ -497,7 +497,7 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values fileWritten := make(map[string]bool) if includeCrds { - for _, crd := range ch.CRDs() { + for _, crd := range ch.CRDObjects() { if outputDir == "" { fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Name, string(crd.File.Data[:])) } else { diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index 50b25c9b5..3ea7ea66f 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -129,8 +129,25 @@ func (ch *Chart) AppVersion() string { return ch.Metadata.AppVersion } -// CRDs returns a list of CRD objects in the 'crds/' directory of a Helm chart & subcharts -func (ch *Chart) CRDs() []CRD { +// CRDs returns a list of File objects in the 'crds/' directory of a Helm chart. +// Deprecated: use CRDObjects() +func (ch *Chart) CRDs() []*File { + files := []*File{} + // Find all resources in the crds/ directory + for _, f := range ch.Files { + if strings.HasPrefix(f.Name, "crds/") { + files = append(files, f) + } + } + // Get CRDs from dependencies, too. + for _, dep := range ch.Dependencies() { + files = append(files, dep.CRDs()...) + } + return files +} + +// CRDObjects returns a list of CRD objects in the 'crds/' directory of a Helm chart & subcharts +func (ch *Chart) CRDObjects() []CRD { crds := []CRD{} // Find all resources in the crds/ directory for _, f := range ch.Files { @@ -141,7 +158,7 @@ func (ch *Chart) CRDs() []CRD { } // Get CRDs from dependencies, too. for _, dep := range ch.Dependencies() { - crds = append(crds, dep.CRDs()...) + crds = append(crds, dep.CRDObjects()...) } return crds }