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
ea6b82a4
Commit
ea6b82a4
authored
May 09, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(tiller): sort list in tiller, not helm
parent
62cb6ce4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
34 deletions
+61
-34
tiller.proto
_proto/hapi/services/tiller.proto
+17
-2
list.go
cmd/helm/list.go
+7
-31
release_server.go
cmd/tiller/release_server.go
+35
-0
helm.go
pkg/helm/helm.go
+2
-1
tiller.pb.go
pkg/proto/hapi/services/tiller.pb.go
+0
-0
No files found.
_proto/hapi/services/tiller.proto
View file @
ea6b82a4
...
...
@@ -53,12 +53,27 @@ service ReleaseService {
}
// ListReleasesRequest requests a list of releases.
//
// Releases can be retrieved in chunks by setting limit and offset.
//
// Releases can be sorted according to a few pre-determined sort stategies.
message
ListReleasesRequest
{
//
The maximum number of releases to be returned
//
Limit is the maximum number of releases to be returned.
int64
limit
=
1
;
//
The zero-based offset at which the returned release list begins
//
Offset is the zero-based offset at which the returned release list begins.
int64
offset
=
2
;
// SortBy is the sort field that the ListReleases server should sort data before returning.
ListSort.SortBy
sort_by
=
3
;
}
message
ListSort
{
enum
SortBy
{
UNKNOWN
=
0
;
NAME
=
1
;
LAST_RELEASED
=
2
;
}
}
// ListReleasesResponse is a list of releases.
...
...
cmd/helm/list.go
View file @
ea6b82a4
...
...
@@ -2,11 +2,11 @@ package main
import
(
"fmt"
"sort"
"github.com/gosuri/uitable"
"github.com/kubernetes/helm/pkg/helm"
"github.com/kubernetes/helm/pkg/proto/hapi/release"
"github.com/kubernetes/helm/pkg/proto/hapi/services"
"github.com/kubernetes/helm/pkg/timeconv"
"github.com/spf13/cobra"
)
...
...
@@ -45,7 +45,12 @@ func listCmd(cmd *cobra.Command, args []string) error {
fmt
.
Println
(
"TODO: Implement filter."
)
}
res
,
err
:=
helm
.
ListReleases
(
listMax
,
listOffset
)
sortBy
:=
services
.
ListSort_NAME
if
listByDate
{
sortBy
=
services
.
ListSort_LAST_RELEASED
}
res
,
err
:=
helm
.
ListReleases
(
listMax
,
listOffset
,
sortBy
)
if
err
!=
nil
{
return
prettyError
(
err
)
}
...
...
@@ -55,12 +60,6 @@ func listCmd(cmd *cobra.Command, args []string) error {
fmt
.
Println
(
"Not all values were fetched."
)
}
if
listByDate
{
sort
.
Sort
(
byDate
(
rels
))
}
else
{
sort
.
Sort
(
byName
(
rels
))
}
// Purty output, ya'll
if
listLong
{
return
formatList
(
rels
)
...
...
@@ -85,26 +84,3 @@ func formatList(rels []*release.Release) error {
return
nil
}
// byName implements the sort.Interface for []*release.Release.
type
byName
[]
*
release
.
Release
func
(
r
byName
)
Len
()
int
{
return
len
(
r
)
}
func
(
r
byName
)
Swap
(
p
,
q
int
)
{
r
[
p
],
r
[
q
]
=
r
[
q
],
r
[
p
]
}
func
(
r
byName
)
Less
(
i
,
j
int
)
bool
{
return
r
[
i
]
.
Name
<
r
[
j
]
.
Name
}
type
byDate
[]
*
release
.
Release
func
(
r
byDate
)
Len
()
int
{
return
len
(
r
)
}
func
(
r
byDate
)
Swap
(
p
,
q
int
)
{
r
[
p
],
r
[
q
]
=
r
[
q
],
r
[
p
]
}
func
(
r
byDate
)
Less
(
p
,
q
int
)
bool
{
return
r
[
p
]
.
Info
.
LastDeployed
.
Seconds
<
r
[
q
]
.
Info
.
LastDeployed
.
Seconds
}
cmd/tiller/release_server.go
View file @
ea6b82a4
...
...
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log"
"sort"
"github.com/kubernetes/helm/cmd/tiller/environment"
"github.com/kubernetes/helm/pkg/proto/hapi/release"
...
...
@@ -49,6 +50,17 @@ func (s *releaseServer) ListReleases(req *services.ListReleasesRequest, stream s
total
:=
int64
(
len
(
rels
))
if
req
.
SortBy
!=
services
.
ListSort_UNKNOWN
{
log
.
Printf
(
"Sorting by %q"
,
req
.
SortBy
)
}
switch
req
.
SortBy
{
case
services
.
ListSort_NAME
:
sort
.
Sort
(
byName
(
rels
))
case
services
.
ListSort_LAST_RELEASED
:
sort
.
Sort
(
byDate
(
rels
))
}
l
:=
int64
(
len
(
rels
))
if
req
.
Offset
>
0
{
if
req
.
Offset
>=
l
{
...
...
@@ -224,3 +236,26 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR
res
:=
services
.
UninstallReleaseResponse
{
Release
:
rel
}
return
&
res
,
nil
}
// byName implements the sort.Interface for []*release.Release.
type
byName
[]
*
release
.
Release
func
(
r
byName
)
Len
()
int
{
return
len
(
r
)
}
func
(
r
byName
)
Swap
(
p
,
q
int
)
{
r
[
p
],
r
[
q
]
=
r
[
q
],
r
[
p
]
}
func
(
r
byName
)
Less
(
i
,
j
int
)
bool
{
return
r
[
i
]
.
Name
<
r
[
j
]
.
Name
}
type
byDate
[]
*
release
.
Release
func
(
r
byDate
)
Len
()
int
{
return
len
(
r
)
}
func
(
r
byDate
)
Swap
(
p
,
q
int
)
{
r
[
p
],
r
[
q
]
=
r
[
q
],
r
[
p
]
}
func
(
r
byDate
)
Less
(
p
,
q
int
)
bool
{
return
r
[
p
]
.
Info
.
LastDeployed
.
Seconds
<
r
[
q
]
.
Info
.
LastDeployed
.
Seconds
}
pkg/helm/helm.go
View file @
ea6b82a4
...
...
@@ -13,7 +13,7 @@ var Config = &config{
}
// ListReleases lists the current releases.
func
ListReleases
(
limit
,
offset
int
)
(
*
services
.
ListReleasesResponse
,
error
)
{
func
ListReleases
(
limit
,
offset
int
,
sort
services
.
ListSort_SortBy
)
(
*
services
.
ListReleasesResponse
,
error
)
{
c
:=
Config
.
client
()
if
err
:=
c
.
dial
();
err
!=
nil
{
return
nil
,
err
...
...
@@ -23,6 +23,7 @@ func ListReleases(limit, offset int) (*services.ListReleasesResponse, error) {
req
:=
&
services
.
ListReleasesRequest
{
Limit
:
int64
(
limit
),
Offset
:
int64
(
offset
),
SortBy
:
sort
,
}
cli
,
err
:=
c
.
impl
.
ListReleases
(
context
.
TODO
(),
req
,
c
.
cfg
.
CallOpts
()
...
)
if
err
!=
nil
{
...
...
pkg/proto/hapi/services/tiller.pb.go
View file @
ea6b82a4
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