Add app version to history table

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
pull/5538/head
Martin Hickey 6 years ago
parent 658c66dc66
commit b600f6090e

@ -35,11 +35,11 @@ configures the maximum length of the revision list returned.
The historical release set is printed as a formatted table, e.g: The historical release set is printed as a formatted table, e.g:
$ helm history angry-bird --max=4 $ helm history angry-bird --max=4
REVISION UPDATED STATUS CHART DESCRIPTION REVISION UPDATED STATUS CHART APP_VERSION DESCRIPTION
1 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 Initial install 1 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Initial install
2 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 Upgraded successfully 2 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Upgraded successfully
3 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 Rolled back to 2 3 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Rolled back to 2
4 Mon Oct 3 10:15:13 2016 deployed alpine-0.1.0 Upgraded successfully 4 Mon Oct 3 10:15:13 2016 deployed alpine-0.1.0 1.0 Upgraded successfully
` `
func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {

@ -1,3 +1,3 @@
REVISION UPDATED STATUS CHART DESCRIPTION REVISION UPDATED STATUS CHART APP_VERSION DESCRIPTION
3 1977-09-02 22:04:05 +0000 UTC superseded foo-0.1.0-beta.1 Release mock 3 1977-09-02 22:04:05 +0000 UTC superseded foo-0.1.0-beta.1 1.0 Release mock
4 1977-09-02 22:04:05 +0000 UTC deployed foo-0.1.0-beta.1 Release mock 4 1977-09-02 22:04:05 +0000 UTC deployed foo-0.1.0-beta.1 1.0 Release mock

@ -1 +1 @@
[{"revision":3,"updated":"1977-09-02 22:04:05 +0000 UTC","status":"superseded","chart":"foo-0.1.0-beta.1","description":"Release mock"},{"revision":4,"updated":"1977-09-02 22:04:05 +0000 UTC","status":"deployed","chart":"foo-0.1.0-beta.1","description":"Release mock"}] [{"revision":3,"updated":"1977-09-02 22:04:05 +0000 UTC","status":"superseded","chart":"foo-0.1.0-beta.1","app_version":"1.0","description":"Release mock"},{"revision":4,"updated":"1977-09-02 22:04:05 +0000 UTC","status":"deployed","chart":"foo-0.1.0-beta.1","app_version":"1.0","description":"Release mock"}]

@ -1,5 +1,5 @@
REVISION UPDATED STATUS CHART DESCRIPTION REVISION UPDATED STATUS CHART APP_VERSION DESCRIPTION
1 1977-09-02 22:04:05 +0000 UTC superseded foo-0.1.0-beta.1 Release mock 1 1977-09-02 22:04:05 +0000 UTC superseded foo-0.1.0-beta.1 1.0 Release mock
2 1977-09-02 22:04:05 +0000 UTC superseded foo-0.1.0-beta.1 Release mock 2 1977-09-02 22:04:05 +0000 UTC superseded foo-0.1.0-beta.1 1.0 Release mock
3 1977-09-02 22:04:05 +0000 UTC superseded foo-0.1.0-beta.1 Release mock 3 1977-09-02 22:04:05 +0000 UTC superseded foo-0.1.0-beta.1 1.0 Release mock
4 1977-09-02 22:04:05 +0000 UTC deployed foo-0.1.0-beta.1 Release mock 4 1977-09-02 22:04:05 +0000 UTC deployed foo-0.1.0-beta.1 1.0 Release mock

@ -1,9 +1,11 @@
- chart: foo-0.1.0-beta.1 - app_version: "1.0"
chart: foo-0.1.0-beta.1
description: Release mock description: Release mock
revision: 3 revision: 3
status: superseded status: superseded
updated: 1977-09-02 22:04:05 +0000 UTC updated: 1977-09-02 22:04:05 +0000 UTC
- chart: foo-0.1.0-beta.1 - app_version: "1.0"
chart: foo-0.1.0-beta.1
description: Release mock description: Release mock
revision: 4 revision: 4
status: deployed status: deployed

@ -34,6 +34,7 @@ type releaseInfo struct {
Updated string `json:"updated"` Updated string `json:"updated"`
Status string `json:"status"` Status string `json:"status"`
Chart string `json:"chart"` Chart string `json:"chart"`
AppVersion string `json:"app_version"`
Description string `json:"description"` Description string `json:"description"`
} }
@ -142,11 +143,13 @@ func getReleaseHistory(rls []*release.Release) (history releaseHistory) {
s := r.Info.Status.String() s := r.Info.Status.String()
v := r.Version v := r.Version
d := r.Info.Description d := r.Info.Description
a := formatAppVersion(r.Chart)
rInfo := releaseInfo{ rInfo := releaseInfo{
Revision: v, Revision: v,
Status: s, Status: s,
Chart: c, Chart: c,
AppVersion: a,
Description: d, Description: d,
} }
if !r.Info.LastDeployed.IsZero() { if !r.Info.LastDeployed.IsZero() {
@ -162,10 +165,10 @@ func getReleaseHistory(rls []*release.Release) (history releaseHistory) {
func formatAsTable(releases releaseHistory) []byte { func formatAsTable(releases releaseHistory) []byte {
tbl := uitable.New() tbl := uitable.New()
tbl.AddRow("REVISION", "UPDATED", "STATUS", "CHART", "DESCRIPTION") tbl.AddRow("REVISION", "UPDATED", "STATUS", "CHART", "APP_VERSION", "DESCRIPTION")
for i := 0; i <= len(releases)-1; i++ { for i := 0; i <= len(releases)-1; i++ {
r := releases[i] r := releases[i]
tbl.AddRow(r.Revision, r.Updated, r.Status, r.Chart, r.Description) tbl.AddRow(r.Revision, r.Updated, r.Status, r.Chart, r.AppVersion, r.Description)
} }
return tbl.Bytes() return tbl.Bytes()
} }
@ -178,3 +181,12 @@ func formatChartname(c *chart.Chart) string {
} }
return fmt.Sprintf("%s-%s", c.Name(), c.Metadata.Version) return fmt.Sprintf("%s-%s", c.Name(), c.Metadata.Version)
} }
func formatAppVersion(c *chart.Chart) string {
if c == nil || c.Metadata == nil {
// This is an edge case that has happened in prod, though we don't
// know how: https://github.com/helm/helm/issues/1347
return "MISSING"
}
return c.AppVersion()
}

@ -100,3 +100,11 @@ func (ch *Chart) ChartFullPath() string {
func (ch *Chart) Validate() error { func (ch *Chart) Validate() error {
return ch.Metadata.Validate() return ch.Metadata.Validate()
} }
// AppVersion returns the appversion of the chart.
func (ch *Chart) AppVersion() string {
if ch.Metadata == nil {
return ""
}
return ch.Metadata.AppVersion
}

@ -71,8 +71,9 @@ func Mock(opts *MockReleaseOptions) *Release {
if opts.Chart == nil { if opts.Chart == nil {
ch = &chart.Chart{ ch = &chart.Chart{
Metadata: &chart.Metadata{ Metadata: &chart.Metadata{
Name: "foo", Name: "foo",
Version: "0.1.0-beta.1", Version: "0.1.0-beta.1",
AppVersion: "1.0",
}, },
Templates: []*chart.File{ Templates: []*chart.File{
{Name: "templates/foo.tpl", Data: []byte(MockManifest)}, {Name: "templates/foo.tpl", Data: []byte(MockManifest)},

Loading…
Cancel
Save