diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 17043bee54923e5a369b74b029b2fe11fe4272d0..00313f6b6b35b0711fbe606de65c1ace295d7eef 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -56,7 +56,7 @@ or $ helm install --set name=prod ./redis You can specify the '--values'/'-f' flag multiple times. The priority will be given to the -last (right-most) file specified. For example, if both myvalues.yaml and override.yaml +last (right-most) file specified. For example, if both myvalues.yaml and override.yaml contained a key called 'Test', the value set in override.yaml would take precedence: $ helm install -f myvalues.yaml -f override.yaml ./redis @@ -283,13 +283,11 @@ func (i *installCmd) printRelease(rel *release.Release) { return } // TODO: Switch to text/template like everything else. + fmt.Fprintf(i.out, "NAME: %s\n", rel.Name) if flagDebug { - fmt.Fprintf(i.out, "NAME: %s\n", rel.Name) fmt.Fprintf(i.out, "TARGET NAMESPACE: %s\n", rel.Namespace) fmt.Fprintf(i.out, "CHART: %s %s\n", rel.Chart.Metadata.Name, rel.Chart.Metadata.Version) fmt.Fprintf(i.out, "MANIFEST: %s\n", rel.Manifest) - } else { - fmt.Fprintf(i.out, "NAME: %s\n", rel.Name) } } diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 70ce9ea22deab26d40a34dfdb51659fecbde8f07..58b746490787fcdd416d9849fff3f112a1f8600c 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -21,13 +21,17 @@ import ( "io" "io/ioutil" "strings" + "time" "github.com/ghodss/yaml" "github.com/spf13/cobra" "k8s.io/helm/cmd/helm/strvals" + "k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/helm" + "k8s.io/helm/pkg/proto/hapi/release" "k8s.io/helm/pkg/storage/driver" + "k8s.io/helm/pkg/timeconv" ) const upgradeDesc = ` @@ -42,7 +46,7 @@ To override values in a chart, use either the '--values' flag and pass in a file or use the '--set' flag and pass configuration from the command line. You can specify the '--values'/'-f' flag multiple times. The priority will be given to the -last (right-most) file specified. For example, if both myvalues.yaml and override.yaml +last (right-most) file specified. For example, if both myvalues.yaml and override.yaml contained a key called 'Test', the value set in override.yaml would take precedence: $ helm install -f myvalues.yaml -f override.yaml ./redis @@ -146,7 +150,7 @@ func (u *upgradeCmd) run() error { return err } - _, err = u.client.UpdateRelease( + resp, err := u.client.UpdateRelease( u.release, chartPath, helm.UpdateValueOverrides(rawVals), @@ -157,8 +161,11 @@ func (u *upgradeCmd) run() error { return fmt.Errorf("UPGRADE FAILED: %v", prettyError(err)) } - success := u.release + " has been upgraded. Happy Helming!\n" - fmt.Fprintf(u.out, success) + if flagDebug { + u.printRelease(resp.Release) + } + + fmt.Fprintf(u.out, "Release %q has been upgraded. Happy Helming!\n", u.release) // Print the status like status command does status, err := u.client.ReleaseStatus(u.release) @@ -194,3 +201,26 @@ func (u *upgradeCmd) vals() ([]byte, error) { return yaml.Marshal(base) } + +// printRelease prints info about a release. +func (u *upgradeCmd) printRelease(rel *release.Release) error { + if rel == nil { + return nil + } + + cfg, err := chartutil.CoalesceValues(rel.Chart, rel.Config) + if err != nil { + return err + } + cfgStr, err := cfg.YAML() + if err != nil { + return err + } + + data := map[string]interface{}{ + "Release": rel, + "ComputedValues": cfgStr, + "ReleaseDate": timeconv.Format(rel.Info.LastDeployed, time.ANSIC), + } + return tpl(getTemplate, data, u.out) +} diff --git a/cmd/helm/upgrade_test.go b/cmd/helm/upgrade_test.go index 7eab8acde375304c63b2a5ceaf9c1a55526ff6e9..bd6f324cc8cd7b37f955948e882eb0b58a78b7c1 100644 --- a/cmd/helm/upgrade_test.go +++ b/cmd/helm/upgrade_test.go @@ -67,14 +67,14 @@ func TestUpgradeCmd(t *testing.T) { name: "upgrade a release", args: []string{"funny-bunny", chartPath}, resp: releaseMock(&releaseOptions{name: "funny-bunny", version: 2, chart: ch}), - expected: "funny-bunny has been upgraded. Happy Helming!\n", + expected: "Release \"funny-bunny\" has been upgraded. Happy Helming!\n", }, { name: "install a release with 'upgrade --install'", args: []string{"zany-bunny", chartPath}, flags: []string{"-i"}, resp: releaseMock(&releaseOptions{name: "zany-bunny", version: 1, chart: ch}), - expected: "zany-bunny has been upgraded. Happy Helming!\n", + expected: "Release \"zany-bunny\" has been upgraded. Happy Helming!\n", }, }