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
6844d3b4
Commit
6844d3b4
authored
May 11, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(helm,tiller): add list reverse, string offset
parent
dfc9693a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
31 deletions
+83
-31
tiller.proto
_proto/hapi/services/tiller.proto
+24
-7
list.go
cmd/helm/list.go
+20
-14
release_server.go
cmd/tiller/release_server.go
+33
-5
release_server_test.go
cmd/tiller/release_server_test.go
+3
-3
helm.go
pkg/helm/helm.go
+3
-2
tiller.pb.go
pkg/proto/hapi/services/tiller.pb.go
+0
-0
No files found.
_proto/hapi/services/tiller.proto
View file @
6844d3b4
...
...
@@ -61,8 +61,12 @@ message ListReleasesRequest {
// Limit is the maximum number of releases to be returned.
int64
limit
=
1
;
// Offset is the zero-based offset at which the returned release list begins.
int64
offset
=
2
;
// Offset is the last release name that was seen. The next listing
// operation will start with the name after this one.
// Example: If list one returns albert, bernie, carl and we supply
// carl as the offset, the next one should begin with the next release name
// after carl (e.g. dennis).
string
offset
=
2
;
// SortBy is the sort field that the ListReleases server should sort data before returning.
ListSort.SortBy
sort_by
=
3
;
...
...
@@ -71,29 +75,42 @@ message ListReleasesRequest {
//
// Anything that matches the regexp will be included in the results.
string
filter
=
4
;
ListSort.SortOrder
sort_order
=
5
;
}
// ListSort defines sorting fields on a release list.
message
ListSort
{
// SortBy defines sort operations.
enum
SortBy
{
UNKNOWN
=
0
;
NAME
=
1
;
LAST_RELEASED
=
2
;
}
// SortOrder defines sort orders to augment sorting operations.
enum
SortOrder
{
ASC
=
0
;
DESC
=
1
;
}
}
// ListReleasesResponse is a list of releases.
message
ListReleasesResponse
{
//
The expected total number of releases to be returned
//
Count is the expected total number of releases to be returned.
int64
count
=
1
;
//
The zero-based offset at which the list is positioned
int64
offset
=
2
;
//
Offset is the last-seen release name, used to offset the next set.
string
offset
=
2
;
// T
he total number of queryable releases
// T
otal is the total number of queryable releases.
int64
total
=
3
;
//
The resulting releases
//
Releases is the list of found release objects.
repeated
hapi.release.Release
releases
=
4
;
// More indicates whether there are more objects to retrieve.
bool
more
=
5
;
}
// GetReleaseStatusRequest is a request to get the status of a release.
...
...
cmd/helm/list.go
View file @
6844d3b4
...
...
@@ -43,16 +43,22 @@ var listCommand = &cobra.Command{
Aliases
:
[]
string
{
"ls"
},
}
var
listLong
bool
var
listMax
int
var
listOffset
int
var
listByDate
bool
var
(
listLong
bool
listMax
int
listOffset
string
listByDate
bool
listSortDesc
bool
)
func
init
()
{
listCommand
.
Flags
()
.
BoolVarP
(
&
listLong
,
"long"
,
"l"
,
false
,
"output long listing format"
)
listCommand
.
Flags
()
.
BoolVarP
(
&
listByDate
,
"date"
,
"d"
,
false
,
"sort by release date"
)
listCommand
.
Flags
()
.
IntVarP
(
&
listMax
,
"max"
,
"m"
,
256
,
"maximum number of releases to fetch"
)
listCommand
.
Flags
()
.
IntVarP
(
&
listOffset
,
"offset"
,
"o"
,
0
,
"offset from start value (zero-indexed)"
)
f
:=
listCommand
.
Flags
()
f
.
BoolVarP
(
&
listLong
,
"long"
,
"l"
,
false
,
"output long listing format"
)
f
.
BoolVarP
(
&
listByDate
,
"date"
,
"d"
,
false
,
"sort by release date"
)
f
.
BoolVarP
(
&
listSortDesc
,
"reverse"
,
"r"
,
false
,
"reverse the sort order"
)
f
.
IntVarP
(
&
listMax
,
"max"
,
"m"
,
256
,
"maximum number of releases to fetch"
)
f
.
StringVarP
(
&
listOffset
,
"offset"
,
"o"
,
""
,
"the last seen release name, used to offset from start value"
)
RootCommand
.
AddCommand
(
listCommand
)
}
...
...
@@ -67,17 +73,17 @@ func listCmd(cmd *cobra.Command, args []string) error {
sortBy
=
services
.
ListSort_LAST_RELEASED
}
res
,
err
:=
helm
.
ListReleases
(
listMax
,
listOffset
,
sortBy
,
filter
)
sortOrder
:=
services
.
ListSort_ASC
if
listSortDesc
{
sortOrder
=
services
.
ListSort_DESC
}
res
,
err
:=
helm
.
ListReleases
(
listMax
,
listOffset
,
sortBy
,
sortOrder
,
filter
)
if
err
!=
nil
{
return
prettyError
(
err
)
}
rels
:=
res
.
Releases
if
flagVerbose
&&
res
.
Count
+
res
.
Offset
<
res
.
Total
{
fmt
.
Println
(
"==> Not all values were fetched."
)
}
// Purty output, ya'll
if
listLong
{
return
formatList
(
rels
)
}
...
...
cmd/tiller/release_server.go
View file @
6844d3b4
...
...
@@ -44,6 +44,7 @@ var (
var
ListDefaultLimit
int64
=
512
func
(
s
*
releaseServer
)
ListReleases
(
req
*
services
.
ListReleasesRequest
,
stream
services
.
ReleaseService_ListReleasesServer
)
error
{
more
:=
false
rels
,
err
:=
s
.
env
.
Releases
.
List
()
if
err
!=
nil
{
return
err
...
...
@@ -65,12 +66,33 @@ func (s *releaseServer) ListReleases(req *services.ListReleasesRequest, stream s
sort
.
Sort
(
byDate
(
rels
))
}
if
req
.
SortOrder
==
services
.
ListSort_DESC
{
ll
:=
len
(
rels
)
rr
:=
make
([]
*
release
.
Release
,
ll
)
for
i
,
item
:=
range
rels
{
rr
[
ll
-
i
-
1
]
=
item
}
rels
=
rr
}
l
:=
int64
(
len
(
rels
))
if
req
.
Offset
>
0
{
if
req
.
Offset
>=
l
{
return
fmt
.
Errorf
(
"offset %d is outside of range %d"
,
req
.
Offset
,
l
)
if
req
.
Offset
!=
""
{
i
:=
-
1
for
ii
,
cur
:=
range
rels
{
if
cur
.
Name
==
req
.
Offset
{
i
=
ii
+
1
}
}
rels
=
rels
[
req
.
Offset
:
]
if
i
==
-
1
{
return
fmt
.
Errorf
(
"offset %q not found"
,
req
.
Offset
)
}
if
len
(
rels
)
<
i
{
return
fmt
.
Errorf
(
"no items after %q"
,
req
.
Offset
)
}
rels
=
rels
[
i
:
]
l
=
int64
(
len
(
rels
))
}
...
...
@@ -79,15 +101,21 @@ func (s *releaseServer) ListReleases(req *services.ListReleasesRequest, stream s
}
if
l
>
req
.
Limit
{
more
=
true
rels
=
rels
[
0
:
req
.
Limit
]
l
=
int64
(
len
(
rels
))
}
last
:=
""
if
l
>
0
{
last
=
rels
[
l
-
1
]
.
Name
}
res
:=
&
services
.
ListReleasesResponse
{
Offset
:
0
,
Offset
:
last
,
Count
:
l
,
Total
:
total
,
Releases
:
rels
,
More
:
more
,
}
stream
.
Send
(
res
)
return
nil
...
...
cmd/tiller/release_server_test.go
View file @
6844d3b4
...
...
@@ -208,7 +208,7 @@ func TestListReleases(t *testing.T) {
}
mrs
:=
&
mockListServer
{}
if
err
:=
rs
.
ListReleases
(
&
services
.
ListReleasesRequest
{
Offset
:
0
,
Limit
:
64
},
mrs
);
err
!=
nil
{
if
err
:=
rs
.
ListReleases
(
&
services
.
ListReleasesRequest
{
Offset
:
""
,
Limit
:
64
},
mrs
);
err
!=
nil
{
t
.
Fatalf
(
"Failed listing: %s"
,
err
)
}
...
...
@@ -234,7 +234,7 @@ func TestListReleasesSort(t *testing.T) {
limit
:=
6
mrs
:=
&
mockListServer
{}
req
:=
&
services
.
ListReleasesRequest
{
Offset
:
0
,
Offset
:
""
,
Limit
:
int64
(
limit
),
SortBy
:
services
.
ListSort_NAME
,
}
...
...
@@ -276,7 +276,7 @@ func TestListReleasesFilter(t *testing.T) {
mrs
:=
&
mockListServer
{}
req
:=
&
services
.
ListReleasesRequest
{
Offset
:
0
,
Offset
:
""
,
Limit
:
64
,
Filter
:
"neuro[a-z]+"
,
SortBy
:
services
.
ListSort_NAME
,
...
...
pkg/helm/helm.go
View file @
6844d3b4
...
...
@@ -13,7 +13,7 @@ var Config = &config{
}
// ListReleases lists the current releases.
func
ListReleases
(
limit
,
offset
int
,
sort
services
.
ListSort_SortBy
,
filter
string
)
(
*
services
.
ListReleasesResponse
,
error
)
{
func
ListReleases
(
limit
int
,
offset
string
,
sort
services
.
ListSort_SortBy
,
order
services
.
ListSort_SortOrder
,
filter
string
)
(
*
services
.
ListReleasesResponse
,
error
)
{
c
:=
Config
.
client
()
if
err
:=
c
.
dial
();
err
!=
nil
{
return
nil
,
err
...
...
@@ -22,8 +22,9 @@ func ListReleases(limit, offset int, sort services.ListSort_SortBy, filter strin
req
:=
&
services
.
ListReleasesRequest
{
Limit
:
int64
(
limit
),
Offset
:
int64
(
offset
)
,
Offset
:
offset
,
SortBy
:
sort
,
SortOrder
:
order
,
Filter
:
filter
,
}
cli
,
err
:=
c
.
impl
.
ListReleases
(
context
.
TODO
(),
req
,
c
.
cfg
.
CallOpts
()
...
)
...
...
pkg/proto/hapi/services/tiller.pb.go
View file @
6844d3b4
This diff is collapsed.
Click to expand it.
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