Merge pull request #3297 from superbrothers/display-default-kube-version

helm template: display the default value of --kube-version in help message
pull/3364/head
Matthew Fisher 7 years ago committed by GitHub
commit 2b92431476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,7 +42,12 @@ import (
const defaultDirectoryPermission = 0755
var whitespaceRegex = regexp.MustCompile(`^\s*$`)
var (
whitespaceRegex = regexp.MustCompile(`^\s*$`)
// defaultKubeVersion is the default value of --kube-version flag
defaultKubeVersion = fmt.Sprintf("%s.%s", chartutil.DefaultKubeVersion.Major, chartutil.DefaultKubeVersion.Minor)
)
const templateDesc = `
Render chart templates locally and display the output.
@ -92,7 +97,7 @@ func newTemplateCmd(out io.Writer) *cobra.Command {
f.StringVar(&t.namespace, "namespace", "", "namespace to install the release into")
f.StringArrayVar(&t.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
f.StringVar(&t.nameTemplate, "name-template", "", "specify template used to name the release")
f.StringVar(&t.kubeVersion, "kube-version", "", "override the Kubernetes version used as Capabilities.KubeVersion.Major/Minor (e.g. 1.7)")
f.StringVar(&t.kubeVersion, "kube-version", defaultKubeVersion, "kubernetes version used as Capabilities.KubeVersion.Major/Minor")
f.StringVar(&t.outputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout")
return cmd
@ -194,9 +199,8 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error {
KubeVersion: chartutil.DefaultKubeVersion,
TillerVersion: tversion.GetVersionProto(),
}
// If --kube-versionis set, try to parse it as SemVer, and override the
// kubernetes version
if t.kubeVersion != "" {
kv, err := semver.NewVersion(t.kubeVersion)
if err != nil {
return fmt.Errorf("could not parse a kubernetes version: %v", err)
@ -204,7 +208,7 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error {
caps.KubeVersion.Major = fmt.Sprint(kv.Major())
caps.KubeVersion.Minor = fmt.Sprint(kv.Minor())
caps.KubeVersion.GitVersion = fmt.Sprintf("v%d.%d.0", kv.Major(), kv.Minor())
}
vals, err := chartutil.ToRenderValuesCaps(c, config, options, caps)
if err != nil {
return err

@ -26,7 +26,7 @@ helm template [flags] CHART
```
-x, --execute stringArray only execute the given templates
--kube-version string override the Kubernetes version used as Capabilities.KubeVersion.Major/Minor (e.g. 1.7)
--kube-version string kubernetes version used as Capabilities.KubeVersion.Major/Minor (default "1.9")
-n, --name string release name (default "RELEASE-NAME")
--name-template string specify template used to name the release
--namespace string namespace to install the release into
@ -50,4 +50,4 @@ helm template [flags] CHART
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 15-Nov-2017
###### Auto generated by spf13/cobra on 17-Jan-2018

Loading…
Cancel
Save