diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 988e7f0a1..59d424f03 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -118,6 +118,7 @@ type installCmd struct { wait bool repoURL string devel bool + annotations []string certFile string keyFile string @@ -193,6 +194,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command { f.StringVar(&inst.keyFile, "key-file", "", "identify HTTPS client using this SSL key file") f.StringVar(&inst.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") f.BoolVar(&inst.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-a'. If --version is set, this is ignored.") + f.StringArrayVar(&inst.annotations, "annotations", []string{}, "set release annotations (can specify multiple or separate values with commas: key1=val1,key2=val2)") return cmd } @@ -209,6 +211,11 @@ func (i *installCmd) run() error { return err } + annotations, err := parseAnnotations(i.annotations) + if err != nil { + return err + } + // If template is specified, try to run the template. if i.nameTemplate != "" { i.name, err = generateName(i.nameTemplate) @@ -245,7 +252,8 @@ func (i *installCmd) run() error { helm.InstallReuseName(i.replace), helm.InstallDisableHooks(i.disableHooks), helm.InstallTimeout(i.timeout), - helm.InstallWait(i.wait)) + helm.InstallWait(i.wait), + helm.InstallAnnotations(annotations)) if err != nil { return prettyError(err) } @@ -462,3 +470,17 @@ func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements) error { } return nil } + +func parseAnnotations(input []string) (map[string]string, error) { + annotations := map[string]string{} + for _, a := range input { + for _, s := range strings.Split(a, ",") { + v := strings.Split(s, "=") + if len(v) < 2 || len(v[0]) == 0 { + return nil, fmt.Errorf("invalid annotations format: '%s', should be =[value]", s) + } + annotations[v[0]] = v[1] + } + } + return annotations, nil +} diff --git a/cmd/helm/printer.go b/cmd/helm/printer.go index ebb24bf7d..b07560ec0 100644 --- a/cmd/helm/printer.go +++ b/cmd/helm/printer.go @@ -42,6 +42,10 @@ HOOKS: {{- end }} MANIFEST: {{.Release.Manifest}} +ANNOTATIONS: +{{- range $k, $v := .Release.Annotations }} +{{$k}}={{$v}} +{{- end }} ` func printRelease(out io.Writer, rel *release.Release) error { diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 989d73cdd..5ae45a867 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -74,6 +74,7 @@ type upgradeCmd struct { wait bool repoURL string devel bool + annotations []string certFile string keyFile string @@ -132,6 +133,7 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command { f.StringVar(&upgrade.keyFile, "key-file", "", "identify HTTPS client using this SSL key file") f.StringVar(&upgrade.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") f.BoolVar(&upgrade.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-a'. If --version is set, this is ignored.") + f.StringArrayVar(&upgrade.annotations, "annotations", []string{}, "set release annotations (can specify multiple or separate values with commas: key1=val1,key2=val2)") f.MarkDeprecated("disable-hooks", "use --no-hooks instead") @@ -168,6 +170,7 @@ func (u *upgradeCmd) run() error { namespace: u.namespace, timeout: u.timeout, wait: u.wait, + annotations: u.annotations, } return ic.run() } @@ -178,6 +181,11 @@ func (u *upgradeCmd) run() error { return err } + annotations, err := parseAnnotations(u.annotations) + if err != nil { + return 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 { @@ -202,7 +210,8 @@ func (u *upgradeCmd) run() error { helm.UpgradeTimeout(u.timeout), helm.ResetValues(u.resetValues), helm.ReuseValues(u.reuseValues), - helm.UpgradeWait(u.wait)) + helm.UpgradeWait(u.wait), + helm.UpgradeAnnotations(annotations)) if err != nil { return fmt.Errorf("UPGRADE FAILED: %v", prettyError(err)) }