maintain backwards compatibility in the api for the CRDs function

Signed-off-by: Mike Tougeron <tougeron@adobe.com>
pull/7440/head
Mike Tougeron 6 years ago
parent 804e07300b
commit 93adb35af1

@ -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 // Pre-install anything in the crd/ directory. We do this before Helm
// contacts the upstream server and builds the capabilities object. // 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 // On dry run, bail here
if i.DryRun { if i.DryRun {
i.cfg.Log("WARNING: This chart or one of its subcharts contains CRDs. Rendering may fail or contain inaccuracies.") 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) fileWritten := make(map[string]bool)
if includeCrds { if includeCrds {
for _, crd := range ch.CRDs() { for _, crd := range ch.CRDObjects() {
if outputDir == "" { if outputDir == "" {
fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Name, string(crd.File.Data[:])) fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Name, string(crd.File.Data[:]))
} else { } else {

@ -129,8 +129,25 @@ func (ch *Chart) AppVersion() string {
return ch.Metadata.AppVersion return ch.Metadata.AppVersion
} }
// CRDs returns a list of CRD objects in the 'crds/' directory of a Helm chart & subcharts // CRDs returns a list of File objects in the 'crds/' directory of a Helm chart.
func (ch *Chart) CRDs() []CRD { // 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{} crds := []CRD{}
// Find all resources in the crds/ directory // Find all resources in the crds/ directory
for _, f := range ch.Files { for _, f := range ch.Files {
@ -141,7 +158,7 @@ func (ch *Chart) CRDs() []CRD {
} }
// Get CRDs from dependencies, too. // Get CRDs from dependencies, too.
for _, dep := range ch.Dependencies() { for _, dep := range ch.Dependencies() {
crds = append(crds, dep.CRDs()...) crds = append(crds, dep.CRDObjects()...)
} }
return crds return crds
} }

Loading…
Cancel
Save