Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
e9203b82
Unverified
Commit
e9203b82
authored
Jan 12, 2018
by
Adam Reese
Committed by
GitHub
Jan 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(helm): filter helm list to print latest release (#3335)
`helm list` should only list latest release fixes #3208
parent
5a73f9ef
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
list.go
cmd/helm/list.go
+25
-1
list_test.go
cmd/helm/list_test.go
+8
-0
No files found.
cmd/helm/list.go
View file @
e9203b82
...
...
@@ -156,7 +156,7 @@ func (l *listCmd) run() error {
fmt
.
Fprintf
(
l
.
out
,
"
\t
next: %s
\n
"
,
res
.
Next
)
}
rels
:=
res
.
Releases
rels
:=
filterList
(
res
.
Releases
)
if
l
.
short
{
for
_
,
r
:=
range
rels
{
...
...
@@ -168,6 +168,30 @@ func (l *listCmd) run() error {
return
nil
}
// filterList returns a list scrubbed of old releases.
func
filterList
(
rels
[]
*
release
.
Release
)
[]
*
release
.
Release
{
idx
:=
map
[
string
]
int32
{}
for
_
,
r
:=
range
rels
{
name
,
version
:=
r
.
GetName
(),
r
.
GetVersion
()
if
max
,
ok
:=
idx
[
name
];
ok
{
// check if we have a greater version already
if
max
>
version
{
continue
}
}
idx
[
name
]
=
version
}
uniq
:=
make
([]
*
release
.
Release
,
0
,
len
(
idx
))
for
_
,
r
:=
range
rels
{
if
idx
[
r
.
GetName
()]
==
r
.
GetVersion
()
{
uniq
=
append
(
uniq
,
r
)
}
}
return
uniq
}
// statusCodes gets the list of status codes that are to be included in the results.
func
(
l
*
listCmd
)
statusCodes
()
[]
release
.
Status_Code
{
if
l
.
all
{
...
...
cmd/helm/list_test.go
View file @
e9203b82
...
...
@@ -118,6 +118,14 @@ func TestListCmd(t *testing.T) {
},
expected
:
"thomas-guide
\n
wild-idea
\n
crazy-maps"
,
},
{
name
:
"with old releases"
,
resp
:
[]
*
release
.
Release
{
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
}),
helm
.
ReleaseMock
(
&
helm
.
MockReleaseOptions
{
Name
:
"thomas-guide"
,
StatusCode
:
release
.
Status_FAILED
}),
},
expected
:
"thomas-guide"
,
},
}
var
buf
bytes
.
Buffer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment