|
|
|
@ -85,6 +85,7 @@ type Install struct {
|
|
|
|
|
SkipCRDs bool
|
|
|
|
|
SubNotes bool
|
|
|
|
|
DisableOpenAPIValidation bool
|
|
|
|
|
IncludeCRDs bool
|
|
|
|
|
// APIVersions allows a manual set of supported API Versions to be passed
|
|
|
|
|
// (for things like templating). These are ignored if ClientOnly is false
|
|
|
|
|
APIVersions chartutil.VersionSet
|
|
|
|
@ -115,12 +116,12 @@ func NewInstall(cfg *Configuration) *Install {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (i *Install) installCRDs(crds []*chart.File) error {
|
|
|
|
|
func (i *Install) installCRDs(crds []chart.CRD) error {
|
|
|
|
|
// We do these one file at a time in the order they were read.
|
|
|
|
|
totalItems := []*resource.Info{}
|
|
|
|
|
for _, obj := range crds {
|
|
|
|
|
// Read in the resources
|
|
|
|
|
res, err := i.cfg.KubeClient.Build(bytes.NewBuffer(obj.Data), false)
|
|
|
|
|
res, err := i.cfg.KubeClient.Build(bytes.NewBuffer(obj.File.Data), false)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return errors.Wrapf(err, "failed to install CRD %s", obj.Name)
|
|
|
|
|
}
|
|
|
|
@ -171,7 +172,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.")
|
|
|
|
@ -221,7 +222,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release.
|
|
|
|
|
rel := i.createRelease(chrt, vals)
|
|
|
|
|
|
|
|
|
|
var manifestDoc *bytes.Buffer
|
|
|
|
|
rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.ReleaseName, i.OutputDir, i.SubNotes, i.UseReleaseName)
|
|
|
|
|
rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.ReleaseName, i.OutputDir, i.SubNotes, i.UseReleaseName, i.IncludeCRDs)
|
|
|
|
|
// Even for errors, attach this if available
|
|
|
|
|
if manifestDoc != nil {
|
|
|
|
|
rel.Manifest = manifestDoc.String()
|
|
|
|
@ -425,7 +426,7 @@ func (i *Install) replaceRelease(rel *release.Release) error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// renderResources renders the templates in a chart
|
|
|
|
|
func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, releaseName string, outputDir string, subNotes, useReleaseName bool) ([]*release.Hook, *bytes.Buffer, string, error) {
|
|
|
|
|
func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, releaseName string, outputDir string, subNotes, useReleaseName bool, includeCrds bool) ([]*release.Hook, *bytes.Buffer, string, error) {
|
|
|
|
|
hs := []*release.Hook{}
|
|
|
|
|
b := bytes.NewBuffer(nil)
|
|
|
|
|
|
|
|
|
@ -498,6 +499,21 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values
|
|
|
|
|
|
|
|
|
|
// Aggregate all valid manifests into one big doc.
|
|
|
|
|
fileWritten := make(map[string]bool)
|
|
|
|
|
|
|
|
|
|
if includeCrds {
|
|
|
|
|
for _, crd := range ch.CRDObjects() {
|
|
|
|
|
if outputDir == "" {
|
|
|
|
|
fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Name, string(crd.File.Data[:]))
|
|
|
|
|
} else {
|
|
|
|
|
err = writeToFile(outputDir, crd.Filename, string(crd.File.Data[:]), fileWritten[crd.Name])
|
|
|
|
|
if err != nil {
|
|
|
|
|
return hs, b, "", err
|
|
|
|
|
}
|
|
|
|
|
fileWritten[crd.Name] = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, m := range manifests {
|
|
|
|
|
if outputDir == "" {
|
|
|
|
|
fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content)
|
|
|
|
|