feat(helm): add --app-version flag to 'helm install/upgrade'

When 'helm install/upgrade --app-version 1.0.0' is run, this will
override the chart app version

Closes #3555

Signed-off-by: Kevin Labesse <kevin@labesse.me>

docs(helm): add --app-version flags for 'helm install/upgrade'

Signed-off-by: Kevin Labesse <kevin@labesse.me>
pull/4961/head
Kevin Labesse 7 years ago
parent d3357fad37
commit 8ddaa4e0a9

@ -129,6 +129,7 @@ type installCmd struct {
fileValues []string fileValues []string
nameTemplate string nameTemplate string
version string version string
appVersion string
timeout int64 timeout int64
wait bool wait bool
repoURL string 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.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.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.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.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.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") 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) return fmt.Errorf("cannot load requirements: %v", err)
} }
if i.appVersion != "" {
chartRequested.Metadata.AppVersion = i.appVersion
}
res, err := i.client.InstallReleaseFromChart( res, err := i.client.InstallReleaseFromChart(
chartRequested, chartRequested,
i.namespace, i.namespace,

@ -101,6 +101,7 @@ type upgradeCmd struct {
install bool install bool
namespace string namespace string
version string version string
appVersion string
timeout int64 timeout int64
resetValues bool resetValues bool
reuseValues 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.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.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.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.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.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.") 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, stringValues: u.stringValues,
fileValues: u.fileValues, fileValues: u.fileValues,
namespace: u.namespace, namespace: u.namespace,
appVersion: u.appVersion,
timeout: u.timeout, timeout: u.timeout,
wait: u.wait, wait: u.wait,
description: u.description, description: u.description,
@ -240,22 +243,28 @@ func (u *upgradeCmd) run() error {
return err 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 // 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(chart); err == nil {
if req, err := chartutil.LoadRequirements(ch); err == nil { if err := renderutil.CheckDependencies(chart, req); err != nil {
if err := renderutil.CheckDependencies(ch, req); err != nil { return err
return err
}
} else if err != chartutil.ErrRequirementsNotFound {
return fmt.Errorf("cannot load requirements: %v", err)
} }
} else { } else if err != chartutil.ErrRequirementsNotFound {
return prettyError(err) 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, u.release,
chartPath, chart,
helm.UpdateValueOverrides(rawVals), helm.UpdateValueOverrides(rawVals),
helm.UpgradeDryRun(u.dryRun), helm.UpgradeDryRun(u.dryRun),
helm.UpgradeRecreate(u.recreate), helm.UpgradeRecreate(u.recreate),

@ -78,6 +78,7 @@ helm install [CHART] [flags]
### Options ### Options
``` ```
--app-version string specify an app version for the release
--ca-file string verify certificates of HTTPS-enabled servers using this CA bundle --ca-file string verify certificates of HTTPS-enabled servers using this CA bundle
--cert-file string identify HTTPS client using this SSL certificate file --cert-file string identify HTTPS client using this SSL certificate file
--dep-up run helm dependency update before installing the chart --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. * [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

@ -65,6 +65,7 @@ helm upgrade [RELEASE] [CHART] [flags]
### Options ### 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 --ca-file string verify certificates of HTTPS-enabled servers using this CA bundle
--cert-file string identify HTTPS client using this SSL certificate file --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 --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. * [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

Loading…
Cancel
Save