@ -128,7 +128,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 . renderResources ( chrt , valuesToRender , caps . APIVersions )
rel . Hooks , manifestDoc , rel . Info . Notes , err = i . cfg . renderResources ( chrt , valuesToRender )
// 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 ( )
@ -172,7 +172,7 @@ func (i *Install) Run(chrt *chart.Chart) (*release.Release, error) {
if ! i . DisableHooks {
if ! i . DisableHooks {
if err := i . execHook ( rel . Hooks , hooks . PreInstall ) ; err != nil {
if err := i . execHook ( rel . Hooks , hooks . PreInstall ) ; err != nil {
rel . SetStatus ( release . StatusFailed , "failed pre-install: " + err . Error ( ) )
rel . SetStatus ( release . StatusFailed , "failed pre-install: " + err . Error ( ) )
i. replaceRelease ( rel )
_ = i. replaceRelease ( rel )
return rel , err
return rel , err
}
}
}
}
@ -190,7 +190,7 @@ func (i *Install) Run(chrt *chart.Chart) (*release.Release, error) {
if ! i . DisableHooks {
if ! i . DisableHooks {
if err := i . execHook ( rel . Hooks , hooks . PostInstall ) ; err != nil {
if err := i . execHook ( rel . Hooks , hooks . PostInstall ) ; err != nil {
rel . SetStatus ( release . StatusFailed , "failed post-install: " + err . Error ( ) )
rel . SetStatus ( release . StatusFailed , "failed post-install: " + err . Error ( ) )
i. replaceRelease ( rel )
_ = i. replaceRelease ( rel )
return rel , err
return rel , err
}
}
}
}
@ -291,22 +291,23 @@ func (i *Install) replaceRelease(rel *release.Release) error {
}
}
// renderResources renders the templates in a chart
// renderResources renders the templates in a chart
func ( i * Install ) renderResources ( ch * chart . Chart , values chartutil . Values , vs chartutil . VersionSet ) ( [ ] * release . Hook , * bytes . Buffer , string , error ) {
func ( c * Configuration ) renderResources ( ch * chart . Chart , values chartutil . Values ) ( [ ] * release . Hook , * bytes . Buffer , string , error ) {
h ook s := [ ] * release . Hook { }
h s := [ ] * release . Hook { }
b := bytes . NewBuffer ( nil )
b := bytes . NewBuffer ( nil )
caps := c . capabilities ( )
if ch . Metadata . KubeVersion != "" {
if ch . Metadata . KubeVersion != "" {
cap , _ := values [ "Capabilities" ] . ( * chartutil . Capabilities )
gitVersion := caps . KubeVersion . String ( )
gitVersion := cap . KubeVersion . String ( )
k8sVersion := strings . Split ( gitVersion , "+" ) [ 0 ]
k8sVersion := strings . Split ( gitVersion , "+" ) [ 0 ]
if ! version . IsCompatibleRange ( ch . Metadata . KubeVersion , k8sVersion ) {
if ! version . IsCompatibleRange ( ch . Metadata . KubeVersion , k8sVersion ) {
return h ook s, b , "" , errors . Errorf ( "chart requires kubernetesVersion: %s which is incompatible with Kubernetes %s" , ch . Metadata . KubeVersion , k8sVersion )
return h s, b , "" , errors . Errorf ( "chart requires kubernetesVersion: %s which is incompatible with Kubernetes %s" , ch . Metadata . KubeVersion , k8sVersion )
}
}
}
}
files , err := engine . Render ( ch , values )
files , err := engine . Render ( ch , values )
if err != nil {
if err != nil {
return h ook s, b , "" , err
return h s, b , "" , 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,
@ -329,7 +330,7 @@ func (i *Install) renderResources(ch *chart.Chart, values chartutil.Values, vs c
// Sort hooks, manifests, and partials. Only hooks and manifests are returned,
// Sort hooks, manifests, and partials. Only hooks and manifests are returned,
// as partials are not used after renderer.Render. Empty manifests are also
// as partials are not used after renderer.Render. Empty manifests are also
// removed here.
// removed here.
h ook s, manifests , err := releaseutil . SortManifests ( files , v s, releaseutil . InstallOrder )
h s, manifests , err := releaseutil . SortManifests ( files , caps. APIVersion s, 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.
@ -337,12 +338,12 @@ func (i *Install) renderResources(ch *chart.Chart, values chartutil.Values, vs c
// We return the files as a big blob of data to help the user debug parser
// We return the files as a big blob of data to help the user debug parser
// errors.
// errors.
for name , content := range files {
for name , content := range files {
if len ( strings . TrimSpace ( content ) ) == 0 {
if strings . TrimSpace ( content ) == "" {
continue
continue
}
}
fmt . Fprintf ( b , "---\n# Source: %s\n%s\n" , name , content )
fmt . Fprintf ( b , "---\n# Source: %s\n%s\n" , name , content )
}
}
return h ook s, b , "" , err
return h s, b , "" , err
}
}
// Aggregate all valid manifests into one big doc.
// Aggregate all valid manifests into one big doc.
@ -350,7 +351,7 @@ func (i *Install) renderResources(ch *chart.Chart, values chartutil.Values, vs c
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 )
}
}
return h ook s, b , notes , nil
return h s, b , notes , nil
}
}
// validateManifest checks to see whether the given manifest is valid for the current Kubernetes
// validateManifest checks to see whether the given manifest is valid for the current Kubernetes