diff --git a/cmd/helm/history.go b/cmd/helm/history.go index f55eea9fd..4d6b0c65d 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -107,7 +107,7 @@ func (r releaseHistory) WriteTable(out io.Writer) error { tbl := uitable.New() tbl.AddRow("REVISION", "UPDATED", "STATUS", "CHART", "APP VERSION", "DESCRIPTION") for _, item := range r { - tbl.AddRow(item.Revision, item.Updated.Format(time.ANSIC), item.Status, item.Chart, item.AppVersion, item.Description) + tbl.AddRow(item.Revision, item.Updated.Local().Format(time.ANSIC), item.Status, item.Chart, item.AppVersion, item.Description) } return output.EncodeTable(out, tbl) } diff --git a/cmd/helm/history_test.go b/cmd/helm/history_test.go index fffd983da..196250400 100644 --- a/cmd/helm/history_test.go +++ b/cmd/helm/history_test.go @@ -19,6 +19,7 @@ package main import ( "fmt" "testing" + "time" "helm.sh/helm/v3/pkg/release" ) @@ -67,7 +68,25 @@ func TestHistoryCmd(t *testing.T) { }, golden: "output/history.json", }} + + prevLocal := time.Local + time.Local = time.UTC runTestCmd(t, tests) + + time.Local = time.FixedZone("Arbitrary", 5*60*60) + runTestCmd(t, []cmdTestCase{{ + name: "get history for release in UTC+5", + cmd: "history angry-bird", + rels: []*release.Release{ + mk("angry-bird", 4, release.StatusDeployed), + mk("angry-bird", 3, release.StatusSuperseded), + mk("angry-bird", 2, release.StatusSuperseded), + mk("angry-bird", 1, release.StatusSuperseded), + }, + golden: "output/history-utc+5.txt", + }}) + + time.Local = prevLocal } func TestHistoryOutputCompletion(t *testing.T) { diff --git a/cmd/helm/testdata/output/history-utc+5.txt b/cmd/helm/testdata/output/history-utc+5.txt new file mode 100644 index 000000000..165268994 --- /dev/null +++ b/cmd/helm/testdata/output/history-utc+5.txt @@ -0,0 +1,5 @@ +REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION +1 Sat Sep 3 03:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Release mock +2 Sat Sep 3 03:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Release mock +3 Sat Sep 3 03:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Release mock +4 Sat Sep 3 03:04:05 1977 deployed foo-0.1.0-beta.1 1.0 Release mock