pull/31295/merge
Terry Howe 1 day ago committed by GitHub
commit 19efc36526
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -139,7 +139,7 @@ type List struct {
// NewList constructs a new *List
func NewList(cfg *Configuration) *List {
return &List{
StateMask: ListDeployed | ListFailed,
StateMask: ListAll,
cfg: cfg,
}
}
@ -317,7 +317,7 @@ func (l *List) SetStateMask() {
// Apply a default
if state == 0 {
state = ListDeployed | ListFailed
state = ListAll
}
l.StateMask = state

@ -176,9 +176,10 @@ func TestList_StateMask(t *testing.T) {
res, err := lister.Run()
is.NoError(err)
is.Len(res, 2)
is.Equal("three", res[0].Name)
is.Equal("two", res[1].Name)
is.Len(res, 3)
is.Equal("one", res[0].Name)
is.Equal("three", res[1].Name)
is.Equal("two", res[2].Name)
lister.StateMask = ListUninstalled
res, err = lister.Run()

@ -36,9 +36,10 @@ import (
var listHelp = `
This command lists all of the releases for a specified namespace (uses current namespace context if namespace not specified).
By default, it lists only releases that are deployed or failed. Flags like
'--uninstalled' and '--all' will alter this behavior. Such flags can be combined:
'--uninstalled --failed'.
By default, it lists all releases in any status. Individual status filters like '--deployed', '--failed',
'--pending', '--uninstalled', '--superseded', and '--uninstalling' can be used
to show only releases in specific states. Such flags can be combined:
'--deployed --failed'.
By default, items are sorted alphabetically. Use the '-d' flag to sort by
release date.
@ -117,11 +118,10 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
f.StringVar(&client.TimeFormat, "time-format", "", `format time using golang time formatter. Example: --time-format "2006-01-02 15:04:05Z0700"`)
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")
f.BoolVar(&client.Uninstalled, "uninstalled", false, "show uninstalled releases (if 'helm uninstall --keep-history' was used)")
f.BoolVar(&client.Superseded, "superseded", false, "show superseded releases")
f.BoolVar(&client.Uninstalling, "uninstalling", false, "show releases that are currently being uninstalled")
f.BoolVar(&client.Deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled")
f.BoolVar(&client.Deployed, "deployed", false, "show deployed releases")
f.BoolVar(&client.Failed, "failed", false, "show failed releases")
f.BoolVar(&client.Pending, "pending", false, "show pending releases")
f.BoolVarP(&client.AllNamespaces, "all-namespaces", "A", false, "list releases across all namespaces")

@ -146,22 +146,17 @@ func TestListCmd(t *testing.T) {
tests := []cmdTestCase{{
name: "list releases",
cmd: "list",
golden: "output/list.txt",
golden: "output/list-all.txt",
rels: releaseFixture,
}, {
name: "list without headers",
cmd: "list --no-headers",
golden: "output/list-no-headers.txt",
rels: releaseFixture,
}, {
name: "list all releases",
cmd: "list --all",
golden: "output/list-all.txt",
golden: "output/list-all-no-headers.txt",
rels: releaseFixture,
}, {
name: "list releases sorted by release date",
cmd: "list --date",
golden: "output/list-date.txt",
golden: "output/list-all-date.txt",
rels: releaseFixture,
}, {
name: "list failed releases",
@ -171,17 +166,17 @@ func TestListCmd(t *testing.T) {
}, {
name: "list filtered releases",
cmd: "list --filter='.*'",
golden: "output/list-filter.txt",
golden: "output/list-all.txt",
rels: releaseFixture,
}, {
name: "list releases, limited to one release",
cmd: "list --max 1",
golden: "output/list-max.txt",
golden: "output/list-all-max.txt",
rels: releaseFixture,
}, {
name: "list releases, offset by one",
cmd: "list --offset 1",
golden: "output/list-offset.txt",
golden: "output/list-all-offset.txt",
rels: releaseFixture,
}, {
name: "list pending releases",
@ -191,27 +186,32 @@ func TestListCmd(t *testing.T) {
}, {
name: "list releases in reverse order",
cmd: "list --reverse",
golden: "output/list-reverse.txt",
golden: "output/list-all-reverse.txt",
rels: releaseFixture,
}, {
name: "list releases sorted by reversed release date",
cmd: "list --date --reverse",
golden: "output/list-date-reversed.txt",
golden: "output/list-all-date-reversed.txt",
rels: releaseFixture,
}, {
name: "list releases in short output format",
cmd: "list --short",
golden: "output/list-short.txt",
golden: "output/list-all-short.txt",
rels: releaseFixture,
}, {
name: "list releases in short output format",
cmd: "list --short --output yaml",
golden: "output/list-short-yaml.txt",
golden: "output/list-all-short-yaml.txt",
rels: releaseFixture,
}, {
name: "list releases in short output format",
cmd: "list --short --output json",
golden: "output/list-short-json.txt",
golden: "output/list-all-short-json.txt",
rels: releaseFixture,
}, {
name: "list deployed and failed releases only",
cmd: "list --deployed --failed",
golden: "output/list.txt",
rels: releaseFixture,
}, {
name: "list superseded releases",

@ -0,0 +1,9 @@
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1
hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1
rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1
thanos default 1 2016-01-16 00:00:01 +0000 UTC pending-install chickadee-1.0.0 0.0.1
starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1
groot default 1 2016-01-16 00:00:01 +0000 UTC uninstalled chickadee-1.0.0 0.0.1
gamora default 1 2016-01-16 00:00:01 +0000 UTC superseded chickadee-1.0.0 0.0.1
drax default 1 2016-01-16 00:00:01 +0000 UTC uninstalling chickadee-1.0.0 0.0.1

@ -0,0 +1,9 @@
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
drax default 1 2016-01-16 00:00:01 +0000 UTC uninstalling chickadee-1.0.0 0.0.1
gamora default 1 2016-01-16 00:00:01 +0000 UTC superseded chickadee-1.0.0 0.0.1
groot default 1 2016-01-16 00:00:01 +0000 UTC uninstalled chickadee-1.0.0 0.0.1
starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1
thanos default 1 2016-01-16 00:00:01 +0000 UTC pending-install chickadee-1.0.0 0.0.1
rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1
hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1
iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1

@ -0,0 +1,2 @@
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
drax default 1 2016-01-16 00:00:01 +0000 UTC uninstalling chickadee-1.0.0 0.0.1

@ -0,0 +1,8 @@
drax default 1 2016-01-16 00:00:01 +0000 UTC uninstalling chickadee-1.0.0 0.0.1
gamora default 1 2016-01-16 00:00:01 +0000 UTC superseded chickadee-1.0.0 0.0.1
groot default 1 2016-01-16 00:00:01 +0000 UTC uninstalled chickadee-1.0.0 0.0.1
hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1
iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1
rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1
starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1
thanos default 1 2016-01-16 00:00:01 +0000 UTC pending-install chickadee-1.0.0 0.0.1

@ -0,0 +1,8 @@
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
gamora default 1 2016-01-16 00:00:01 +0000 UTC superseded chickadee-1.0.0 0.0.1
groot default 1 2016-01-16 00:00:01 +0000 UTC uninstalled chickadee-1.0.0 0.0.1
hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1
iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1
rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1
starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1
thanos default 1 2016-01-16 00:00:01 +0000 UTC pending-install chickadee-1.0.0 0.0.1

@ -0,0 +1,9 @@
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
thanos default 1 2016-01-16 00:00:01 +0000 UTC pending-install chickadee-1.0.0 0.0.1
starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1
rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1
iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1
hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1
groot default 1 2016-01-16 00:00:01 +0000 UTC uninstalled chickadee-1.0.0 0.0.1
gamora default 1 2016-01-16 00:00:01 +0000 UTC superseded chickadee-1.0.0 0.0.1
drax default 1 2016-01-16 00:00:01 +0000 UTC uninstalling chickadee-1.0.0 0.0.1

@ -0,0 +1 @@
["drax","gamora","groot","hummingbird","iguana","rocket","starlord","thanos"]

@ -0,0 +1,8 @@
- drax
- gamora
- groot
- hummingbird
- iguana
- rocket
- starlord
- thanos

@ -0,0 +1,8 @@
drax
gamora
groot
hummingbird
iguana
rocket
starlord
thanos

@ -44,7 +44,11 @@ func SortByDate(list []*rspb.Release) {
sort.Slice(list, func(i, j int) bool {
ti := list[i].Info.LastDeployed.Unix()
tj := list[j].Info.LastDeployed.Unix()
return ti < tj
if ti != tj {
return ti < tj
}
// Use name as tie-breaker for stable sorting
return list[i].Name < list[j].Name
})
}

Loading…
Cancel
Save