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
967e438b
Commit
967e438b
authored
Aug 01, 2016
by
fibonacci1729
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt ...
parent
a05b48f3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
21 deletions
+19
-21
memory.go
pkg/storage/driver/memory.go
+1
-1
filter.go
pkg/storage/filter.go
+2
-3
storage.go
pkg/storage/storage.go
+4
-3
storage_test.go
pkg/storage/storage_test.go
+12
-14
No files found.
pkg/storage/driver/memory.go
View file @
967e438b
...
...
@@ -44,7 +44,7 @@ func (mem *Memory) Get(key string) (*rspb.Release, error) {
// List returns all releases whose status is not Status_DELETED.
func
(
mem
*
Memory
)
List
(
filter
func
(
*
rspb
.
Release
)
bool
)
([]
*
rspb
.
Release
,
error
)
{
defer
unlock
(
mem
.
rlock
())
var
releases
[]
*
rspb
.
Release
for
k
:=
range
mem
.
cache
{
if
filter
(
mem
.
cache
[
k
])
{
...
...
pkg/storage/filter.go
View file @
967e438b
...
...
@@ -11,7 +11,7 @@ func (fn FilterFunc) Check(rls *rspb.Release) bool {
if
rls
==
nil
{
return
false
}
return
fn
(
rls
)
return
fn
(
rls
)
}
// Any returns a FilterFunc that filters a list of releases
...
...
@@ -48,4 +48,4 @@ func StatusFilter(status rspb.Status_Code) FilterFunc {
}
return
rls
.
GetInfo
()
.
GetStatus
()
.
Code
==
status
})
}
\ No newline at end of file
}
pkg/storage/storage.go
View file @
967e438b
...
...
@@ -91,6 +91,8 @@ func (s *Storage) ListFilterAny(filters ...FilterFunc) ([]*rspb.Release, error)
}
func
Init
(
d
driver
.
Driver
)
*
Storage
{
if
d
==
nil
{
d
=
driver
.
NewMemory
()
}
if
d
==
nil
{
d
=
driver
.
NewMemory
()
}
return
&
Storage
{
Driver
:
d
}
}
\ No newline at end of file
}
pkg/storage/storage_test.go
View file @
967e438b
...
...
@@ -47,7 +47,7 @@ func TestStorageUpdate(t *testing.T) {
assertErrNil
(
t
.
Fatal
,
storage
.
Create
(
rls
),
"StoreRelease"
)
// modify the release
rls
.
Version
=
2
rls
.
Version
=
2
rls
.
Manifest
=
"new-manifest"
assertErrNil
(
t
.
Fatal
,
storage
.
Update
(
rls
),
"UpdateRelease"
)
...
...
@@ -81,12 +81,12 @@ func TestStorageList(t *testing.T) {
setup
:=
func
()
{
// release records
rls0
:=
ReleaseTestData
{
Name
:
"happy-catdog"
,
Status
:
rspb
.
Status_SUPERSEDED
}
.
ToRelease
()
rls1
:=
ReleaseTestData
{
Name
:
"livid-human"
,
Status
:
rspb
.
Status_SUPERSEDED
}
.
ToRelease
()
rls2
:=
ReleaseTestData
{
Name
:
"relaxed-cat"
,
Status
:
rspb
.
Status_SUPERSEDED
}
.
ToRelease
()
rls1
:=
ReleaseTestData
{
Name
:
"livid-human"
,
Status
:
rspb
.
Status_SUPERSEDED
}
.
ToRelease
()
rls2
:=
ReleaseTestData
{
Name
:
"relaxed-cat"
,
Status
:
rspb
.
Status_SUPERSEDED
}
.
ToRelease
()
rls3
:=
ReleaseTestData
{
Name
:
"hungry-hippo"
,
Status
:
rspb
.
Status_DEPLOYED
}
.
ToRelease
()
rls4
:=
ReleaseTestData
{
Name
:
"angry-beaver"
,
Status
:
rspb
.
Status_DEPLOYED
}
.
ToRelease
()
rls5
:=
ReleaseTestData
{
Name
:
"opulent-frog"
,
Status
:
rspb
.
Status_DELETED
}
.
ToRelease
()
rls6
:=
ReleaseTestData
{
Name
:
"happy-liger"
,
Status
:
rspb
.
Status_DELETED
}
.
ToRelease
()
rls6
:=
ReleaseTestData
{
Name
:
"happy-liger"
,
Status
:
rspb
.
Status_DELETED
}
.
ToRelease
()
// create the release records in the storage
assertErrNil
(
t
.
Fatal
,
storage
.
Create
(
rls0
),
"Storing release 'rls0'"
)
...
...
@@ -98,12 +98,12 @@ func TestStorageList(t *testing.T) {
assertErrNil
(
t
.
Fatal
,
storage
.
Create
(
rls6
),
"Storing release 'rls6'"
)
}
var
listTests
=
[]
struct
{
var
listTests
=
[]
struct
{
Description
string
NumExpected
int
ListFunc
func
()
([]
*
rspb
.
Release
,
error
)
ListFunc
func
()
([]
*
rspb
.
Release
,
error
)
}{
{
"ListDeleted"
,
2
,
storage
.
ListDeleted
},
{
"ListDeleted"
,
2
,
storage
.
ListDeleted
},
{
"ListDeployed"
,
2
,
storage
.
ListDeployed
},
{
"ListReleases"
,
7
,
storage
.
ListReleases
},
}
...
...
@@ -124,20 +124,20 @@ func TestStorageList(t *testing.T) {
}
type
ReleaseTestData
struct
{
Name
string
Name
string
Version
int32
Manifest
string
Namespace
string
Status
rspb
.
Status_Code
Status
rspb
.
Status_Code
}
func
(
test
ReleaseTestData
)
ToRelease
()
*
rspb
.
Release
{
return
&
rspb
.
Release
{
Name
:
test
.
Name
,
Name
:
test
.
Name
,
Version
:
test
.
Version
,
Manifest
:
test
.
Manifest
,
Namespace
:
test
.
Namespace
,
Info
:
&
rspb
.
Info
{
Status
:
&
rspb
.
Status
{
Code
:
test
.
Status
}},
Info
:
&
rspb
.
Info
{
Status
:
&
rspb
.
Status
{
Code
:
test
.
Status
}},
}
}
...
...
@@ -147,7 +147,6 @@ func assertErrNil(eh func(args ...interface{}), err error, message string) {
}
}
/*
func releaseData() *rspb.Release {
var manifest = `apiVersion: v1
...
...
@@ -174,4 +173,4 @@ func releaseData() *rspb.Release {
Namespace: "kube-system",
}
}
*/
\ No newline at end of file
*/
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