From 9624f9461f90f6432873ca1272efa53b7d819fbf Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Hernandez Date: Sat, 13 Nov 2021 13:33:29 +0000 Subject: [PATCH] feat(helm): add chart name, version and app version to the status Signed-off-by: Carlos Rodriguez Hernandez --- cmd/helm/install_test.go | 2 +- cmd/helm/status.go | 11 +++++++---- cmd/helm/status_test.go | 9 +++++++-- .../testdata/output/chart-with-subchart-update.txt | 3 ++- cmd/helm/testdata/output/deprecated-chart.txt | 3 ++- cmd/helm/testdata/output/get-release.txt | 4 +++- cmd/helm/testdata/output/install-and-replace.txt | 3 ++- cmd/helm/testdata/output/install-name-template.txt | 3 ++- cmd/helm/testdata/output/install-no-hooks.txt | 4 +++- .../output/install-with-multiple-values-files.txt | 4 +++- .../testdata/output/install-with-multiple-values.txt | 4 +++- cmd/helm/testdata/output/install-with-timeout.txt | 3 ++- cmd/helm/testdata/output/install-with-values-file.txt | 4 +++- cmd/helm/testdata/output/install-with-values.txt | 4 +++- .../testdata/output/install-with-wait-for-jobs.txt | 3 ++- cmd/helm/testdata/output/install-with-wait.txt | 3 ++- cmd/helm/testdata/output/install.txt | 3 ++- cmd/helm/testdata/output/schema.txt | 3 ++- cmd/helm/testdata/output/status-with-desc.txt | 3 ++- cmd/helm/testdata/output/status-with-notes.txt | 3 ++- cmd/helm/testdata/output/status-with-test-suite.txt | 3 ++- cmd/helm/testdata/output/status.json | 2 +- cmd/helm/testdata/output/status.txt | 3 ++- cmd/helm/testdata/output/subchart-schema-cli.txt | 4 +++- .../output/upgrade-with-dependency-update.txt | 3 ++- .../testdata/output/upgrade-with-install-timeout.txt | 3 ++- cmd/helm/testdata/output/upgrade-with-install.txt | 3 ++- .../testdata/output/upgrade-with-reset-values.txt | 3 ++- .../testdata/output/upgrade-with-reset-values2.txt | 3 ++- cmd/helm/testdata/output/upgrade-with-timeout.txt | 3 ++- .../testdata/output/upgrade-with-wait-for-jobs.txt | 3 ++- cmd/helm/testdata/output/upgrade-with-wait.txt | 3 ++- cmd/helm/testdata/output/upgrade.txt | 3 ++- 33 files changed, 81 insertions(+), 37 deletions(-) diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go index ff025b809..718802289 100644 --- a/cmd/helm/install_test.go +++ b/cmd/helm/install_test.go @@ -55,7 +55,7 @@ func TestInstall(t *testing.T) { // Install, base case { name: "basic install", - cmd: "install aeneas testdata/testcharts/empty --namespace default", + cmd: "install aeneas testdata/testcharts/reqtest --namespace default", golden: "output/install.txt", }, diff --git a/cmd/helm/status.go b/cmd/helm/status.go index 6085251d5..0d9e30a5b 100644 --- a/cmd/helm/status.go +++ b/cmd/helm/status.go @@ -36,6 +36,8 @@ import ( var statusHelp = ` This command shows the status of a named release. The status consists of: +- name and version of the released chart +- application version - last deployment time - k8s namespace in which the release lives - state of the release (can be: unknown, deployed, uninstalled, superseded, failed, uninstalling, pending-install, pending-upgrade or pending-rollback) @@ -67,9 +69,6 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return err } - // strip chart metadata from the output - rel.Chart = nil - return outfmt.Write(out, &statusPrinter{rel, false, client.ShowDescription}) }, } @@ -113,7 +112,11 @@ func (s statusPrinter) WriteTable(out io.Writer) error { if s.release == nil { return nil } - fmt.Fprintf(out, "NAME: %s\n", s.release.Name) + fmt.Fprintf(out, "RELEASE NAME: %s\n", s.release.Name) + fmt.Fprintf(out, "CHART: %s-%s\n", s.release.Chart.Metadata.Name, s.release.Chart.Metadata.Version) + if len(s.release.Chart.Metadata.AppVersion) > 0 { + fmt.Fprintf(out, "APP VERSION: %s\n", s.release.Chart.Metadata.AppVersion) + } if !s.release.Info.LastDeployed.IsZero() { fmt.Fprintf(out, "LAST DEPLOYED: %s\n", s.release.Info.LastDeployed.Format(time.ANSIC)) } diff --git a/cmd/helm/status_test.go b/cmd/helm/status_test.go index 7f305d56b..1f50ae751 100644 --- a/cmd/helm/status_test.go +++ b/cmd/helm/status_test.go @@ -32,8 +32,13 @@ func TestStatusCmd(t *testing.T) { Name: "flummoxed-chickadee", Namespace: "default", Info: info, - Chart: &chart.Chart{}, - Hooks: hooks, + Chart: &chart.Chart{ + Metadata: &chart.Metadata{ + Name: "Myrelease-Chart", + Version: "1.2.3", + }, + }, + Hooks: hooks, }} } diff --git a/cmd/helm/testdata/output/chart-with-subchart-update.txt b/cmd/helm/testdata/output/chart-with-subchart-update.txt index a4135c782..b540345b6 100644 --- a/cmd/helm/testdata/output/chart-with-subchart-update.txt +++ b/cmd/helm/testdata/output/chart-with-subchart-update.txt @@ -1,4 +1,5 @@ -NAME: updeps +RELEASE NAME: updeps +CHART: chart-with-subchart-update-0.0.1 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/deprecated-chart.txt b/cmd/helm/testdata/output/deprecated-chart.txt index 039d6aef6..b6e2d9dd0 100644 --- a/cmd/helm/testdata/output/deprecated-chart.txt +++ b/cmd/helm/testdata/output/deprecated-chart.txt @@ -1,4 +1,5 @@ -NAME: aeneas +RELEASE NAME: aeneas +CHART: deprecated-0.1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/get-release.txt b/cmd/helm/testdata/output/get-release.txt index f6c3b57eb..d55853f1d 100644 --- a/cmd/helm/testdata/output/get-release.txt +++ b/cmd/helm/testdata/output/get-release.txt @@ -1,4 +1,6 @@ -NAME: thomas-guide +RELEASE NAME: thomas-guide +CHART: foo-0.1.0-beta.1 +APP VERSION: 1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-and-replace.txt b/cmd/helm/testdata/output/install-and-replace.txt index 039d6aef6..f98b95816 100644 --- a/cmd/helm/testdata/output/install-and-replace.txt +++ b/cmd/helm/testdata/output/install-and-replace.txt @@ -1,4 +1,5 @@ -NAME: aeneas +RELEASE NAME: aeneas +CHART: empty-0.1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-name-template.txt b/cmd/helm/testdata/output/install-name-template.txt index 67e06d92b..a2dc2dd79 100644 --- a/cmd/helm/testdata/output/install-name-template.txt +++ b/cmd/helm/testdata/output/install-name-template.txt @@ -1,4 +1,5 @@ -NAME: FOOBAR +RELEASE NAME: FOOBAR +CHART: empty-0.1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-no-hooks.txt b/cmd/helm/testdata/output/install-no-hooks.txt index 039d6aef6..4cd6835d8 100644 --- a/cmd/helm/testdata/output/install-no-hooks.txt +++ b/cmd/helm/testdata/output/install-no-hooks.txt @@ -1,4 +1,6 @@ -NAME: aeneas +RELEASE NAME: aeneas +CHART: alpine-0.1.0 +APP VERSION: 3.9 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-with-multiple-values-files.txt b/cmd/helm/testdata/output/install-with-multiple-values-files.txt index 406e522a9..c1fdae2ac 100644 --- a/cmd/helm/testdata/output/install-with-multiple-values-files.txt +++ b/cmd/helm/testdata/output/install-with-multiple-values-files.txt @@ -1,4 +1,6 @@ -NAME: virgil +RELEASE NAME: virgil +CHART: alpine-0.1.0 +APP VERSION: 3.9 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-with-multiple-values.txt b/cmd/helm/testdata/output/install-with-multiple-values.txt index 406e522a9..c1fdae2ac 100644 --- a/cmd/helm/testdata/output/install-with-multiple-values.txt +++ b/cmd/helm/testdata/output/install-with-multiple-values.txt @@ -1,4 +1,6 @@ -NAME: virgil +RELEASE NAME: virgil +CHART: alpine-0.1.0 +APP VERSION: 3.9 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-with-timeout.txt b/cmd/helm/testdata/output/install-with-timeout.txt index 19952e3c2..0c90921f2 100644 --- a/cmd/helm/testdata/output/install-with-timeout.txt +++ b/cmd/helm/testdata/output/install-with-timeout.txt @@ -1,4 +1,5 @@ -NAME: foobar +RELEASE NAME: foobar +CHART: empty-0.1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-with-values-file.txt b/cmd/helm/testdata/output/install-with-values-file.txt index 406e522a9..c1fdae2ac 100644 --- a/cmd/helm/testdata/output/install-with-values-file.txt +++ b/cmd/helm/testdata/output/install-with-values-file.txt @@ -1,4 +1,6 @@ -NAME: virgil +RELEASE NAME: virgil +CHART: alpine-0.1.0 +APP VERSION: 3.9 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-with-values.txt b/cmd/helm/testdata/output/install-with-values.txt index 406e522a9..c1fdae2ac 100644 --- a/cmd/helm/testdata/output/install-with-values.txt +++ b/cmd/helm/testdata/output/install-with-values.txt @@ -1,4 +1,6 @@ -NAME: virgil +RELEASE NAME: virgil +CHART: alpine-0.1.0 +APP VERSION: 3.9 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-with-wait-for-jobs.txt b/cmd/helm/testdata/output/install-with-wait-for-jobs.txt index 7ce22d4ec..0f339626b 100644 --- a/cmd/helm/testdata/output/install-with-wait-for-jobs.txt +++ b/cmd/helm/testdata/output/install-with-wait-for-jobs.txt @@ -1,4 +1,5 @@ -NAME: apollo +RELEASE NAME: apollo +CHART: empty-0.1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install-with-wait.txt b/cmd/helm/testdata/output/install-with-wait.txt index 7ce22d4ec..0f339626b 100644 --- a/cmd/helm/testdata/output/install-with-wait.txt +++ b/cmd/helm/testdata/output/install-with-wait.txt @@ -1,4 +1,5 @@ -NAME: apollo +RELEASE NAME: apollo +CHART: empty-0.1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/install.txt b/cmd/helm/testdata/output/install.txt index 039d6aef6..b64446950 100644 --- a/cmd/helm/testdata/output/install.txt +++ b/cmd/helm/testdata/output/install.txt @@ -1,4 +1,5 @@ -NAME: aeneas +RELEASE NAME: aeneas +CHART: reqtest-0.1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/schema.txt b/cmd/helm/testdata/output/schema.txt index 22a94b3f4..d0f6fbf25 100644 --- a/cmd/helm/testdata/output/schema.txt +++ b/cmd/helm/testdata/output/schema.txt @@ -1,4 +1,5 @@ -NAME: schema +RELEASE NAME: schema +CHART: empty-0.1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/status-with-desc.txt b/cmd/helm/testdata/output/status-with-desc.txt index c681fe3ec..3429a1aab 100644 --- a/cmd/helm/testdata/output/status-with-desc.txt +++ b/cmd/helm/testdata/output/status-with-desc.txt @@ -1,4 +1,5 @@ -NAME: flummoxed-chickadee +RELEASE NAME: flummoxed-chickadee +CHART: Myrelease-Chart-1.2.3 LAST DEPLOYED: Sat Jan 16 00:00:00 2016 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/status-with-notes.txt b/cmd/helm/testdata/output/status-with-notes.txt index e992ce91e..e5735b26c 100644 --- a/cmd/helm/testdata/output/status-with-notes.txt +++ b/cmd/helm/testdata/output/status-with-notes.txt @@ -1,4 +1,5 @@ -NAME: flummoxed-chickadee +RELEASE NAME: flummoxed-chickadee +CHART: Myrelease-Chart-1.2.3 LAST DEPLOYED: Sat Jan 16 00:00:00 2016 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/status-with-test-suite.txt b/cmd/helm/testdata/output/status-with-test-suite.txt index 58c67e103..757a6fb6e 100644 --- a/cmd/helm/testdata/output/status-with-test-suite.txt +++ b/cmd/helm/testdata/output/status-with-test-suite.txt @@ -1,4 +1,5 @@ -NAME: flummoxed-chickadee +RELEASE NAME: flummoxed-chickadee +CHART: Myrelease-Chart-1.2.3 LAST DEPLOYED: Sat Jan 16 00:00:00 2016 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/status.json b/cmd/helm/testdata/output/status.json index 4b499c935..4ca6e6886 100644 --- a/cmd/helm/testdata/output/status.json +++ b/cmd/helm/testdata/output/status.json @@ -1 +1 @@ -{"name":"flummoxed-chickadee","info":{"first_deployed":"","last_deployed":"2016-01-16T00:00:00Z","deleted":"","status":"deployed","notes":"release notes"},"namespace":"default"} +{"name":"flummoxed-chickadee","info":{"first_deployed":"","last_deployed":"2016-01-16T00:00:00Z","deleted":"","status":"deployed","notes":"release notes"},"chart":{"metadata":{"name":"Myrelease-Chart","version":"1.2.3"},"lock":null,"templates":null,"values":null,"schema":null,"files":null},"namespace":"default"} diff --git a/cmd/helm/testdata/output/status.txt b/cmd/helm/testdata/output/status.txt index a326c3db0..d4a1604fb 100644 --- a/cmd/helm/testdata/output/status.txt +++ b/cmd/helm/testdata/output/status.txt @@ -1,4 +1,5 @@ -NAME: flummoxed-chickadee +RELEASE NAME: flummoxed-chickadee +CHART: Myrelease-Chart-1.2.3 LAST DEPLOYED: Sat Jan 16 00:00:00 2016 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/subchart-schema-cli.txt b/cmd/helm/testdata/output/subchart-schema-cli.txt index 22a94b3f4..6178f672f 100644 --- a/cmd/helm/testdata/output/subchart-schema-cli.txt +++ b/cmd/helm/testdata/output/subchart-schema-cli.txt @@ -1,4 +1,6 @@ -NAME: schema +RELEASE NAME: schema +CHART: chart-without-schema-0.1.0 +APP VERSION: 0.1.0 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/upgrade-with-dependency-update.txt b/cmd/helm/testdata/output/upgrade-with-dependency-update.txt index 0e7e5842e..4e83b3b0b 100644 --- a/cmd/helm/testdata/output/upgrade-with-dependency-update.txt +++ b/cmd/helm/testdata/output/upgrade-with-dependency-update.txt @@ -1,5 +1,6 @@ Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny +RELEASE NAME: funny-bunny +CHART: chart-with-subchart-update-0.0.1 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/upgrade-with-install-timeout.txt b/cmd/helm/testdata/output/upgrade-with-install-timeout.txt index 5d8d3a4ea..b317b03c2 100644 --- a/cmd/helm/testdata/output/upgrade-with-install-timeout.txt +++ b/cmd/helm/testdata/output/upgrade-with-install-timeout.txt @@ -1,5 +1,6 @@ Release "crazy-bunny" has been upgraded. Happy Helming! -NAME: crazy-bunny +RELEASE NAME: crazy-bunny +CHART: testUpgradeChart-0.1.3 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/upgrade-with-install.txt b/cmd/helm/testdata/output/upgrade-with-install.txt index af61212bd..6fe776845 100644 --- a/cmd/helm/testdata/output/upgrade-with-install.txt +++ b/cmd/helm/testdata/output/upgrade-with-install.txt @@ -1,5 +1,6 @@ Release "zany-bunny" has been upgraded. Happy Helming! -NAME: zany-bunny +RELEASE NAME: zany-bunny +CHART: testUpgradeChart-0.1.3 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/upgrade-with-reset-values.txt b/cmd/helm/testdata/output/upgrade-with-reset-values.txt index 01f1c0ac8..39048d5ca 100644 --- a/cmd/helm/testdata/output/upgrade-with-reset-values.txt +++ b/cmd/helm/testdata/output/upgrade-with-reset-values.txt @@ -1,5 +1,6 @@ Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny +RELEASE NAME: funny-bunny +CHART: testUpgradeChart-0.1.3 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/upgrade-with-reset-values2.txt b/cmd/helm/testdata/output/upgrade-with-reset-values2.txt index fdd1d2db7..0542eec58 100644 --- a/cmd/helm/testdata/output/upgrade-with-reset-values2.txt +++ b/cmd/helm/testdata/output/upgrade-with-reset-values2.txt @@ -1,5 +1,6 @@ Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny +RELEASE NAME: funny-bunny +CHART: testUpgradeChart-0.1.3 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/upgrade-with-timeout.txt b/cmd/helm/testdata/output/upgrade-with-timeout.txt index be3a42368..1807192ad 100644 --- a/cmd/helm/testdata/output/upgrade-with-timeout.txt +++ b/cmd/helm/testdata/output/upgrade-with-timeout.txt @@ -1,5 +1,6 @@ Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny +RELEASE NAME: funny-bunny +CHART: testUpgradeChart-0.1.3 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/upgrade-with-wait-for-jobs.txt b/cmd/helm/testdata/output/upgrade-with-wait-for-jobs.txt index 500d07a11..609a2654e 100644 --- a/cmd/helm/testdata/output/upgrade-with-wait-for-jobs.txt +++ b/cmd/helm/testdata/output/upgrade-with-wait-for-jobs.txt @@ -1,5 +1,6 @@ Release "crazy-bunny" has been upgraded. Happy Helming! -NAME: crazy-bunny +RELEASE NAME: crazy-bunny +CHART: testUpgradeChart-0.1.3 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/upgrade-with-wait.txt b/cmd/helm/testdata/output/upgrade-with-wait.txt index 500d07a11..609a2654e 100644 --- a/cmd/helm/testdata/output/upgrade-with-wait.txt +++ b/cmd/helm/testdata/output/upgrade-with-wait.txt @@ -1,5 +1,6 @@ Release "crazy-bunny" has been upgraded. Happy Helming! -NAME: crazy-bunny +RELEASE NAME: crazy-bunny +CHART: testUpgradeChart-0.1.3 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed diff --git a/cmd/helm/testdata/output/upgrade.txt b/cmd/helm/testdata/output/upgrade.txt index bea42db54..1d5e92192 100644 --- a/cmd/helm/testdata/output/upgrade.txt +++ b/cmd/helm/testdata/output/upgrade.txt @@ -1,5 +1,6 @@ Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny +RELEASE NAME: funny-bunny +CHART: testUpgradeChart-0.1.3 LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed