diff --git a/_proto/hapi/chart/metadata.proto b/_proto/hapi/chart/metadata.proto index 0ac695ce2..14d4ffdcc 100644 --- a/_proto/hapi/chart/metadata.proto +++ b/_proto/hapi/chart/metadata.proto @@ -90,4 +90,7 @@ message Metadata { // KubeVersion is a SemVer constraint specifying the version of Kubernetes required. string kubeVersion = 17; + + // Whether or not the app version can be override by flag --app-version (during install or update) + bool overrideAppVersion = 18; } diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 05321f1f7..68bbe057d 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,14 @@ func (i *installCmd) run() error { return fmt.Errorf("cannot load requirements: %v", err) } + if i.appVersion != "" { + if !chartRequested.Metadata.OverrideAppVersion { + return fmt.Errorf("override app version is not allowed on this chart") + } + + 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..56ac591a4 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.") @@ -240,22 +242,32 @@ 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 != "" { + if !chart.Metadata.OverrideAppVersion { + return fmt.Errorf("override app version is not allowed on this chart") + } + + 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..fd1648aea 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 21-Mar-2019 diff --git a/docs/helm/helm_upgrade.md b/docs/helm/helm_upgrade.md index f18bcf6a7..401c49da7 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 21-Mar-2019 diff --git a/pkg/proto/hapi/chart/metadata.pb.go b/pkg/proto/hapi/chart/metadata.pb.go index 9daeaa9e5..3aaddcf26 100644 --- a/pkg/proto/hapi/chart/metadata.pb.go +++ b/pkg/proto/hapi/chart/metadata.pb.go @@ -109,6 +109,8 @@ type Metadata struct { Annotations map[string]string `protobuf:"bytes,16,rep,name=annotations" json:"annotations,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // KubeVersion is a SemVer constraint specifying the version of Kubernetes required. KubeVersion string `protobuf:"bytes,17,opt,name=kubeVersion" json:"kubeVersion,omitempty"` + // Whether or not the app version can be override by flag --app-version (during install or update) + OverrideAppVersion bool `protobuf:"varint,18,opt,name=overrideAppVersion" json:"overrideAppVersion,omitempty"` } func (m *Metadata) Reset() { *m = Metadata{} } @@ -235,6 +237,13 @@ func (m *Metadata) GetKubeVersion() string { return "" } +func (m *Metadata) GetOverrideAppVersion() bool { + if m != nil { + return m.OverrideAppVersion + } + return false +} + func init() { proto.RegisterType((*Maintainer)(nil), "hapi.chart.Maintainer") proto.RegisterType((*Metadata)(nil), "hapi.chart.Metadata") @@ -244,33 +253,34 @@ func init() { func init() { proto.RegisterFile("hapi/chart/metadata.proto", fileDescriptor2) } var fileDescriptor2 = []byte{ - // 435 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x5d, 0x6b, 0xd4, 0x40, - 0x14, 0x35, 0xcd, 0x66, 0x77, 0x73, 0x63, 0x35, 0x0e, 0x52, 0xc6, 0x22, 0x12, 0x16, 0x85, 0x7d, - 0xda, 0x82, 0xbe, 0x14, 0x1f, 0x04, 0x85, 0x52, 0x41, 0xbb, 0x95, 0xe0, 0x07, 0xf8, 0x36, 0x4d, - 0x2e, 0xdd, 0x61, 0x93, 0x99, 0x30, 0x99, 0xad, 0xec, 0xaf, 0xf0, 0x2f, 0xcb, 0xdc, 0x64, 0x9a, - 0xac, 0xf4, 0xed, 0x9e, 0x73, 0x66, 0xce, 0xcc, 0xbd, 0xf7, 0xc0, 0x8b, 0x8d, 0x68, 0xe4, 0x59, - 0xb1, 0x11, 0xc6, 0x9e, 0xd5, 0x68, 0x45, 0x29, 0xac, 0x58, 0x35, 0x46, 0x5b, 0xcd, 0xc0, 0x49, - 0x2b, 0x92, 0x16, 0x9f, 0x01, 0xae, 0x84, 0x54, 0x56, 0x48, 0x85, 0x86, 0x31, 0x98, 0x28, 0x51, - 0x23, 0x0f, 0xb2, 0x60, 0x19, 0xe7, 0x54, 0xb3, 0xe7, 0x10, 0x61, 0x2d, 0x64, 0xc5, 0x8f, 0x88, - 0xec, 0x00, 0x4b, 0x21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, 0x3c, 0x25, 0x8b, 0x43, 0x92, 0x5d, - 0x42, 0x22, 0x94, 0xd2, 0x56, 0xb8, 0x7f, 0xb4, 0x3c, 0xa5, 0xe9, 0xbc, 0x39, 0x98, 0x8e, 0xcf, - 0xd2, 0xc7, 0xe1, 0xdc, 0x85, 0xb2, 0x66, 0x9f, 0x8f, 0x6f, 0xba, 0x25, 0x6d, 0x77, 0x37, 0xe8, - 0x1f, 0x7b, 0xd6, 0x2d, 0x69, 0x44, 0x9d, 0x7e, 0x80, 0xf4, 0x7f, 0x0b, 0x97, 0xaa, 0x2d, 0xee, - 0xfb, 0xd4, 0xb8, 0xd2, 0xa5, 0xef, 0x4e, 0x54, 0x3b, 0x9f, 0x9a, 0x0e, 0xbc, 0x3f, 0x3a, 0x0f, - 0x16, 0x19, 0x4c, 0x2f, 0xba, 0x05, 0x24, 0x30, 0xfb, 0xb1, 0xfe, 0xb2, 0xbe, 0xfe, 0xb5, 0x4e, - 0x1f, 0xb1, 0x18, 0xa2, 0xcb, 0xeb, 0xef, 0xdf, 0xbe, 0xa6, 0xc1, 0xa7, 0xd9, 0xef, 0x88, 0xfe, - 0x7c, 0x33, 0xa5, 0xdc, 0xbf, 0xfb, 0x17, 0x00, 0x00, 0xff, 0xff, 0x36, 0xf9, 0x0d, 0xa6, 0x14, + // 451 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x5d, 0x6b, 0xd4, 0x40, + 0x14, 0x35, 0xcd, 0x66, 0x77, 0x73, 0x63, 0x35, 0x5e, 0xa4, 0x8c, 0x45, 0x24, 0x2c, 0x0a, 0xfb, + 0x94, 0x82, 0xbe, 0x14, 0x1f, 0x84, 0x0a, 0xa5, 0x82, 0x76, 0x2b, 0xc1, 0x0f, 0xf0, 0x6d, 0x9a, + 0x5c, 0xba, 0xc3, 0x26, 0x33, 0x61, 0x32, 0xbb, 0xb2, 0xbf, 0x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