@ -89,6 +89,9 @@ type Install struct {
APIVersions chartutil . VersionSet
APIVersions chartutil . VersionSet
// Used by helm template to render charts with .Release.IsUpgrade. Ignored if Dry-Run is false
// Used by helm template to render charts with .Release.IsUpgrade. Ignored if Dry-Run is false
IsUpgrade bool
IsUpgrade bool
// Used by helm template to add the release as part of OutputDir path
// OutputDir/<ReleaseName>
UseReleaseName bool
}
}
// ChartPathOptions captures common options used for controlling chart paths
// ChartPathOptions captures common options used for controlling chart paths
@ -217,7 +220,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release.
rel := i . createRelease ( chrt , vals )
rel := i . createRelease ( chrt , vals )
var manifestDoc * bytes . Buffer
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 . ReleaseName, i . OutputDir, i . SubNotes , i . UseReleaseName )
// Even for errors, attach this if available
// Even for errors, attach this if available
if manifestDoc != nil {
if manifestDoc != nil {
rel . Manifest = manifestDoc . String ( )
rel . Manifest = manifestDoc . String ( )
@ -421,7 +424,7 @@ func (i *Install) replaceRelease(rel *release.Release) error {
}
}
// renderResources renders the templates in a chart
// 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 , releaseName string , outputDir string , subNotes , useReleaseName bool ) ( [ ] * release . Hook , * bytes . Buffer , string , error ) {
hs := [ ] * release . Hook { }
hs := [ ] * release . Hook { }
b := bytes . NewBuffer ( nil )
b := bytes . NewBuffer ( nil )
@ -498,7 +501,11 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values
if outputDir == "" {
if outputDir == "" {
fmt . Fprintf ( b , "---\n# Source: %s\n%s\n" , m . Name , m . Content )
fmt . Fprintf ( b , "---\n# Source: %s\n%s\n" , m . Name , m . Content )
} else {
} else {
err = writeToFile ( outputDir , m . Name , m . Content , fileWritten [ m . Name ] )
newDir := outputDir
if useReleaseName {
newDir = filepath . Join ( outputDir , releaseName )
}
err = writeToFile ( newDir , m . Name , m . Content , fileWritten [ m . Name ] )
if err != nil {
if err != nil {
return hs , b , "" , err
return hs , b , "" , err
}
}