|
|
|
@ -83,6 +83,7 @@ type Install struct {
|
|
|
|
|
OutputDir string
|
|
|
|
|
Atomic bool
|
|
|
|
|
SkipCRDs bool
|
|
|
|
|
IncludeCRDs bool
|
|
|
|
|
SubNotes bool
|
|
|
|
|
// APIVersions allows a manual set of supported API Versions to be passed
|
|
|
|
|
// (for things like templating). These are ignored if ClientOnly is false
|
|
|
|
@ -111,12 +112,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)
|
|
|
|
|
}
|
|
|
|
@ -217,7 +218,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.OutputDir, i.SubNotes)
|
|
|
|
|
rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.OutputDir, i.SubNotes, i.IncludeCRDs)
|
|
|
|
|
// Even for errors, attach this if available
|
|
|
|
|
if manifestDoc != nil {
|
|
|
|
|
rel.Manifest = manifestDoc.String()
|
|
|
|
@ -421,7 +422,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, outputDir string, subNotes bool) ([]*release.Hook, *bytes.Buffer, string, error) {
|
|
|
|
|
func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, outputDir string, subNotes bool, includeCrds bool) ([]*release.Hook, *bytes.Buffer, string, error) {
|
|
|
|
|
hs := []*release.Hook{}
|
|
|
|
|
b := bytes.NewBuffer(nil)
|
|
|
|
|
|
|
|
|
@ -494,6 +495,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.CRDs() {
|
|
|
|
|
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)
|
|
|
|
|