diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 1838bb758..17b6ec9b3 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -76,6 +76,18 @@ type templateCmd struct { renderFiles []string kubeVersion string outputDir string + + verify bool + keyring string + version string + repoURL string + username string + password string + devel bool + + certFile string + keyFile string + caFile string } func newTemplateCmd(out io.Writer) *cobra.Command { @@ -104,6 +116,16 @@ func newTemplateCmd(out io.Writer) *cobra.Command { f.StringVar(&t.nameTemplate, "name-template", "", "specify template used to name the release") 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") + f.StringVar(&t.version, "version", "", "version of the chart. By default, the newest chart is selected") + f.BoolVar(&t.verify, "verify", false, "verify the provenance data for this chart") + f.StringVar(&t.keyring, "keyring", defaultKeyring(), "location of public keys used for verification") + f.StringVar(&t.repoURL, "repo", "", "chart repository url where to locate the requested chart") + f.StringVar(&t.username, "username", "", "chart repository username where to locate the requested chart") + f.StringVar(&t.password, "password", "", "chart repository password where to locate the requested chart") + f.BoolVar(&t.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") + f.StringVar(&t.certFile, "cert-file", "", "identify HTTPS client using this SSL certificate file") + f.StringVar(&t.keyFile, "key-file", "", "identify HTTPS client using this SSL key file") + f.StringVar(&t.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") return cmd } @@ -112,12 +134,8 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error { if len(args) < 1 { return errors.New("chart is required") } - // verify chart path exists - if _, err := os.Stat(args[0]); err == nil { - if t.chartPath, err = filepath.Abs(args[0]); err != nil { - return err - } - } else { + + if err := t.prepareChart(args[0]); err != nil { return err } @@ -253,6 +271,30 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error { return nil } +func (t *templateCmd) prepareChart(chart string) error { + // verify chart path exists or can be fetched from remote repo + if _, err := os.Stat(chart); err == nil { + if t.chartPath, err = filepath.Abs(chart); err != nil { + return err + } + return nil + } + + debug("Original chart version: %q", t.version) + if t.version == "" && t.devel { + debug("setting version to >0.0.0-0") + t.version = ">0.0.0-0" + } + + cp, err := locateChartPath(t.repoURL, t.username, t.password, chart, t.version, false, t.keyring, + t.certFile, t.keyFile, t.caFile) + if err != nil { + return err + } + t.chartPath = cp + return nil +} + // write the to / func writeToFile(outputDir string, name string, data string) error { outfileName := strings.Join([]string{outputDir, name}, string(filepath.Separator)) diff --git a/docs/helm/helm_template.md b/docs/helm/helm_template.md index 805556096..4ac0607a4 100644 --- a/docs/helm/helm_template.md +++ b/docs/helm/helm_template.md @@ -24,19 +24,29 @@ helm template [flags] CHART ### Options ``` + --ca-file string verify certificates of HTTPS-enabled servers using this CA bundle + --cert-file string identify HTTPS client using this SSL certificate file + --devel use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored. -x, --execute stringArray only execute the given templates -h, --help help for template --is-upgrade set .Release.IsUpgrade instead of .Release.IsInstall + --key-file string identify HTTPS client using this SSL key file + --keyring string location of public keys used for verification (default "~/.gnupg/pubring.gpg") --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 --notes show the computed NOTES.txt file as well --output-dir string writes the executed templates to files in output-dir instead of stdout + --password string chart repository password where to locate the requested chart + --repo string chart repository url where to locate the requested chart --set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2) --set-file stringArray set values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2) --set-string stringArray set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2) + --username string chart repository username where to locate the requested chart -f, --values valueFiles specify values in a YAML file (can specify multiple) (default []) + --verify verify the provenance data for this chart + --version string version of the chart. By default, the newest chart is selected ``` ### Options inherited from parent commands @@ -55,4 +65,4 @@ helm template [flags] CHART * [helm](helm.md) - The Helm package manager for Kubernetes. -###### Auto generated by spf13/cobra on 1-Aug-2018 +###### Auto generated by spf13/cobra on 28-May-2019