@ -55,7 +55,7 @@ import (
// See https://github.com/helm/helm/issues/1528
// See https://github.com/helm/helm/issues/1528
const releaseNameMaxLen = 53
const releaseNameMaxLen = 53
// NOTESFILE_SUFFIX that we want to treat special. It goes through the templating engine
// notesFileSuffix that we want to treat special. It goes through the templating engine
// but it's not a yaml file (resource) hence can't have hooks, etc. And the user actually
// but it's not a yaml file (resource) hence can't have hooks, etc. And the user actually
// wants to see this file after rendering in the status command. However, it must be a suffix
// wants to see this file after rendering in the status command. However, it must be a suffix
// since there can be filepath in front of it.
// since there can be filepath in front of it.
@ -135,7 +135,7 @@ func (i *Install) Run(chrt *chart.Chart) (*release.Release, error) {
rel := i . createRelease ( chrt , i . rawValues )
rel := i . createRelease ( chrt , i . rawValues )
var manifestDoc * bytes . Buffer
var manifestDoc * bytes . Buffer
rel . Hooks , manifestDoc , rel . Info . Notes , err = i . cfg . renderResources ( chrt , valuesToRender , i . OutputDir )
rel . Hooks , manifestDoc , rel . Info . Notes , rel. Tests , err = i . cfg . renderResources ( chrt , valuesToRender , i . OutputDir )
// 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 ( )
@ -308,24 +308,25 @@ 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 ) ( [ ] * release . Hook , * bytes . Buffer , string , error ) {
func ( c * Configuration ) renderResources ( ch * chart . Chart , values chartutil . Values , outputDir string ) ( [ ] * release . Hook , * bytes . Buffer , string , [ ] * release . Test , error ) {
hs := [ ] * release . Hook { }
hs := [ ] * release . Hook { }
ts := [ ] * release . Test { }
b := bytes . NewBuffer ( nil )
b := bytes . NewBuffer ( nil )
caps , err := c . getCapabilities ( )
caps , err := c . getCapabilities ( )
if err != nil {
if err != nil {
return hs , b , "" , err
return hs , b , "" , ts, err
}
}
if ch . Metadata . KubeVersion != "" {
if ch . Metadata . KubeVersion != "" {
if ! version . IsCompatibleRange ( ch . Metadata . KubeVersion , caps . KubeVersion . String ( ) ) {
if ! version . IsCompatibleRange ( ch . Metadata . KubeVersion , caps . KubeVersion . String ( ) ) {
return hs , b , "" , errors. Errorf ( "chart requires kubernetesVersion: %s which is incompatible with Kubernetes %s" , ch . Metadata . KubeVersion , caps . KubeVersion . String ( ) )
return hs , b , "" , ts, errors. Errorf ( "chart requires kubernetesVersion: %s which is incompatible with Kubernetes %s" , ch . Metadata . KubeVersion , caps . KubeVersion . String ( ) )
}
}
}
}
files , err := engine . Render ( ch , values )
files , err := engine . Render ( ch , values )
if err != nil {
if err != nil {
return hs , b , "" , err
return hs , b , "" , ts, err
}
}
// NOTES.txt gets rendered like all the other files, but because it's not a hook nor a resource,
// NOTES.txt gets rendered like all the other files, but because it's not a hook nor a resource,
@ -345,10 +346,10 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values
}
}
}
}
// Sort hooks, manifests, and partials. Only hooks and manifests are returned,
// Sort hooks, tests, resource manifests, and partials. Only hooks, tests, and
// as partials are not used after renderer.Render. Empty manifests are also
// resource manifests are returned, as partials are not used after renderer.Render.
// removed here.
// Empty manifests and test manifests are also removed here.
hs , manifests , err := releaseutil . SortManifests ( files , caps . APIVersions , releaseutil . InstallOrder )
hs , manifests , tests, err := releaseutil . SortManifests ( files , caps . APIVersions , releaseutil . InstallOrder )
if err != nil {
if err != nil {
// By catching parse errors here, we can prevent bogus releases from going
// By catching parse errors here, we can prevent bogus releases from going
// to Kubernetes.
// to Kubernetes.
@ -361,7 +362,7 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values
}
}
fmt . Fprintf ( b , "---\n# Source: %s\n%s\n" , name , content )
fmt . Fprintf ( b , "---\n# Source: %s\n%s\n" , name , content )
}
}
return hs , b , "" , err
return hs , b , "" , ts, err
}
}
// Aggregate all valid manifests into one big doc.
// Aggregate all valid manifests into one big doc.
@ -371,12 +372,12 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values
} else {
} else {
err = writeToFile ( outputDir , m . Name , m . Content )
err = writeToFile ( outputDir , m . Name , m . Content )
if err != nil {
if err != nil {
return hs , b , "" , err
return hs , b , "" , ts, err
}
}
}
}
}
}
return hs , b , notes , nil
return hs , b , notes , tests , nil
}
}
// write the <data> to <output-dir>/<name>
// write the <data> to <output-dir>/<name>