diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 08a26be04..b71278c7c 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -46,8 +46,8 @@ regular expressions (Perl compatible) that are applied to the list of releases. Only items that match the filter will be returned. $ helm list --filter 'ara[a-z]+' - NAME UPDATED CHART - maudlin-arachnid Mon May 9 16:07:08 2016 alpine-0.1.0 + NAME UPDATED CHART + maudlin-arachnid 2020-06-18 14:17:46.125134977 +0000 UTC alpine-0.1.0 If no results are found, 'helm list' will exit 0, but with no output (or in the case of no '-q' flag, only headers). @@ -104,16 +104,17 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } return nil default: - return outfmt.Write(out, newReleaseListWriter(results)) + return outfmt.Write(out, newReleaseListWriter(results, client.TimeFormat)) } } - return outfmt.Write(out, newReleaseListWriter(results)) + return outfmt.Write(out, newReleaseListWriter(results, client.TimeFormat)) }, } f := cmd.Flags() f.BoolVarP(&client.Short, "short", "q", false, "output short (quiet) listing format") + f.StringVar(&client.TimeFormat, "time-format", "", "format time. Example: --time-format 2009-11-17 20:34:10 +0000 UTC") f.BoolVarP(&client.ByDate, "date", "d", false, "sort by release date") f.BoolVarP(&client.SortReverse, "reverse", "r", false, "reverse the sort order") f.BoolVarP(&client.All, "all", "a", false, "show all releases without any filter applied") @@ -147,7 +148,7 @@ type releaseListWriter struct { releases []releaseElement } -func newReleaseListWriter(releases []*release.Release) *releaseListWriter { +func newReleaseListWriter(releases []*release.Release, timeFormat string) *releaseListWriter { // Initialize the array so no results returns an empty array instead of null elements := make([]releaseElement, 0, len(releases)) for _, r := range releases { @@ -159,11 +160,17 @@ func newReleaseListWriter(releases []*release.Release) *releaseListWriter { Chart: fmt.Sprintf("%s-%s", r.Chart.Metadata.Name, r.Chart.Metadata.Version), AppVersion: r.Chart.Metadata.AppVersion, } + t := "-" if tspb := r.Info.LastDeployed; !tspb.IsZero() { - t = tspb.String() + if timeFormat != "" { + t = tspb.Format(timeFormat) + } else { + t = tspb.String() + } } element.Updated = t + elements = append(elements, element) } return &releaseListWriter{elements} diff --git a/pkg/action/list.go b/pkg/action/list.go index 5ba0c4770..ebbc56b01 100644 --- a/pkg/action/list.go +++ b/pkg/action/list.go @@ -122,6 +122,7 @@ type List struct { // Filter is a filter that is applied to the results Filter string Short bool + TimeFormat string Uninstalled bool Superseded bool Uninstalling bool