Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2ced0835
Commit
2ced0835
authored
Aug 11, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused registry infrastructure
parent
5de0f11b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
303 deletions
+0
-303
etcd.go
pkg/registry/generic/etcd/etcd.go
+0
-43
etcd_test.go
pkg/registry/generic/etcd/etcd_test.go
+0
-153
matcher.go
pkg/registry/generic/matcher.go
+0
-15
matcher_test.go
pkg/registry/generic/matcher_test.go
+0
-0
generic.go
pkg/registry/registrytest/generic.go
+0
-92
No files found.
pkg/registry/generic/etcd/etcd.go
View file @
2ced0835
...
@@ -174,30 +174,6 @@ func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher) (runtime.Object
...
@@ -174,30 +174,6 @@ func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher) (runtime.Object
return
generic
.
FilterList
(
list
,
m
,
generic
.
DecoratorFunc
(
e
.
Decorator
))
return
generic
.
FilterList
(
list
,
m
,
generic
.
DecoratorFunc
(
e
.
Decorator
))
}
}
// CreateWithName inserts a new item with the provided name
// DEPRECATED: use Create instead
func
(
e
*
Etcd
)
CreateWithName
(
ctx
api
.
Context
,
name
string
,
obj
runtime
.
Object
)
error
{
key
,
err
:=
e
.
KeyFunc
(
ctx
,
name
)
if
err
!=
nil
{
return
err
}
if
e
.
CreateStrategy
!=
nil
{
if
err
:=
rest
.
BeforeCreate
(
e
.
CreateStrategy
,
ctx
,
obj
);
err
!=
nil
{
return
err
}
}
ttl
,
err
:=
e
.
calculateTTL
(
obj
,
0
,
false
)
if
err
!=
nil
{
return
err
}
err
=
e
.
Storage
.
Create
(
key
,
obj
,
nil
,
ttl
)
err
=
etcderr
.
InterpretCreateError
(
err
,
e
.
EndpointName
,
name
)
if
err
==
nil
&&
e
.
Decorator
!=
nil
{
err
=
e
.
Decorator
(
obj
)
}
return
err
}
// Create inserts a new item according to the unique key from the object.
// Create inserts a new item according to the unique key from the object.
func
(
e
*
Etcd
)
Create
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
func
(
e
*
Etcd
)
Create
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
trace
:=
util
.
NewTrace
(
"Create "
+
reflect
.
TypeOf
(
obj
)
.
String
())
trace
:=
util
.
NewTrace
(
"Create "
+
reflect
.
TypeOf
(
obj
)
.
String
())
...
@@ -238,25 +214,6 @@ func (e *Etcd) Create(ctx api.Context, obj runtime.Object) (runtime.Object, erro
...
@@ -238,25 +214,6 @@ func (e *Etcd) Create(ctx api.Context, obj runtime.Object) (runtime.Object, erro
return
out
,
nil
return
out
,
nil
}
}
// UpdateWithName updates the item with the provided name
// DEPRECATED: use Update instead
func
(
e
*
Etcd
)
UpdateWithName
(
ctx
api
.
Context
,
name
string
,
obj
runtime
.
Object
)
error
{
key
,
err
:=
e
.
KeyFunc
(
ctx
,
name
)
if
err
!=
nil
{
return
err
}
ttl
,
err
:=
e
.
calculateTTL
(
obj
,
0
,
true
)
if
err
!=
nil
{
return
err
}
err
=
e
.
Storage
.
Set
(
key
,
obj
,
nil
,
ttl
)
err
=
etcderr
.
InterpretUpdateError
(
err
,
e
.
EndpointName
,
name
)
if
err
==
nil
&&
e
.
Decorator
!=
nil
{
err
=
e
.
Decorator
(
obj
)
}
return
err
}
// Update performs an atomic update and set of the object. Returns the result of the update
// Update performs an atomic update and set of the object. Returns the result of the update
// or an error. If the registry allows create-on-update, the create flow will be executed.
// or an error. If the registry allows create-on-update, the create flow will be executed.
// A bool is returned along with the object and any errors, to indicate object creation.
// A bool is returned along with the object and any errors, to indicate object creation.
...
...
pkg/registry/generic/etcd/etcd_test.go
View file @
2ced0835
...
@@ -307,83 +307,6 @@ func TestEtcdCreate(t *testing.T) {
...
@@ -307,83 +307,6 @@ func TestEtcdCreate(t *testing.T) {
}
}
}
}
// DEPRECATED
func
TestEtcdCreateWithName
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
api
.
PodSpec
{
NodeName
:
"machine"
},
}
podB
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
api
.
NamespaceDefault
},
Spec
:
api
.
PodSpec
{
NodeName
:
"machine2"
},
}
nodeWithPodA
:=
tools
.
EtcdResponseWithError
{
R
:
&
etcd
.
Response
{
Node
:
&
etcd
.
Node
{
Value
:
runtime
.
EncodeOrDie
(
testapi
.
Codec
(),
podA
),
ModifiedIndex
:
1
,
CreatedIndex
:
1
,
},
},
E
:
nil
,
}
emptyNode
:=
tools
.
EtcdResponseWithError
{
R
:
&
etcd
.
Response
{},
E
:
tools
.
EtcdErrorNotFound
,
}
key
:=
"foo"
table
:=
map
[
string
]
struct
{
existing
tools
.
EtcdResponseWithError
expect
tools
.
EtcdResponseWithError
toCreate
runtime
.
Object
objOK
func
(
obj
runtime
.
Object
)
bool
errOK
func
(
error
)
bool
}{
"normal"
:
{
existing
:
emptyNode
,
toCreate
:
podA
,
objOK
:
hasCreated
(
t
,
podA
),
errOK
:
func
(
err
error
)
bool
{
return
err
==
nil
},
},
"preExisting"
:
{
existing
:
nodeWithPodA
,
expect
:
nodeWithPodA
,
toCreate
:
podB
,
errOK
:
errors
.
IsAlreadyExists
,
},
}
for
name
,
item
:=
range
table
{
fakeClient
,
registry
:=
NewTestGenericEtcdRegistry
(
t
)
path
:=
etcdtest
.
AddPrefix
(
"pods/foo"
)
fakeClient
.
Data
[
path
]
=
item
.
existing
err
:=
registry
.
CreateWithName
(
api
.
NewDefaultContext
(),
key
,
item
.
toCreate
)
if
!
item
.
errOK
(
err
)
{
t
.
Errorf
(
"%v: unexpected error: %v"
,
name
,
err
)
}
actual
:=
fakeClient
.
Data
[
path
]
if
item
.
objOK
!=
nil
{
obj
,
err
:=
api
.
Scheme
.
Decode
([]
byte
(
actual
.
R
.
Node
.
Value
))
if
err
!=
nil
{
t
.
Errorf
(
"unable to decode stored value for %#v"
,
actual
)
continue
}
if
!
item
.
objOK
(
obj
)
{
t
.
Errorf
(
"%v: unexpected response: %v"
,
name
,
actual
)
}
}
else
{
if
e
,
a
:=
item
.
expect
,
actual
;
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"%v:
\n
%s"
,
name
,
util
.
ObjectDiff
(
e
,
a
))
}
}
}
}
func
TestEtcdUpdate
(
t
*
testing
.
T
)
{
func
TestEtcdUpdate
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
podA
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
api
.
NamespaceDefault
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
api
.
NamespaceDefault
},
...
@@ -520,82 +443,6 @@ func TestEtcdUpdate(t *testing.T) {
...
@@ -520,82 +443,6 @@ func TestEtcdUpdate(t *testing.T) {
}
}
}
}
// DEPRECATED
func
TestEtcdUpdateWithName
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
Spec
:
api
.
PodSpec
{
NodeName
:
"machine"
},
}
podB
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
Spec
:
api
.
PodSpec
{
NodeName
:
"machine2"
},
}
nodeWithPodA
:=
tools
.
EtcdResponseWithError
{
R
:
&
etcd
.
Response
{
Node
:
&
etcd
.
Node
{
Value
:
runtime
.
EncodeOrDie
(
testapi
.
Codec
(),
podA
),
ModifiedIndex
:
1
,
CreatedIndex
:
1
,
},
},
E
:
nil
,
}
nodeWithPodB
:=
tools
.
EtcdResponseWithError
{
R
:
&
etcd
.
Response
{
Node
:
&
etcd
.
Node
{
Value
:
runtime
.
EncodeOrDie
(
testapi
.
Codec
(),
podB
),
ModifiedIndex
:
1
,
CreatedIndex
:
1
,
},
},
E
:
nil
,
}
emptyNode
:=
tools
.
EtcdResponseWithError
{
R
:
&
etcd
.
Response
{},
E
:
tools
.
EtcdErrorNotFound
,
}
key
:=
"foo"
table
:=
map
[
string
]
struct
{
existing
tools
.
EtcdResponseWithError
expect
tools
.
EtcdResponseWithError
toUpdate
runtime
.
Object
errOK
func
(
error
)
bool
}{
"normal"
:
{
existing
:
nodeWithPodA
,
expect
:
nodeWithPodB
,
toUpdate
:
podB
,
errOK
:
func
(
err
error
)
bool
{
return
err
==
nil
},
},
"notExisting"
:
{
existing
:
emptyNode
,
expect
:
nodeWithPodA
,
toUpdate
:
podA
,
// TODO: Should updating a non-existing thing fail?
errOK
:
func
(
err
error
)
bool
{
return
err
==
nil
},
},
}
for
name
,
item
:=
range
table
{
fakeClient
,
registry
:=
NewTestGenericEtcdRegistry
(
t
)
path
:=
etcdtest
.
AddPrefix
(
"pods/foo"
)
fakeClient
.
Data
[
path
]
=
item
.
existing
err
:=
registry
.
UpdateWithName
(
api
.
NewContext
(),
key
,
item
.
toUpdate
)
if
!
item
.
errOK
(
err
)
{
t
.
Errorf
(
"%v: unexpected error: %v"
,
name
,
err
)
}
if
e
,
a
:=
item
.
expect
,
fakeClient
.
Data
[
path
];
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"%v:
\n
%s"
,
name
,
util
.
ObjectDiff
(
e
,
a
))
}
}
}
func
TestEtcdGet
(
t
*
testing
.
T
)
{
func
TestEtcdGet
(
t
*
testing
.
T
)
{
podA
:=
&
api
.
Pod
{
podA
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
...
...
pkg/registry/generic/
registry
.go
→
pkg/registry/generic/
matcher
.go
View file @
2ced0835
...
@@ -17,11 +17,9 @@ limitations under the License.
...
@@ -17,11 +17,9 @@ limitations under the License.
package
generic
package
generic
import
(
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
)
)
// AttrFunc returns label and field sets for List or Watch to compare against, or an error.
// AttrFunc returns label and field sets for List or Watch to compare against, or an error.
...
@@ -124,19 +122,6 @@ var (
...
@@ -124,19 +122,6 @@ var (
// DecoratorFunc can mutate the provided object prior to being returned.
// DecoratorFunc can mutate the provided object prior to being returned.
type
DecoratorFunc
func
(
obj
runtime
.
Object
)
error
type
DecoratorFunc
func
(
obj
runtime
.
Object
)
error
// Registry knows how to store & list any runtime.Object. Can be used for
// any object types which don't require special features from the storage
// layer.
// DEPRECATED: replace with direct implementation of RESTStorage
type
Registry
interface
{
ListPredicate
(
api
.
Context
,
Matcher
)
(
runtime
.
Object
,
error
)
CreateWithName
(
ctx
api
.
Context
,
id
string
,
obj
runtime
.
Object
)
error
UpdateWithName
(
ctx
api
.
Context
,
id
string
,
obj
runtime
.
Object
)
error
Get
(
ctx
api
.
Context
,
id
string
)
(
runtime
.
Object
,
error
)
Delete
(
ctx
api
.
Context
,
id
string
,
options
*
api
.
DeleteOptions
)
(
runtime
.
Object
,
error
)
WatchPredicate
(
ctx
api
.
Context
,
m
Matcher
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
}
// FilterList filters any list object that conforms to the api conventions,
// FilterList filters any list object that conforms to the api conventions,
// provided that 'm' works with the concrete type of list. d is an optional
// provided that 'm' works with the concrete type of list. d is an optional
// decorator for the returned functions. Only matching items are decorated.
// decorator for the returned functions. Only matching items are decorated.
...
...
pkg/registry/generic/
registry
_test.go
→
pkg/registry/generic/
matcher
_test.go
View file @
2ced0835
File moved
pkg/registry/registrytest/generic.go
deleted
100644 → 0
View file @
5de0f11b
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
registrytest
import
(
"sync"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/registry/generic"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
)
// GenericRegistry knows how to store & list any runtime.Object.
type
GenericRegistry
struct
{
Err
error
Object
runtime
.
Object
ObjectList
runtime
.
Object
sync
.
Mutex
Broadcaster
*
watch
.
Broadcaster
}
func
NewGeneric
(
list
runtime
.
Object
)
*
GenericRegistry
{
return
&
GenericRegistry
{
ObjectList
:
list
,
Broadcaster
:
watch
.
NewBroadcaster
(
0
,
watch
.
WaitIfChannelFull
),
}
}
func
(
r
*
GenericRegistry
)
ListPredicate
(
ctx
api
.
Context
,
m
generic
.
Matcher
)
(
runtime
.
Object
,
error
)
{
r
.
Lock
()
defer
r
.
Unlock
()
if
r
.
Err
!=
nil
{
return
nil
,
r
.
Err
}
return
generic
.
FilterList
(
r
.
ObjectList
,
m
,
nil
)
}
func
(
r
*
GenericRegistry
)
WatchPredicate
(
ctx
api
.
Context
,
m
generic
.
Matcher
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
// TODO: wire filter down into the mux; it needs access to current and previous state :(
return
r
.
Broadcaster
.
Watch
(),
nil
}
func
(
r
*
GenericRegistry
)
Get
(
ctx
api
.
Context
,
id
string
)
(
runtime
.
Object
,
error
)
{
r
.
Lock
()
defer
r
.
Unlock
()
if
r
.
Err
!=
nil
{
return
nil
,
r
.
Err
}
if
r
.
Object
!=
nil
{
return
r
.
Object
,
nil
}
panic
(
"generic registry should either have an object or an error for Get"
)
}
func
(
r
*
GenericRegistry
)
CreateWithName
(
ctx
api
.
Context
,
id
string
,
obj
runtime
.
Object
)
error
{
r
.
Lock
()
defer
r
.
Unlock
()
r
.
Object
=
obj
r
.
Broadcaster
.
Action
(
watch
.
Added
,
obj
)
return
r
.
Err
}
func
(
r
*
GenericRegistry
)
UpdateWithName
(
ctx
api
.
Context
,
id
string
,
obj
runtime
.
Object
)
error
{
r
.
Lock
()
defer
r
.
Unlock
()
r
.
Object
=
obj
r
.
Broadcaster
.
Action
(
watch
.
Modified
,
obj
)
return
r
.
Err
}
func
(
r
*
GenericRegistry
)
Delete
(
ctx
api
.
Context
,
id
string
,
options
*
api
.
DeleteOptions
)
(
runtime
.
Object
,
error
)
{
r
.
Lock
()
defer
r
.
Unlock
()
r
.
Broadcaster
.
Action
(
watch
.
Deleted
,
r
.
Object
)
return
&
api
.
Status
{
Status
:
api
.
StatusSuccess
},
r
.
Err
}
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