diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 05321f1f7..fa0182e81 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -129,6 +129,7 @@ type installCmd struct { fileValues []string nameTemplate string version string + appVersion string timeout int64 wait bool repoURL string @@ -209,6 +210,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command { f.BoolVar(&inst.verify, "verify", false, "verify the package before installing it") f.StringVar(&inst.keyring, "keyring", defaultKeyring(), "location of public keys used for verification") f.StringVar(&inst.version, "version", "", "specify the exact chart version to install. If this is not specified, the latest version is installed") + f.StringVar(&inst.appVersion, "app-version", "", "specify an app version for the release") f.Int64Var(&inst.timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") f.BoolVar(&inst.wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout") f.StringVar(&inst.repoURL, "repo", "", "chart repository url where to locate the requested chart") @@ -291,6 +293,10 @@ func (i *installCmd) run() error { return fmt.Errorf("cannot load requirements: %v", err) } + if i.appVersion != "" { + chartRequested.Metadata.AppVersion = i.appVersion + } + res, err := i.client.InstallReleaseFromChart( chartRequested, i.namespace, diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index d05987b8a..c02024c34 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -101,6 +101,7 @@ type upgradeCmd struct { install bool namespace string version string + appVersion string timeout int64 resetValues bool reuseValues bool @@ -162,6 +163,7 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command { f.BoolVarP(&upgrade.install, "install", "i", false, "if a release by this name doesn't already exist, run an install") f.StringVar(&upgrade.namespace, "namespace", "", "namespace to install the release into (only used if --install is set). Defaults to the current kube config namespace") f.StringVar(&upgrade.version, "version", "", "specify the exact chart version to use. If this is not specified, the latest version is used") + f.StringVar(&upgrade.appVersion, "app-version", "", "specify the app version to use for the upgrade") f.Int64Var(&upgrade.timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") f.BoolVar(&upgrade.resetValues, "reset-values", false, "when upgrading, reset the values to the ones built into the chart") f.BoolVar(&upgrade.reuseValues, "reuse-values", false, "when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' is specified, this is ignored.") @@ -227,6 +229,7 @@ func (u *upgradeCmd) run() error { stringValues: u.stringValues, fileValues: u.fileValues, namespace: u.namespace, + appVersion: u.appVersion, timeout: u.timeout, wait: u.wait, description: u.description, @@ -240,22 +243,28 @@ func (u *upgradeCmd) run() error { return err } + // load the chart to update + chart, err := chartutil.Load(chartPath) + if err != nil { + return prettyError(err) + } + // Check chart requirements to make sure all dependencies are present in /charts - if ch, err := chartutil.Load(chartPath); err == nil { - if req, err := chartutil.LoadRequirements(ch); err == nil { - if err := renderutil.CheckDependencies(ch, req); err != nil { - return err - } - } else if err != chartutil.ErrRequirementsNotFound { - return fmt.Errorf("cannot load requirements: %v", err) + if req, err := chartutil.LoadRequirements(chart); err == nil { + if err := renderutil.CheckDependencies(chart, req); err != nil { + return err } - } else { - return prettyError(err) + } else if err != chartutil.ErrRequirementsNotFound { + return fmt.Errorf("cannot load requirements: %v", err) + } + + if u.appVersion != "" { + chart.Metadata.AppVersion = u.appVersion } - resp, err := u.client.UpdateRelease( + resp, err := u.client.UpdateReleaseFromChart( u.release, - chartPath, + chart, helm.UpdateValueOverrides(rawVals), helm.UpgradeDryRun(u.dryRun), helm.UpgradeRecreate(u.recreate), diff --git a/docs/helm/helm_install.md b/docs/helm/helm_install.md index 05cdf1e4a..7ad1e4061 100644 --- a/docs/helm/helm_install.md +++ b/docs/helm/helm_install.md @@ -78,6 +78,7 @@ helm install [CHART] [flags] ### Options ``` + --app-version string specify an app version for the release --ca-file string verify certificates of HTTPS-enabled servers using this CA bundle --cert-file string identify HTTPS client using this SSL certificate file --dep-up run helm dependency update before installing the chart @@ -128,4 +129,4 @@ helm install [CHART] [flags] * [helm](helm.md) - The Helm package manager for Kubernetes. -###### Auto generated by spf13/cobra on 10-Aug-2018 +###### Auto generated by spf13/cobra on 22-Nov-2018 diff --git a/docs/helm/helm_upgrade.md b/docs/helm/helm_upgrade.md index f18bcf6a7..acc348369 100644 --- a/docs/helm/helm_upgrade.md +++ b/docs/helm/helm_upgrade.md @@ -65,6 +65,7 @@ helm upgrade [RELEASE] [CHART] [flags] ### Options ``` + --app-version string specify the app version to use for the upgrade --ca-file string verify certificates of HTTPS-enabled servers using this CA bundle --cert-file string identify HTTPS client using this SSL certificate file --description string specify the description to use for the upgrade, rather than the default @@ -115,4 +116,4 @@ helm upgrade [RELEASE] [CHART] [flags] * [helm](helm.md) - The Helm package manager for Kubernetes. -###### Auto generated by spf13/cobra on 24-Aug-2018 +###### Auto generated by spf13/cobra on 22-Nov-2018