Unverified Commit d4c4d222 authored by Matthew Fisher's avatar Matthew Fisher Committed by GitHub

Merge pull request #4105 from balboah/feature/template_release_isinstall

Add helm template --is-upgrade
parents 086139ab 93e8f0a6
...@@ -63,18 +63,19 @@ To render just one template in a chart, use '-x': ...@@ -63,18 +63,19 @@ To render just one template in a chart, use '-x':
` `
type templateCmd struct { type templateCmd struct {
namespace string namespace string
valueFiles valueFiles valueFiles valueFiles
chartPath string chartPath string
out io.Writer out io.Writer
values []string values []string
stringValues []string stringValues []string
nameTemplate string nameTemplate string
showNotes bool showNotes bool
releaseName string releaseName string
renderFiles []string releaseIsUpgrade bool
kubeVersion string renderFiles []string
outputDir string kubeVersion string
outputDir string
} }
func newTemplateCmd(out io.Writer) *cobra.Command { func newTemplateCmd(out io.Writer) *cobra.Command {
...@@ -93,6 +94,7 @@ func newTemplateCmd(out io.Writer) *cobra.Command { ...@@ -93,6 +94,7 @@ func newTemplateCmd(out io.Writer) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.BoolVar(&t.showNotes, "notes", false, "show the computed NOTES.txt file as well") f.BoolVar(&t.showNotes, "notes", false, "show the computed NOTES.txt file as well")
f.StringVarP(&t.releaseName, "name", "n", "RELEASE-NAME", "release name") f.StringVarP(&t.releaseName, "name", "n", "RELEASE-NAME", "release name")
f.BoolVar(&t.releaseIsUpgrade, "is-upgrade", false, "set .Release.IsUpgrade instead of .Release.IsInstall")
f.StringArrayVarP(&t.renderFiles, "execute", "x", []string{}, "only execute the given templates") f.StringArrayVarP(&t.renderFiles, "execute", "x", []string{}, "only execute the given templates")
f.VarP(&t.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)") f.VarP(&t.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)")
f.StringVar(&t.namespace, "namespace", "", "namespace to install the release into") f.StringVar(&t.namespace, "namespace", "", "namespace to install the release into")
...@@ -159,6 +161,8 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error { ...@@ -159,6 +161,8 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error {
} }
options := chartutil.ReleaseOptions{ options := chartutil.ReleaseOptions{
Name: t.releaseName, Name: t.releaseName,
IsInstall: !t.releaseIsUpgrade,
IsUpgrade: t.releaseIsUpgrade,
Time: timeconv.Now(), Time: timeconv.Now(),
Namespace: t.namespace, Namespace: t.namespace,
} }
......
...@@ -107,6 +107,20 @@ func TestTemplateCmd(t *testing.T) { ...@@ -107,6 +107,20 @@ func TestTemplateCmd(t *testing.T) {
expectKey: "subchart1/templates/service.yaml", expectKey: "subchart1/templates/service.yaml",
expectValue: "release-name: \"test\"", expectValue: "release-name: \"test\"",
}, },
{
name: "check_release_is_install",
desc: "verify --is-upgrade toggles .Release.IsInstall",
args: []string{subchart1ChartPath, "--is-upgrade=false"},
expectKey: "subchart1/templates/service.yaml",
expectValue: "release-is-install: \"true\"",
},
{
name: "check_release_is_upgrade",
desc: "verify --is-upgrade toggles .Release.IsUpgrade",
args: []string{subchart1ChartPath, "--is-upgrade", "true"},
expectKey: "subchart1/templates/service.yaml",
expectValue: "release-is-upgrade: \"true\"",
},
{ {
name: "check_notes", name: "check_notes",
desc: "verify --notes shows notes", desc: "verify --notes shows notes",
......
...@@ -26,6 +26,7 @@ helm template [flags] CHART ...@@ -26,6 +26,7 @@ helm template [flags] CHART
``` ```
-x, --execute stringArray only execute the given templates -x, --execute stringArray only execute the given templates
--is-upgrade set .Release.IsUpgrade instead of .Release.IsInstall
--kube-version string kubernetes version used as Capabilities.KubeVersion.Major/Minor (default "1.9") --kube-version string kubernetes version used as Capabilities.KubeVersion.Major/Minor (default "1.9")
-n, --name string release name (default "RELEASE-NAME") -n, --name string release name (default "RELEASE-NAME")
--name-template string specify template used to name the release --name-template string specify template used to name the release
...@@ -51,4 +52,4 @@ helm template [flags] CHART ...@@ -51,4 +52,4 @@ helm template [flags] CHART
### SEE ALSO ### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes. * [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 9-Mar-2018 ###### Auto generated by spf13/cobra on 22-May-2018
...@@ -6,6 +6,8 @@ metadata: ...@@ -6,6 +6,8 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
namespace: "{{ .Release.Namespace }}" namespace: "{{ .Release.Namespace }}"
release-name: "{{ .Release.Name }}" release-name: "{{ .Release.Name }}"
release-is-upgrade: "{{ .Release.IsUpgrade }}"
release-is-install: "{{ .Release.IsInstall }}"
kube-version/major: "{{ .Capabilities.KubeVersion.Major }}" kube-version/major: "{{ .Capabilities.KubeVersion.Major }}"
kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}" kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}"
kube-version/gitversion: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0" kube-version/gitversion: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment