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
5618afe3
Commit
5618afe3
authored
Feb 13, 2017
by
Matt Butcher
Committed by
GitHub
Feb 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1922 from larryrensing/feat/list-namespaces
feat(*): add --namespace flag to 'helm list'
parents
e29b5e42
574a7a5a
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
138 additions
and
38 deletions
+138
-38
tiller.proto
_proto/hapi/services/tiller.proto
+2
-0
helm_test.go
cmd/helm/helm_test.go
+10
-3
list.go
cmd/helm/list.go
+7
-2
list_test.go
cmd/helm/list_test.go
+11
-1
helm_test.go
pkg/helm/helm_test.go
+3
-0
option.go
pkg/helm/option.go
+7
-0
tiller.pb.go
pkg/proto/hapi/services/tiller.pb.go
+2
-0
cfgmaps_test.go
pkg/storage/driver/cfgmaps_test.go
+14
-10
memory_test.go
pkg/storage/driver/memory_test.go
+4
-4
mock_test.go
pkg/storage/driver/mock_test.go
+13
-12
records_test.go
pkg/storage/driver/records_test.go
+6
-6
release_server.go
pkg/tiller/release_server.go
+17
-0
release_server_test.go
pkg/tiller/release_server_test.go
+42
-0
No files found.
_proto/hapi/services/tiller.proto
View file @
5618afe3
...
@@ -112,6 +112,8 @@ message ListReleasesRequest {
...
@@ -112,6 +112,8 @@ message ListReleasesRequest {
ListSort.SortOrder
sort_order
=
5
;
ListSort.SortOrder
sort_order
=
5
;
repeated
hapi.release.Status.Code
status_codes
=
6
;
repeated
hapi.release.Status.Code
status_codes
=
6
;
// Namespace is the filter to select releases only from a specific namespace.
string
namespace
=
7
;
}
}
// ListSort defines sorting fields on a release list.
// ListSort defines sorting fields on a release list.
...
...
cmd/helm/helm_test.go
View file @
5618afe3
...
@@ -56,6 +56,7 @@ type releaseOptions struct {
...
@@ -56,6 +56,7 @@ type releaseOptions struct {
version
int32
version
int32
chart
*
chart
.
Chart
chart
*
chart
.
Chart
statusCode
release
.
Status_Code
statusCode
release
.
Status_Code
namespace
string
}
}
func
releaseMock
(
opts
*
releaseOptions
)
*
release
.
Release
{
func
releaseMock
(
opts
*
releaseOptions
)
*
release
.
Release
{
...
@@ -71,6 +72,11 @@ func releaseMock(opts *releaseOptions) *release.Release {
...
@@ -71,6 +72,11 @@ func releaseMock(opts *releaseOptions) *release.Release {
version
=
opts
.
version
version
=
opts
.
version
}
}
namespace
:=
opts
.
namespace
if
namespace
==
""
{
namespace
=
"default"
}
ch
:=
opts
.
chart
ch
:=
opts
.
chart
if
opts
.
chart
==
nil
{
if
opts
.
chart
==
nil
{
ch
=
&
chart
.
Chart
{
ch
=
&
chart
.
Chart
{
...
@@ -97,9 +103,10 @@ func releaseMock(opts *releaseOptions) *release.Release {
...
@@ -97,9 +103,10 @@ func releaseMock(opts *releaseOptions) *release.Release {
Status
:
&
release
.
Status
{
Code
:
scode
},
Status
:
&
release
.
Status
{
Code
:
scode
},
Description
:
"Release mock"
,
Description
:
"Release mock"
,
},
},
Chart
:
ch
,
Chart
:
ch
,
Config
:
&
chart
.
Config
{
Raw
:
`name: "value"`
},
Config
:
&
chart
.
Config
{
Raw
:
`name: "value"`
},
Version
:
version
,
Version
:
version
,
Namespace
:
namespace
,
Hooks
:
[]
*
release
.
Hook
{
Hooks
:
[]
*
release
.
Hook
{
{
{
Name
:
"pre-install-hook"
,
Name
:
"pre-install-hook"
,
...
...
cmd/helm/list.go
View file @
5618afe3
...
@@ -70,6 +70,7 @@ type listCmd struct {
...
@@ -70,6 +70,7 @@ type listCmd struct {
deleting
bool
deleting
bool
deployed
bool
deployed
bool
failed
bool
failed
bool
namespace
string
superseded
bool
superseded
bool
client
helm
.
Interface
client
helm
.
Interface
}
}
...
@@ -108,6 +109,8 @@ func newListCmd(client helm.Interface, out io.Writer) *cobra.Command {
...
@@ -108,6 +109,8 @@ func newListCmd(client helm.Interface, out io.Writer) *cobra.Command {
f
.
BoolVar
(
&
list
.
deleting
,
"deleting"
,
false
,
"show releases that are currently being deleted"
)
f
.
BoolVar
(
&
list
.
deleting
,
"deleting"
,
false
,
"show releases that are currently being deleted"
)
f
.
BoolVar
(
&
list
.
deployed
,
"deployed"
,
false
,
"show deployed releases. If no other is specified, this will be automatically enabled"
)
f
.
BoolVar
(
&
list
.
deployed
,
"deployed"
,
false
,
"show deployed releases. If no other is specified, this will be automatically enabled"
)
f
.
BoolVar
(
&
list
.
failed
,
"failed"
,
false
,
"show failed releases"
)
f
.
BoolVar
(
&
list
.
failed
,
"failed"
,
false
,
"show failed releases"
)
f
.
StringVar
(
&
list
.
namespace
,
"namespace"
,
""
,
"show releases within a specific namespace"
)
// TODO: Do we want this as a feature of 'helm list'?
// TODO: Do we want this as a feature of 'helm list'?
//f.BoolVar(&list.superseded, "history", true, "show historical releases")
//f.BoolVar(&list.superseded, "history", true, "show historical releases")
...
@@ -134,6 +137,7 @@ func (l *listCmd) run() error {
...
@@ -134,6 +137,7 @@ func (l *listCmd) run() error {
helm
.
ReleaseListSort
(
int32
(
sortBy
)),
helm
.
ReleaseListSort
(
int32
(
sortBy
)),
helm
.
ReleaseListOrder
(
int32
(
sortOrder
)),
helm
.
ReleaseListOrder
(
int32
(
sortOrder
)),
helm
.
ReleaseListStatuses
(
stats
),
helm
.
ReleaseListStatuses
(
stats
),
helm
.
ReleaseListNamespace
(
l
.
namespace
),
)
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -198,13 +202,14 @@ func (l *listCmd) statusCodes() []release.Status_Code {
...
@@ -198,13 +202,14 @@ func (l *listCmd) statusCodes() []release.Status_Code {
func
formatList
(
rels
[]
*
release
.
Release
)
string
{
func
formatList
(
rels
[]
*
release
.
Release
)
string
{
table
:=
uitable
.
New
()
table
:=
uitable
.
New
()
table
.
MaxColWidth
=
60
table
.
MaxColWidth
=
60
table
.
AddRow
(
"NAME"
,
"REVISION"
,
"UPDATED"
,
"STATUS"
,
"CHART"
)
table
.
AddRow
(
"NAME"
,
"REVISION"
,
"UPDATED"
,
"STATUS"
,
"CHART"
,
"NAMESPACE"
)
for
_
,
r
:=
range
rels
{
for
_
,
r
:=
range
rels
{
c
:=
fmt
.
Sprintf
(
"%s-%s"
,
r
.
Chart
.
Metadata
.
Name
,
r
.
Chart
.
Metadata
.
Version
)
c
:=
fmt
.
Sprintf
(
"%s-%s"
,
r
.
Chart
.
Metadata
.
Name
,
r
.
Chart
.
Metadata
.
Version
)
t
:=
timeconv
.
String
(
r
.
Info
.
LastDeployed
)
t
:=
timeconv
.
String
(
r
.
Info
.
LastDeployed
)
s
:=
r
.
Info
.
Status
.
Code
.
String
()
s
:=
r
.
Info
.
Status
.
Code
.
String
()
v
:=
r
.
Version
v
:=
r
.
Version
table
.
AddRow
(
r
.
Name
,
v
,
t
,
s
,
c
)
n
:=
r
.
Namespace
table
.
AddRow
(
r
.
Name
,
v
,
t
,
s
,
c
,
n
)
}
}
return
table
.
String
()
return
table
.
String
()
}
}
cmd/helm/list_test.go
View file @
5618afe3
...
@@ -45,7 +45,7 @@ func TestListCmd(t *testing.T) {
...
@@ -45,7 +45,7 @@ func TestListCmd(t *testing.T) {
resp
:
[]
*
release
.
Release
{
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"atlas"
}),
releaseMock
(
&
releaseOptions
{
name
:
"atlas"
}),
},
},
expected
:
"NAME
\t
REVISION
\t
UPDATED
\t
STATUS
\t
CHART
\
n
atlas
\t
1
\t
(.*)
\t
DEPLOYED
\t
foo-0.1.0-beta.1
\n
"
,
expected
:
"NAME
\t
REVISION
\t
UPDATED
\t
STATUS
\t
CHART
\
t
NAMESPACE
\n
atlas
\t
1
\t
(.*)
\t
DEPLOYED
\t
foo-0.1.0-beta.1
\t
default
\n
"
,
},
},
{
{
name
:
"list, one deployed, one failed"
,
name
:
"list, one deployed, one failed"
,
...
@@ -87,6 +87,16 @@ func TestListCmd(t *testing.T) {
...
@@ -87,6 +87,16 @@ func TestListCmd(t *testing.T) {
// See note on previous test.
// See note on previous test.
expected
:
"thomas-guide
\n
atlas-guide"
,
expected
:
"thomas-guide
\n
atlas-guide"
,
},
},
{
name
:
"namespace defined, multiple flags"
,
args
:
[]
string
{
"--all"
,
"-q"
,
"--namespace test123"
},
resp
:
[]
*
release
.
Release
{
releaseMock
(
&
releaseOptions
{
name
:
"thomas-guide"
,
namespace
:
"test123"
}),
releaseMock
(
&
releaseOptions
{
name
:
"atlas-guide"
,
namespace
:
"test321"
}),
},
// See note on previous test.
expected
:
"thomas-guide"
,
},
}
}
var
buf
bytes
.
Buffer
var
buf
bytes
.
Buffer
...
...
pkg/helm/helm_test.go
View file @
5618afe3
...
@@ -51,6 +51,7 @@ func TestListReleases_VerifyOptions(t *testing.T) {
...
@@ -51,6 +51,7 @@ func TestListReleases_VerifyOptions(t *testing.T) {
rls
.
Status_DEPLOYED
,
rls
.
Status_DEPLOYED
,
rls
.
Status_SUPERSEDED
,
rls
.
Status_SUPERSEDED
,
}
}
var
namespace
=
"namespace"
// Expected ListReleasesRequest message
// Expected ListReleasesRequest message
exp
:=
&
tpb
.
ListReleasesRequest
{
exp
:=
&
tpb
.
ListReleasesRequest
{
...
@@ -60,6 +61,7 @@ func TestListReleases_VerifyOptions(t *testing.T) {
...
@@ -60,6 +61,7 @@ func TestListReleases_VerifyOptions(t *testing.T) {
SortBy
:
tpb
.
ListSort_SortBy
(
sortBy
),
SortBy
:
tpb
.
ListSort_SortBy
(
sortBy
),
SortOrder
:
tpb
.
ListSort_SortOrder
(
sortOrd
),
SortOrder
:
tpb
.
ListSort_SortOrder
(
sortOrd
),
StatusCodes
:
codes
,
StatusCodes
:
codes
,
Namespace
:
namespace
,
}
}
// Options used in ListReleases
// Options used in ListReleases
...
@@ -70,6 +72,7 @@ func TestListReleases_VerifyOptions(t *testing.T) {
...
@@ -70,6 +72,7 @@ func TestListReleases_VerifyOptions(t *testing.T) {
ReleaseListOffset
(
offset
),
ReleaseListOffset
(
offset
),
ReleaseListFilter
(
filter
),
ReleaseListFilter
(
filter
),
ReleaseListStatuses
(
codes
),
ReleaseListStatuses
(
codes
),
ReleaseListNamespace
(
namespace
),
}
}
// BeforeCall option to intercept helm client ListReleasesRequest
// BeforeCall option to intercept helm client ListReleasesRequest
...
...
pkg/helm/option.go
View file @
5618afe3
...
@@ -136,6 +136,13 @@ func ReleaseListStatuses(statuses []release.Status_Code) ReleaseListOption {
...
@@ -136,6 +136,13 @@ func ReleaseListStatuses(statuses []release.Status_Code) ReleaseListOption {
}
}
}
}
// ReleaseListNamespace specifies the namespace to list releases from
func
ReleaseListNamespace
(
namespace
string
)
ReleaseListOption
{
return
func
(
opts
*
options
)
{
opts
.
listReq
.
Namespace
=
namespace
}
}
// InstallOption allows specifying various settings
// InstallOption allows specifying various settings
// configurable by the helm client user for overriding
// configurable by the helm client user for overriding
// the defaults used when running the `helm install` command.
// the defaults used when running the `helm install` command.
...
...
pkg/proto/hapi/services/tiller.pb.go
View file @
5618afe3
...
@@ -129,6 +129,8 @@ type ListReleasesRequest struct {
...
@@ -129,6 +129,8 @@ type ListReleasesRequest struct {
// SortOrder is the ordering directive used for sorting.
// SortOrder is the ordering directive used for sorting.
SortOrder
ListSort_SortOrder
`protobuf:"varint,5,opt,name=sort_order,json=sortOrder,enum=hapi.services.tiller.ListSort_SortOrder" json:"sort_order,omitempty"`
SortOrder
ListSort_SortOrder
`protobuf:"varint,5,opt,name=sort_order,json=sortOrder,enum=hapi.services.tiller.ListSort_SortOrder" json:"sort_order,omitempty"`
StatusCodes
[]
hapi_release3
.
Status_Code
`protobuf:"varint,6,rep,packed,name=status_codes,json=statusCodes,enum=hapi.release.Status_Code" json:"status_codes,omitempty"`
StatusCodes
[]
hapi_release3
.
Status_Code
`protobuf:"varint,6,rep,packed,name=status_codes,json=statusCodes,enum=hapi.release.Status_Code" json:"status_codes,omitempty"`
// Namespace is the filter to select releases only from a specific namespace.
Namespace
string
`protobuf:"bytes,7,opt,name=namespace" json:"namespace,omitempty"`
}
}
func
(
m
*
ListReleasesRequest
)
Reset
()
{
*
m
=
ListReleasesRequest
{}
}
func
(
m
*
ListReleasesRequest
)
Reset
()
{
*
m
=
ListReleasesRequest
{}
}
...
...
pkg/storage/driver/cfgmaps_test.go
View file @
5618afe3
...
@@ -34,8 +34,9 @@ func TestConfigMapName(t *testing.T) {
...
@@ -34,8 +34,9 @@ func TestConfigMapName(t *testing.T) {
func
TestConfigMapGet
(
t
*
testing
.
T
)
{
func
TestConfigMapGet
(
t
*
testing
.
T
)
{
vers
:=
int32
(
1
)
vers
:=
int32
(
1
)
name
:=
"smug-pigeon"
name
:=
"smug-pigeon"
namespace
:=
"default"
key
:=
testKey
(
name
,
vers
)
key
:=
testKey
(
name
,
vers
)
rel
:=
releaseStub
(
name
,
vers
,
rspb
.
Status_DEPLOYED
)
rel
:=
releaseStub
(
name
,
vers
,
namespace
,
rspb
.
Status_DEPLOYED
)
cfgmaps
:=
newTestFixtureCfgMaps
(
t
,
[]
*
rspb
.
Release
{
rel
}
...
)
cfgmaps
:=
newTestFixtureCfgMaps
(
t
,
[]
*
rspb
.
Release
{
rel
}
...
)
...
@@ -53,8 +54,9 @@ func TestConfigMapGet(t *testing.T) {
...
@@ -53,8 +54,9 @@ func TestConfigMapGet(t *testing.T) {
func
TestUNcompressedConfigMapGet
(
t
*
testing
.
T
)
{
func
TestUNcompressedConfigMapGet
(
t
*
testing
.
T
)
{
vers
:=
int32
(
1
)
vers
:=
int32
(
1
)
name
:=
"smug-pigeon"
name
:=
"smug-pigeon"
namespace
:=
"default"
key
:=
testKey
(
name
,
vers
)
key
:=
testKey
(
name
,
vers
)
rel
:=
releaseStub
(
name
,
vers
,
rspb
.
Status_DEPLOYED
)
rel
:=
releaseStub
(
name
,
vers
,
namespace
,
rspb
.
Status_DEPLOYED
)
// Create a test fixture which contains an uncompressed release
// Create a test fixture which contains an uncompressed release
cfgmap
,
err
:=
newConfigMapsObject
(
key
,
rel
,
nil
)
cfgmap
,
err
:=
newConfigMapsObject
(
key
,
rel
,
nil
)
...
@@ -83,12 +85,12 @@ func TestUNcompressedConfigMapGet(t *testing.T) {
...
@@ -83,12 +85,12 @@ func TestUNcompressedConfigMapGet(t *testing.T) {
func
TestConfigMapList
(
t
*
testing
.
T
)
{
func
TestConfigMapList
(
t
*
testing
.
T
)
{
cfgmaps
:=
newTestFixtureCfgMaps
(
t
,
[]
*
rspb
.
Release
{
cfgmaps
:=
newTestFixtureCfgMaps
(
t
,
[]
*
rspb
.
Release
{
releaseStub
(
"key-1"
,
1
,
rspb
.
Status_DELETED
),
releaseStub
(
"key-1"
,
1
,
"default"
,
rspb
.
Status_DELETED
),
releaseStub
(
"key-2"
,
1
,
rspb
.
Status_DELETED
),
releaseStub
(
"key-2"
,
1
,
"default"
,
rspb
.
Status_DELETED
),
releaseStub
(
"key-3"
,
1
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"key-3"
,
1
,
"default"
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"key-4"
,
1
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"key-4"
,
1
,
"default"
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"key-5"
,
1
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"key-5"
,
1
,
"default"
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"key-6"
,
1
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"key-6"
,
1
,
"default"
,
rspb
.
Status_SUPERSEDED
),
}
...
)
}
...
)
// list all deleted releases
// list all deleted releases
...
@@ -133,8 +135,9 @@ func TestConfigMapCreate(t *testing.T) {
...
@@ -133,8 +135,9 @@ func TestConfigMapCreate(t *testing.T) {
vers
:=
int32
(
1
)
vers
:=
int32
(
1
)
name
:=
"smug-pigeon"
name
:=
"smug-pigeon"
namespace
:=
"default"
key
:=
testKey
(
name
,
vers
)
key
:=
testKey
(
name
,
vers
)
rel
:=
releaseStub
(
name
,
vers
,
rspb
.
Status_DEPLOYED
)
rel
:=
releaseStub
(
name
,
vers
,
namespace
,
rspb
.
Status_DEPLOYED
)
// store the release in a configmap
// store the release in a configmap
if
err
:=
cfgmaps
.
Create
(
key
,
rel
);
err
!=
nil
{
if
err
:=
cfgmaps
.
Create
(
key
,
rel
);
err
!=
nil
{
...
@@ -156,8 +159,9 @@ func TestConfigMapCreate(t *testing.T) {
...
@@ -156,8 +159,9 @@ func TestConfigMapCreate(t *testing.T) {
func
TestConfigMapUpdate
(
t
*
testing
.
T
)
{
func
TestConfigMapUpdate
(
t
*
testing
.
T
)
{
vers
:=
int32
(
1
)
vers
:=
int32
(
1
)
name
:=
"smug-pigeon"
name
:=
"smug-pigeon"
namespace
:=
"default"
key
:=
testKey
(
name
,
vers
)
key
:=
testKey
(
name
,
vers
)
rel
:=
releaseStub
(
name
,
vers
,
rspb
.
Status_DEPLOYED
)
rel
:=
releaseStub
(
name
,
vers
,
namespace
,
rspb
.
Status_DEPLOYED
)
cfgmaps
:=
newTestFixtureCfgMaps
(
t
,
[]
*
rspb
.
Release
{
rel
}
...
)
cfgmaps
:=
newTestFixtureCfgMaps
(
t
,
[]
*
rspb
.
Release
{
rel
}
...
)
...
...
pkg/storage/driver/memory_test.go
View file @
5618afe3
...
@@ -37,12 +37,12 @@ func TestMemoryCreate(t *testing.T) {
...
@@ -37,12 +37,12 @@ func TestMemoryCreate(t *testing.T) {
}{
}{
{
{
"create should success"
,
"create should success"
,
releaseStub
(
"rls-c"
,
1
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"rls-c"
,
1
,
"default"
,
rspb
.
Status_DEPLOYED
),
false
,
false
,
},
},
{
{
"create should fail (release already exists)"
,
"create should fail (release already exists)"
,
releaseStub
(
"rls-a"
,
1
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"rls-a"
,
1
,
"default"
,
rspb
.
Status_DEPLOYED
),
true
,
true
,
},
},
}
}
...
@@ -116,13 +116,13 @@ func TestMemoryUpdate(t *testing.T) {
...
@@ -116,13 +116,13 @@ func TestMemoryUpdate(t *testing.T) {
{
{
"update release status"
,
"update release status"
,
"rls-a.v4"
,
"rls-a.v4"
,
releaseStub
(
"rls-a"
,
4
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-a"
,
4
,
"default"
,
rspb
.
Status_SUPERSEDED
),
false
,
false
,
},
},
{
{
"update release does not exist"
,
"update release does not exist"
,
"rls-z.v1"
,
"rls-z.v1"
,
releaseStub
(
"rls-z"
,
1
,
rspb
.
Status_DELETED
),
releaseStub
(
"rls-z"
,
1
,
"default"
,
rspb
.
Status_DELETED
),
true
,
true
,
},
},
}
}
...
...
pkg/storage/driver/mock_test.go
View file @
5618afe3
...
@@ -27,11 +27,12 @@ import (
...
@@ -27,11 +27,12 @@ import (
rspb
"k8s.io/helm/pkg/proto/hapi/release"
rspb
"k8s.io/helm/pkg/proto/hapi/release"
)
)
func
releaseStub
(
name
string
,
vers
int32
,
code
rspb
.
Status_Code
)
*
rspb
.
Release
{
func
releaseStub
(
name
string
,
vers
int32
,
namespace
string
,
code
rspb
.
Status_Code
)
*
rspb
.
Release
{
return
&
rspb
.
Release
{
return
&
rspb
.
Release
{
Name
:
name
,
Name
:
name
,
Version
:
vers
,
Version
:
vers
,
Info
:
&
rspb
.
Info
{
Status
:
&
rspb
.
Status
{
Code
:
code
}},
Namespace
:
namespace
,
Info
:
&
rspb
.
Info
{
Status
:
&
rspb
.
Status
{
Code
:
code
}},
}
}
}
}
...
@@ -42,15 +43,15 @@ func testKey(name string, vers int32) string {
...
@@ -42,15 +43,15 @@ func testKey(name string, vers int32) string {
func
tsFixtureMemory
(
t
*
testing
.
T
)
*
Memory
{
func
tsFixtureMemory
(
t
*
testing
.
T
)
*
Memory
{
hs
:=
[]
*
rspb
.
Release
{
hs
:=
[]
*
rspb
.
Release
{
// rls-a
// rls-a
releaseStub
(
"rls-a"
,
4
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"rls-a"
,
4
,
"default"
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"rls-a"
,
1
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-a"
,
1
,
"default"
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-a"
,
3
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-a"
,
3
,
"default"
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-a"
,
2
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-a"
,
2
,
"default"
,
rspb
.
Status_SUPERSEDED
),
// rls-b
// rls-b
releaseStub
(
"rls-b"
,
4
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"rls-b"
,
4
,
"default"
,
rspb
.
Status_DEPLOYED
),
releaseStub
(
"rls-b"
,
1
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-b"
,
1
,
"default"
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-b"
,
3
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-b"
,
3
,
"default"
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-b"
,
2
,
rspb
.
Status_SUPERSEDED
),
releaseStub
(
"rls-b"
,
2
,
"default"
,
rspb
.
Status_SUPERSEDED
),
}
}
mem
:=
NewMemory
()
mem
:=
NewMemory
()
...
...
pkg/storage/driver/records_test.go
View file @
5618afe3
...
@@ -24,8 +24,8 @@ import (
...
@@ -24,8 +24,8 @@ import (
func
TestRecordsAdd
(
t
*
testing
.
T
)
{
func
TestRecordsAdd
(
t
*
testing
.
T
)
{
rs
:=
records
([]
*
record
{
rs
:=
records
([]
*
record
{
newRecord
(
"rls-a.v1"
,
releaseStub
(
"rls-a"
,
1
,
rspb
.
Status_SUPERSEDED
)),
newRecord
(
"rls-a.v1"
,
releaseStub
(
"rls-a"
,
1
,
"default"
,
rspb
.
Status_SUPERSEDED
)),
newRecord
(
"rls-a.v2"
,
releaseStub
(
"rls-a"
,
2
,
rspb
.
Status_DEPLOYED
)),
newRecord
(
"rls-a.v2"
,
releaseStub
(
"rls-a"
,
2
,
"default"
,
rspb
.
Status_DEPLOYED
)),
})
})
var
tests
=
[]
struct
{
var
tests
=
[]
struct
{
...
@@ -38,13 +38,13 @@ func TestRecordsAdd(t *testing.T) {
...
@@ -38,13 +38,13 @@ func TestRecordsAdd(t *testing.T) {
"add valid key"
,
"add valid key"
,
"rls-a.v3"
,
"rls-a.v3"
,
false
,
false
,
newRecord
(
"rls-a.v3"
,
releaseStub
(
"rls-a"
,
3
,
rspb
.
Status_SUPERSEDED
)),
newRecord
(
"rls-a.v3"
,
releaseStub
(
"rls-a"
,
3
,
"default"
,
rspb
.
Status_SUPERSEDED
)),
},
},
{
{
"add already existing key"
,
"add already existing key"
,
"rls-a.v1"
,
"rls-a.v1"
,
true
,
true
,
newRecord
(
"rls-a.v1"
,
releaseStub
(
"rls-a"
,
1
,
rspb
.
Status_DEPLOYED
)),
newRecord
(
"rls-a.v1"
,
releaseStub
(
"rls-a"
,
1
,
"default"
,
rspb
.
Status_DEPLOYED
)),
},
},
}
}
...
@@ -69,8 +69,8 @@ func TestRecordsRemove(t *testing.T) {
...
@@ -69,8 +69,8 @@ func TestRecordsRemove(t *testing.T) {
}
}
rs
:=
records
([]
*
record
{
rs
:=
records
([]
*
record
{
newRecord
(
"rls-a.v1"
,
releaseStub
(
"rls-a"
,
1
,
rspb
.
Status_SUPERSEDED
)),
newRecord
(
"rls-a.v1"
,
releaseStub
(
"rls-a"
,
1
,
"default"
,
rspb
.
Status_SUPERSEDED
)),
newRecord
(
"rls-a.v2"
,
releaseStub
(
"rls-a"
,
2
,
rspb
.
Status_DEPLOYED
)),
newRecord
(
"rls-a.v2"
,
releaseStub
(
"rls-a"
,
2
,
"default"
,
rspb
.
Status_DEPLOYED
)),
})
})
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
...
...
pkg/tiller/release_server.go
View file @
5618afe3
...
@@ -113,6 +113,13 @@ func (s *ReleaseServer) ListReleases(req *services.ListReleasesRequest, stream s
...
@@ -113,6 +113,13 @@ func (s *ReleaseServer) ListReleases(req *services.ListReleasesRequest, stream s
return
err
return
err
}
}
if
req
.
Namespace
!=
""
{
rels
,
err
=
filterByNamespace
(
req
.
Namespace
,
rels
)
if
err
!=
nil
{
return
err
}
}
if
len
(
req
.
Filter
)
!=
0
{
if
len
(
req
.
Filter
)
!=
0
{
rels
,
err
=
filterReleases
(
req
.
Filter
,
rels
)
rels
,
err
=
filterReleases
(
req
.
Filter
,
rels
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -179,6 +186,16 @@ func (s *ReleaseServer) ListReleases(req *services.ListReleasesRequest, stream s
...
@@ -179,6 +186,16 @@ func (s *ReleaseServer) ListReleases(req *services.ListReleasesRequest, stream s
return
stream
.
Send
(
res
)
return
stream
.
Send
(
res
)
}
}
func
filterByNamespace
(
namespace
string
,
rels
[]
*
release
.
Release
)
([]
*
release
.
Release
,
error
)
{
matches
:=
[]
*
release
.
Release
{}
for
_
,
r
:=
range
rels
{
if
namespace
==
r
.
Namespace
{
matches
=
append
(
matches
,
r
)
}
}
return
matches
,
nil
}
func
filterReleases
(
filter
string
,
rels
[]
*
release
.
Release
)
([]
*
release
.
Release
,
error
)
{
func
filterReleases
(
filter
string
,
rels
[]
*
release
.
Release
)
([]
*
release
.
Release
,
error
)
{
preg
,
err
:=
regexp
.
Compile
(
filter
)
preg
,
err
:=
regexp
.
Compile
(
filter
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/tiller/release_server_test.go
View file @
5618afe3
...
@@ -1435,6 +1435,48 @@ func TestListReleasesFilter(t *testing.T) {
...
@@ -1435,6 +1435,48 @@ func TestListReleasesFilter(t *testing.T) {
}
}
}
}
func
TestReleasesNamespace
(
t
*
testing
.
T
)
{
rs
:=
rsFixture
()
names
:=
[]
string
{
"axon"
,
"dendrite"
,
"neuron"
,
"ribosome"
,
}
namespaces
:=
[]
string
{
"default"
,
"test123"
,
"test123"
,
"cerebellum"
,
}
num
:=
4
for
i
:=
0
;
i
<
num
;
i
++
{
rel
:=
releaseStub
()
rel
.
Name
=
names
[
i
]
rel
.
Namespace
=
namespaces
[
i
]
if
err
:=
rs
.
env
.
Releases
.
Create
(
rel
);
err
!=
nil
{
t
.
Fatalf
(
"Could not store mock release: %s"
,
err
)
}
}
mrs
:=
&
mockListServer
{}
req
:=
&
services
.
ListReleasesRequest
{
Offset
:
""
,
Limit
:
64
,
Namespace
:
"test123"
,
}
if
err
:=
rs
.
ListReleases
(
req
,
mrs
);
err
!=
nil
{
t
.
Fatalf
(
"Failed listing: %s"
,
err
)
}
if
len
(
mrs
.
val
.
Releases
)
!=
2
{
t
.
Errorf
(
"Expected 2 releases, got %d"
,
len
(
mrs
.
val
.
Releases
))
}
}
func
TestRunReleaseTest
(
t
*
testing
.
T
)
{
func
TestRunReleaseTest
(
t
*
testing
.
T
)
{
rs
:=
rsFixture
()
rs
:=
rsFixture
()
rel
:=
namedReleaseStub
(
"nemo"
,
release
.
Status_DEPLOYED
)
rel
:=
namedReleaseStub
(
"nemo"
,
release
.
Status_DEPLOYED
)
...
...
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