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
a05b48f3
Commit
a05b48f3
authored
Aug 01, 2016
by
fibonacci1729
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update driver Queryor interface to reflect list filtering mechanism
parent
bfd6712c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
17 deletions
+22
-17
driver.go
pkg/storage/driver/driver.go
+16
-6
memory.go
pkg/storage/driver/memory.go
+6
-7
memory_test.go
pkg/storage/driver/memory_test.go
+0
-4
No files found.
pkg/storage/driver/driver.go
View file @
a05b48f3
...
...
@@ -27,24 +27,34 @@ var (
ErrNotImplemented
=
errors
.
New
(
"not implemented"
)
)
// Creator stores a release.
type
Creator
interface
{
Create
(
*
rspb
.
Release
)
error
Create
(
rls
*
rspb
.
Release
)
error
}
// Updator updates an existing release or returns
// ErrReleaseNotFound if the release does not exist.
type
Updator
interface
{
Update
(
*
rspb
.
Release
)
error
Update
(
rls
*
rspb
.
Release
)
error
}
// Deletor deletes the release named by key or returns
// ErrReleaseNotFound if the release does not exist.
type
Deletor
interface
{
Delete
(
string
)
(
*
rspb
.
Release
,
error
)
Delete
(
key
string
)
(
*
rspb
.
Release
,
error
)
}
// Queryor defines the behavior on accessing a release from storage.
type
Queryor
interface
{
Get
(
string
)
(
*
rspb
.
Release
,
error
)
All
(
string
,
...
interface
{})
([]
*
rspb
.
Release
,
error
)
// Get returns the release named by key or returns ErrReleaseNotFound
// if the release does not exist.
Get
(
key
string
)
(
*
rspb
.
Release
,
error
)
// List returns the set of all releases that satisfy the filter predicate.
List
(
filter
func
(
*
rspb
.
Release
)
bool
)
([]
*
rspb
.
Release
,
error
)
}
// Driver defines the behavior for storing, updating, deleted, and retrieving
// tiller releases from some underlying storage mechanism, e.g. memory, configmaps.
type
Driver
interface
{
Creator
Updator
...
...
pkg/storage/driver/memory.go
View file @
a05b48f3
...
...
@@ -41,14 +41,14 @@ func (mem *Memory) Get(key string) (*rspb.Release, error) {
return
nil
,
ErrReleaseNotFound
}
//
All
returns all releases whose status is not Status_DELETED.
func
(
mem
*
Memory
)
All
(
key
string
,
opts
...
interface
{}
)
([]
*
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
_
,
rls
:=
range
mem
.
cache
{
if
rls
.
Info
.
Status
.
Code
!=
rspb
.
Status_DELETED
{
releases
=
append
(
releases
,
rls
)
for
k
:=
range
mem
.
cache
{
if
filter
(
mem
.
cache
[
k
])
{
releases
=
append
(
releases
,
mem
.
cache
[
k
]
)
}
}
return
releases
,
nil
...
...
@@ -57,7 +57,6 @@ func (mem *Memory) All(key string, opts ...interface{}) ([]*rspb.Release, error)
// Create creates a new release or error.
func
(
mem
*
Memory
)
Create
(
rls
*
rspb
.
Release
)
error
{
defer
unlock
(
mem
.
wlock
())
mem
.
cache
[
rls
.
Name
]
=
rls
return
nil
}
...
...
pkg/storage/driver/memory_test.go
View file @
a05b48f3
...
...
@@ -36,10 +36,6 @@ func TestMemoryGet(t *testing.T) {
}
}
func
TestMemoryAll
(
t
*
testing
.
T
)
{
t
.
Skip
(
"MemoryAll"
)
}
func
TestMemoryCreate
(
t
*
testing
.
T
)
{
key
:=
"test-1"
rls
:=
&
rspb
.
Release
{
Name
:
key
}
...
...
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