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
9c53f301
Commit
9c53f301
authored
Oct 27, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge selectors with ListOptions.
parent
cd7e4bd6
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
138 additions
and
269 deletions
+138
-269
rest.go
pkg/api/rest/rest.go
+2
-6
resttest.go
pkg/api/rest/resttest/resttest.go
+14
-9
apiserver_test.go
pkg/apiserver/apiserver_test.go
+22
-7
resthandler.go
pkg/apiserver/resthandler.go
+2
-2
master.go
pkg/master/master.go
+2
-4
master_test.go
pkg/master/master_test.go
+3
-5
thirdparty_controller.go
pkg/master/thirdparty_controller.go
+1
-3
rest.go
pkg/registry/componentstatus/rest.go
+1
-3
rest_test.go
pkg/registry/componentstatus/rest_test.go
+3
-5
registry.go
pkg/registry/controller/registry.go
+7
-10
registry.go
pkg/registry/deployment/registry.go
+4
-7
registry.go
pkg/registry/endpoint/registry.go
+6
-8
etcd.go
pkg/registry/generic/etcd/etcd.go
+22
-2
registry.go
pkg/registry/job/registry.go
+0
-99
registry.go
pkg/registry/namespace/registry.go
+6
-14
registry.go
pkg/registry/node/registry.go
+6
-8
endpoint.go
pkg/registry/registrytest/endpoint.go
+2
-4
node.go
pkg/registry/registrytest/node.go
+2
-4
service.go
pkg/registry/registrytest/service.go
+2
-4
registry.go
pkg/registry/secret/registry.go
+6
-14
repair.go
pkg/registry/service/ipallocator/controller/repair.go
+1
-3
repair.go
pkg/registry/service/portallocator/controller/repair.go
+1
-3
registry.go
pkg/registry/service/registry.go
+6
-8
rest.go
pkg/registry/service/rest.go
+4
-6
rest_test.go
pkg/registry/service/rest_test.go
+1
-3
registry.go
pkg/registry/serviceaccount/registry.go
+6
-14
registry.go
pkg/registry/thirdpartyresourcedata/registry.go
+6
-14
No files found.
pkg/api/rest/rest.go
View file @
9c53f301
...
@@ -22,8 +22,6 @@ import (
...
@@ -22,8 +22,6 @@ import (
"net/url"
"net/url"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -62,8 +60,7 @@ type Lister interface {
...
@@ -62,8 +60,7 @@ type Lister interface {
// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
NewList
()
runtime
.
Object
NewList
()
runtime
.
Object
// List selects resources in the storage which match to the selector. 'options' can be nil.
// List selects resources in the storage which match to the selector. 'options' can be nil.
// TODO: Move 'label' and 'field' to 'options'.
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
List
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
}
}
// Getter is an object that can retrieve a named RESTful resource.
// Getter is an object that can retrieve a named RESTful resource.
...
@@ -184,8 +181,7 @@ type Watcher interface {
...
@@ -184,8 +181,7 @@ type Watcher interface {
// are supported; an error should be returned if 'field' tries to select on a field that
// are supported; an error should be returned if 'field' tries to select on a field that
// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
// particular version.
// particular version.
// TODO: Replace 'label', 'field' and 'resourceVersion' with ListOptions.
Watch
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
Watch
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
}
}
// StandardStorage is an interface covering the common verbs. Provided for testing whether a
// StandardStorage is an interface covering the common verbs. Provided for testing whether a
...
...
pkg/api/rest/resttest/resttest.go
View file @
9c53f301
...
@@ -853,7 +853,7 @@ func (t *Tester) testListError() {
...
@@ -853,7 +853,7 @@ func (t *Tester) testListError() {
storageError
:=
fmt
.
Errorf
(
"test error"
)
storageError
:=
fmt
.
Errorf
(
"test error"
)
t
.
withStorageError
(
storageError
,
func
()
{
t
.
withStorageError
(
storageError
,
func
()
{
_
,
err
:=
t
.
storage
.
(
rest
.
Lister
)
.
List
(
ctx
,
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
_
,
err
:=
t
.
storage
.
(
rest
.
Lister
)
.
List
(
ctx
,
nil
)
if
err
!=
storageError
{
if
err
!=
storageError
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -870,7 +870,7 @@ func (t *Tester) testListFound(obj runtime.Object, assignFn AssignFunc) {
...
@@ -870,7 +870,7 @@ func (t *Tester) testListFound(obj runtime.Object, assignFn AssignFunc) {
existing
:=
assignFn
([]
runtime
.
Object
{
foo1
,
foo2
})
existing
:=
assignFn
([]
runtime
.
Object
{
foo1
,
foo2
})
listObj
,
err
:=
t
.
storage
.
(
rest
.
Lister
)
.
List
(
ctx
,
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
listObj
,
err
:=
t
.
storage
.
(
rest
.
Lister
)
.
List
(
ctx
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -902,7 +902,8 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) {
...
@@ -902,7 +902,8 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) {
filtered
:=
[]
runtime
.
Object
{
existing
[
1
]}
filtered
:=
[]
runtime
.
Object
{
existing
[
1
]}
selector
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
testLabels
))
selector
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
testLabels
))
listObj
,
err
:=
t
.
storage
.
(
rest
.
Lister
)
.
List
(
ctx
,
selector
,
fields
.
Everything
(),
nil
)
options
:=
&
api
.
ListOptions
{
LabelSelector
:
selector
}
listObj
,
err
:=
t
.
storage
.
(
rest
.
Lister
)
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -924,7 +925,7 @@ func (t *Tester) testListNotFound(assignFn AssignFunc, setRVFn SetRVFunc) {
...
@@ -924,7 +925,7 @@ func (t *Tester) testListNotFound(assignFn AssignFunc, setRVFn SetRVFunc) {
setRVFn
(
uint64
(
123
))
setRVFn
(
uint64
(
123
))
_
=
assignFn
([]
runtime
.
Object
{})
_
=
assignFn
([]
runtime
.
Object
{})
listObj
,
err
:=
t
.
storage
.
(
rest
.
Lister
)
.
List
(
ctx
,
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
listObj
,
err
:=
t
.
storage
.
(
rest
.
Lister
)
.
List
(
ctx
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -950,7 +951,7 @@ func (t *Tester) testListNotFound(assignFn AssignFunc, setRVFn SetRVFunc) {
...
@@ -950,7 +951,7 @@ func (t *Tester) testListNotFound(assignFn AssignFunc, setRVFn SetRVFunc) {
func
(
t
*
Tester
)
testWatch
(
initWatchFn
InitWatchFunc
,
injectErrFn
InjectErrFunc
)
{
func
(
t
*
Tester
)
testWatch
(
initWatchFn
InitWatchFunc
,
injectErrFn
InjectErrFunc
)
{
ctx
:=
t
.
TestContext
()
ctx
:=
t
.
TestContext
()
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
labels
.
Everything
(),
fields
.
Everything
(),
"1"
)
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
&
api
.
ListOptions
{
ResourceVersion
:
"1"
}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -976,7 +977,8 @@ func (t *Tester) testWatchFields(obj runtime.Object, initWatchFn InitWatchFunc,
...
@@ -976,7 +977,8 @@ func (t *Tester) testWatchFields(obj runtime.Object, initWatchFn InitWatchFunc,
for
_
,
field
:=
range
fieldsPass
{
for
_
,
field
:=
range
fieldsPass
{
for
_
,
action
:=
range
actions
{
for
_
,
action
:=
range
actions
{
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
labels
.
Everything
(),
field
.
AsSelector
(),
"1"
)
options
:=
&
api
.
ListOptions
{
FieldSelector
:
field
.
AsSelector
(),
ResourceVersion
:
"1"
}
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -999,7 +1001,8 @@ func (t *Tester) testWatchFields(obj runtime.Object, initWatchFn InitWatchFunc,
...
@@ -999,7 +1001,8 @@ func (t *Tester) testWatchFields(obj runtime.Object, initWatchFn InitWatchFunc,
for
_
,
field
:=
range
fieldsFail
{
for
_
,
field
:=
range
fieldsFail
{
for
_
,
action
:=
range
actions
{
for
_
,
action
:=
range
actions
{
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
labels
.
Everything
(),
field
.
AsSelector
(),
"1"
)
options
:=
&
api
.
ListOptions
{
FieldSelector
:
field
.
AsSelector
(),
ResourceVersion
:
"1"
}
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -1024,7 +1027,8 @@ func (t *Tester) testWatchLabels(obj runtime.Object, initWatchFn InitWatchFunc,
...
@@ -1024,7 +1027,8 @@ func (t *Tester) testWatchLabels(obj runtime.Object, initWatchFn InitWatchFunc,
for
_
,
label
:=
range
labelsPass
{
for
_
,
label
:=
range
labelsPass
{
for
_
,
action
:=
range
actions
{
for
_
,
action
:=
range
actions
{
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
label
.
AsSelector
(),
fields
.
Everything
(),
"1"
)
options
:=
&
api
.
ListOptions
{
LabelSelector
:
label
.
AsSelector
(),
ResourceVersion
:
"1"
}
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
@@ -1047,7 +1051,8 @@ func (t *Tester) testWatchLabels(obj runtime.Object, initWatchFn InitWatchFunc,
...
@@ -1047,7 +1051,8 @@ func (t *Tester) testWatchLabels(obj runtime.Object, initWatchFn InitWatchFunc,
for
_
,
label
:=
range
labelsFail
{
for
_
,
label
:=
range
labelsFail
{
for
_
,
action
:=
range
actions
{
for
_
,
action
:=
range
actions
{
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
label
.
AsSelector
(),
fields
.
Everything
(),
"1"
)
options
:=
&
api
.
ListOptions
{
LabelSelector
:
label
.
AsSelector
(),
ResourceVersion
:
"1"
}
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
...
pkg/apiserver/apiserver_test.go
View file @
9c53f301
...
@@ -307,13 +307,19 @@ type SimpleRESTStorage struct {
...
@@ -307,13 +307,19 @@ type SimpleRESTStorage struct {
injectedFunction
func
(
obj
runtime
.
Object
)
(
returnObj
runtime
.
Object
,
err
error
)
injectedFunction
func
(
obj
runtime
.
Object
)
(
returnObj
runtime
.
Object
,
err
error
)
}
}
func
(
storage
*
SimpleRESTStorage
)
List
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
storage
*
SimpleRESTStorage
)
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
storage
.
checkContext
(
ctx
)
storage
.
checkContext
(
ctx
)
result
:=
&
apiservertesting
.
SimpleList
{
result
:=
&
apiservertesting
.
SimpleList
{
Items
:
storage
.
list
,
Items
:
storage
.
list
,
}
}
storage
.
requestedLabelSelector
=
label
storage
.
requestedLabelSelector
=
labels
.
Everything
()
storage
.
requestedFieldSelector
=
field
if
options
!=
nil
&&
options
.
LabelSelector
!=
nil
{
storage
.
requestedLabelSelector
=
options
.
LabelSelector
}
storage
.
requestedFieldSelector
=
fields
.
Everything
()
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
{
storage
.
requestedFieldSelector
=
options
.
FieldSelector
}
return
result
,
storage
.
errors
[
"list"
]
return
result
,
storage
.
errors
[
"list"
]
}
}
...
@@ -410,11 +416,20 @@ func (storage *SimpleRESTStorage) Update(ctx api.Context, obj runtime.Object) (r
...
@@ -410,11 +416,20 @@ func (storage *SimpleRESTStorage) Update(ctx api.Context, obj runtime.Object) (r
}
}
// Implement ResourceWatcher.
// Implement ResourceWatcher.
func
(
storage
*
SimpleRESTStorage
)
Watch
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
storage
*
SimpleRESTStorage
)
Watch
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
storage
.
checkContext
(
ctx
)
storage
.
checkContext
(
ctx
)
storage
.
requestedLabelSelector
=
label
storage
.
requestedLabelSelector
=
labels
.
Everything
()
storage
.
requestedFieldSelector
=
field
if
options
!=
nil
&&
options
.
LabelSelector
!=
nil
{
storage
.
requestedResourceVersion
=
resourceVersion
storage
.
requestedLabelSelector
=
options
.
LabelSelector
}
storage
.
requestedFieldSelector
=
fields
.
Everything
()
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
{
storage
.
requestedFieldSelector
=
options
.
FieldSelector
}
storage
.
requestedResourceVersion
=
""
if
options
!=
nil
{
storage
.
requestedResourceVersion
=
options
.
ResourceVersion
}
storage
.
requestedResourceNamespace
=
api
.
NamespaceValue
(
ctx
)
storage
.
requestedResourceNamespace
=
api
.
NamespaceValue
(
ctx
)
if
err
:=
storage
.
errors
[
"watch"
];
err
!=
nil
{
if
err
:=
storage
.
errors
[
"watch"
];
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
pkg/apiserver/resthandler.go
View file @
9c53f301
...
@@ -267,7 +267,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
...
@@ -267,7 +267,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
}
}
if
(
opts
.
Watch
||
forceWatch
)
&&
rw
!=
nil
{
if
(
opts
.
Watch
||
forceWatch
)
&&
rw
!=
nil
{
watcher
,
err
:=
rw
.
Watch
(
ctx
,
opts
.
LabelSelector
,
opts
.
FieldSelector
,
opts
.
ResourceVersion
)
watcher
,
err
:=
rw
.
Watch
(
ctx
,
&
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
errorJSON
(
err
,
scope
.
Codec
,
w
)
errorJSON
(
err
,
scope
.
Codec
,
w
)
return
return
...
@@ -284,7 +284,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
...
@@ -284,7 +284,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
return
return
}
}
result
,
err
:=
r
.
List
(
ctx
,
opts
.
LabelSelector
,
opts
.
FieldSelector
,
&
opts
)
result
,
err
:=
r
.
List
(
ctx
,
&
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
errorJSON
(
err
,
scope
.
Codec
,
w
)
errorJSON
(
err
,
scope
.
Codec
,
w
)
return
return
...
...
pkg/master/master.go
View file @
9c53f301
...
@@ -42,9 +42,7 @@ import (
...
@@ -42,9 +42,7 @@ import (
"k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/auth/handlers"
"k8s.io/kubernetes/pkg/auth/handlers"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/registry/componentstatus"
"k8s.io/kubernetes/pkg/registry/componentstatus"
controlleretcd
"k8s.io/kubernetes/pkg/registry/controller/etcd"
controlleretcd
"k8s.io/kubernetes/pkg/registry/controller/etcd"
...
@@ -935,7 +933,7 @@ func (m *Master) RemoveThirdPartyResource(path string) error {
...
@@ -935,7 +933,7 @@ func (m *Master) RemoveThirdPartyResource(path string) error {
func
(
m
*
Master
)
removeAllThirdPartyResources
(
registry
*
thirdpartyresourcedataetcd
.
REST
)
error
{
func
(
m
*
Master
)
removeAllThirdPartyResources
(
registry
*
thirdpartyresourcedataetcd
.
REST
)
error
{
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
existingData
,
err
:=
registry
.
List
(
ctx
,
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
existingData
,
err
:=
registry
.
List
(
ctx
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -1138,7 +1136,7 @@ func findExternalAddress(node *api.Node) (string, error) {
...
@@ -1138,7 +1136,7 @@ func findExternalAddress(node *api.Node) (string, error) {
}
}
func
(
m
*
Master
)
getNodeAddresses
()
([]
string
,
error
)
{
func
(
m
*
Master
)
getNodeAddresses
()
([]
string
,
error
)
{
nodes
,
err
:=
m
.
nodeRegistry
.
ListNodes
(
api
.
NewDefaultContext
(),
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
nodes
,
err
:=
m
.
nodeRegistry
.
ListNodes
(
api
.
NewDefaultContext
(),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/master/master_test.go
View file @
9c53f301
...
@@ -40,8 +40,6 @@ import (
...
@@ -40,8 +40,6 @@ import (
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/apiserver"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/endpoint"
"k8s.io/kubernetes/pkg/registry/endpoint"
"k8s.io/kubernetes/pkg/registry/namespace"
"k8s.io/kubernetes/pkg/registry/namespace"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/registry/registrytest"
...
@@ -338,14 +336,14 @@ func TestGetNodeAddresses(t *testing.T) {
...
@@ -338,14 +336,14 @@ func TestGetNodeAddresses(t *testing.T) {
master
,
_
,
assert
:=
setUp
(
t
)
master
,
_
,
assert
:=
setUp
(
t
)
// Fail case (no addresses associated with nodes)
// Fail case (no addresses associated with nodes)
nodes
,
_
:=
master
.
nodeRegistry
.
ListNodes
(
api
.
NewDefaultContext
(),
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
nodes
,
_
:=
master
.
nodeRegistry
.
ListNodes
(
api
.
NewDefaultContext
(),
nil
)
addrs
,
err
:=
master
.
getNodeAddresses
()
addrs
,
err
:=
master
.
getNodeAddresses
()
assert
.
Error
(
err
,
"getNodeAddresses should have caused an error as there are no addresses."
)
assert
.
Error
(
err
,
"getNodeAddresses should have caused an error as there are no addresses."
)
assert
.
Equal
([]
string
(
nil
),
addrs
)
assert
.
Equal
([]
string
(
nil
),
addrs
)
// Pass case with External type IP
// Pass case with External type IP
nodes
,
_
=
master
.
nodeRegistry
.
ListNodes
(
api
.
NewDefaultContext
(),
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
nodes
,
_
=
master
.
nodeRegistry
.
ListNodes
(
api
.
NewDefaultContext
(),
nil
)
for
index
:=
range
nodes
.
Items
{
for
index
:=
range
nodes
.
Items
{
nodes
.
Items
[
index
]
.
Status
.
Addresses
=
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeExternalIP
,
Address
:
"127.0.0.1"
}}
nodes
.
Items
[
index
]
.
Status
.
Addresses
=
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeExternalIP
,
Address
:
"127.0.0.1"
}}
}
}
...
@@ -354,7 +352,7 @@ func TestGetNodeAddresses(t *testing.T) {
...
@@ -354,7 +352,7 @@ func TestGetNodeAddresses(t *testing.T) {
assert
.
Equal
([]
string
{
"127.0.0.1"
,
"127.0.0.1"
},
addrs
)
assert
.
Equal
([]
string
{
"127.0.0.1"
,
"127.0.0.1"
},
addrs
)
// Pass case with LegacyHost type IP
// Pass case with LegacyHost type IP
nodes
,
_
=
master
.
nodeRegistry
.
ListNodes
(
api
.
NewDefaultContext
(),
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
nodes
,
_
=
master
.
nodeRegistry
.
ListNodes
(
api
.
NewDefaultContext
(),
nil
)
for
index
:=
range
nodes
.
Items
{
for
index
:=
range
nodes
.
Items
{
nodes
.
Items
[
index
]
.
Status
.
Addresses
=
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
"127.0.0.2"
}}
nodes
.
Items
[
index
]
.
Status
.
Addresses
=
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
"127.0.0.2"
}}
}
}
...
...
pkg/master/thirdparty_controller.go
View file @
9c53f301
...
@@ -22,8 +22,6 @@ import (
...
@@ -22,8 +22,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
expapi
"k8s.io/kubernetes/pkg/apis/extensions"
expapi
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
thirdpartyresourceetcd
"k8s.io/kubernetes/pkg/registry/thirdpartyresource/etcd"
thirdpartyresourceetcd
"k8s.io/kubernetes/pkg/registry/thirdpartyresource/etcd"
"k8s.io/kubernetes/pkg/registry/thirdpartyresourcedata"
"k8s.io/kubernetes/pkg/registry/thirdpartyresourcedata"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
...
@@ -76,7 +74,7 @@ func (t *ThirdPartyController) SyncOneResource(rsrc *expapi.ThirdPartyResource)
...
@@ -76,7 +74,7 @@ func (t *ThirdPartyController) SyncOneResource(rsrc *expapi.ThirdPartyResource)
// Synchronize all resources with RESTful resources on the master
// Synchronize all resources with RESTful resources on the master
func
(
t
*
ThirdPartyController
)
SyncResources
()
error
{
func
(
t
*
ThirdPartyController
)
SyncResources
()
error
{
list
,
err
:=
t
.
thirdPartyResourceRegistry
.
List
(
api
.
NewDefaultContext
(),
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
list
,
err
:=
t
.
thirdPartyResourceRegistry
.
List
(
api
.
NewDefaultContext
(),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/registry/componentstatus/rest.go
View file @
9c53f301
...
@@ -22,8 +22,6 @@ import (
...
@@ -22,8 +22,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
)
)
...
@@ -51,7 +49,7 @@ func (rs *REST) NewList() runtime.Object {
...
@@ -51,7 +49,7 @@ func (rs *REST) NewList() runtime.Object {
// Returns the list of component status. Note that the label and field are both ignored.
// Returns the list of component status. Note that the label and field are both ignored.
// Note that this call doesn't support labels or selectors.
// Note that this call doesn't support labels or selectors.
func
(
rs
*
REST
)
List
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
rs
*
REST
)
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
servers
:=
rs
.
GetServersToValidate
()
servers
:=
rs
.
GetServersToValidate
()
// TODO: This should be parallelized.
// TODO: This should be parallelized.
...
...
pkg/registry/componentstatus/rest_test.go
View file @
9c53f301
...
@@ -27,8 +27,6 @@ import (
...
@@ -27,8 +27,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
)
)
...
@@ -78,7 +76,7 @@ func createTestStatus(name string, status api.ConditionStatus, msg string, err s
...
@@ -78,7 +76,7 @@ func createTestStatus(name string, status api.ConditionStatus, msg string, err s
func
TestList_NoError
(
t
*
testing
.
T
)
{
func
TestList_NoError
(
t
*
testing
.
T
)
{
r
:=
NewTestREST
(
testResponse
{
code
:
200
,
data
:
"ok"
})
r
:=
NewTestREST
(
testResponse
{
code
:
200
,
data
:
"ok"
})
got
,
err
:=
r
.
List
(
api
.
NewContext
(),
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
got
,
err
:=
r
.
List
(
api
.
NewContext
(),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
}
...
@@ -92,7 +90,7 @@ func TestList_NoError(t *testing.T) {
...
@@ -92,7 +90,7 @@ func TestList_NoError(t *testing.T) {
func
TestList_FailedCheck
(
t
*
testing
.
T
)
{
func
TestList_FailedCheck
(
t
*
testing
.
T
)
{
r
:=
NewTestREST
(
testResponse
{
code
:
500
,
data
:
""
})
r
:=
NewTestREST
(
testResponse
{
code
:
500
,
data
:
""
})
got
,
err
:=
r
.
List
(
api
.
NewContext
(),
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
got
,
err
:=
r
.
List
(
api
.
NewContext
(),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
}
...
@@ -107,7 +105,7 @@ func TestList_FailedCheck(t *testing.T) {
...
@@ -107,7 +105,7 @@ func TestList_FailedCheck(t *testing.T) {
func
TestList_UnknownError
(
t
*
testing
.
T
)
{
func
TestList_UnknownError
(
t
*
testing
.
T
)
{
r
:=
NewTestREST
(
testResponse
{
code
:
500
,
data
:
""
,
err
:
fmt
.
Errorf
(
"fizzbuzz error"
)})
r
:=
NewTestREST
(
testResponse
{
code
:
500
,
data
:
""
,
err
:
fmt
.
Errorf
(
"fizzbuzz error"
)})
got
,
err
:=
r
.
List
(
api
.
NewContext
(),
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
got
,
err
:=
r
.
List
(
api
.
NewContext
(),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
}
...
...
pkg/registry/controller/registry.go
View file @
9c53f301
...
@@ -21,15 +21,13 @@ import (
...
@@ -21,15 +21,13 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
// Registry is an interface for things that know how to store ReplicationControllers.
// Registry is an interface for things that know how to store ReplicationControllers.
type
Registry
interface
{
type
Registry
interface
{
ListControllers
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
ReplicationControllerList
,
error
)
ListControllers
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ReplicationControllerList
,
error
)
WatchControllers
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
WatchControllers
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
GetController
(
ctx
api
.
Context
,
controllerID
string
)
(
*
api
.
ReplicationController
,
error
)
GetController
(
ctx
api
.
Context
,
controllerID
string
)
(
*
api
.
ReplicationController
,
error
)
CreateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
CreateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
UpdateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
UpdateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
...
@@ -47,20 +45,19 @@ func NewRegistry(s rest.StandardStorage) Registry {
...
@@ -47,20 +45,19 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
return
&
storage
{
s
}
}
}
// List obtains a list of ReplicationControllers that match selector.
func
(
s
*
storage
)
ListControllers
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ReplicationControllerList
,
error
)
{
func
(
s
*
storage
)
ListControllers
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
ReplicationControllerList
,
error
)
{
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
&&
!
options
.
FieldSelector
.
Empty
()
{
if
!
field
.
Empty
()
{
return
nil
,
fmt
.
Errorf
(
"field selector not supported yet"
)
return
nil
,
fmt
.
Errorf
(
"field selector not supported yet"
)
}
}
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
obj
.
(
*
api
.
ReplicationControllerList
),
err
return
obj
.
(
*
api
.
ReplicationControllerList
),
err
}
}
func
(
s
*
storage
)
WatchControllers
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchControllers
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
label
,
field
,
resourceVersion
)
return
s
.
Watch
(
ctx
,
options
)
}
}
func
(
s
*
storage
)
GetController
(
ctx
api
.
Context
,
controllerID
string
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
s
*
storage
)
GetController
(
ctx
api
.
Context
,
controllerID
string
)
(
*
api
.
ReplicationController
,
error
)
{
...
...
pkg/registry/deployment/registry.go
View file @
9c53f301
...
@@ -22,13 +22,11 @@ import (
...
@@ -22,13 +22,11 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
)
)
// Registry is an interface for things that know how to store Deployments.
// Registry is an interface for things that know how to store Deployments.
type
Registry
interface
{
type
Registry
interface
{
ListDeployments
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
extensions
.
DeploymentList
,
error
)
ListDeployments
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
extensions
.
DeploymentList
,
error
)
GetDeployment
(
ctx
api
.
Context
,
deploymentID
string
)
(
*
extensions
.
Deployment
,
error
)
GetDeployment
(
ctx
api
.
Context
,
deploymentID
string
)
(
*
extensions
.
Deployment
,
error
)
CreateDeployment
(
ctx
api
.
Context
,
deployment
*
extensions
.
Deployment
)
(
*
extensions
.
Deployment
,
error
)
CreateDeployment
(
ctx
api
.
Context
,
deployment
*
extensions
.
Deployment
)
(
*
extensions
.
Deployment
,
error
)
UpdateDeployment
(
ctx
api
.
Context
,
deployment
*
extensions
.
Deployment
)
(
*
extensions
.
Deployment
,
error
)
UpdateDeployment
(
ctx
api
.
Context
,
deployment
*
extensions
.
Deployment
)
(
*
extensions
.
Deployment
,
error
)
...
@@ -45,12 +43,11 @@ func NewRegistry(s rest.StandardStorage) Registry {
...
@@ -45,12 +43,11 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
return
&
storage
{
s
}
}
}
// List obtains a list of Deployments that match selector.
func
(
s
*
storage
)
ListDeployments
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
extensions
.
DeploymentList
,
error
)
{
func
(
s
*
storage
)
ListDeployments
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
extensions
.
DeploymentList
,
error
)
{
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
&&
!
options
.
FieldSelector
.
Empty
()
{
if
!
field
.
Empty
()
{
return
nil
,
fmt
.
Errorf
(
"field selector not supported yet"
)
return
nil
,
fmt
.
Errorf
(
"field selector not supported yet"
)
}
}
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/registry/endpoint/registry.go
View file @
9c53f301
...
@@ -19,16 +19,14 @@ package endpoint
...
@@ -19,16 +19,14 @@ package endpoint
import
(
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
// Registry is an interface for things that know how to store endpoints.
// Registry is an interface for things that know how to store endpoints.
type
Registry
interface
{
type
Registry
interface
{
ListEndpoints
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
ListEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
GetEndpoints
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Endpoints
,
error
)
GetEndpoints
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Endpoints
,
error
)
WatchEndpoints
(
ctx
api
.
Context
,
labels
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
WatchEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
UpdateEndpoints
(
ctx
api
.
Context
,
e
*
api
.
Endpoints
)
error
UpdateEndpoints
(
ctx
api
.
Context
,
e
*
api
.
Endpoints
)
error
DeleteEndpoints
(
ctx
api
.
Context
,
name
string
)
error
DeleteEndpoints
(
ctx
api
.
Context
,
name
string
)
error
}
}
...
@@ -44,16 +42,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
...
@@ -44,16 +42,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
return
&
storage
{
s
}
}
}
func
(
s
*
storage
)
ListEndpoints
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
{
func
(
s
*
storage
)
ListEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
obj
.
(
*
api
.
EndpointsList
),
nil
return
obj
.
(
*
api
.
EndpointsList
),
nil
}
}
func
(
s
*
storage
)
WatchEndpoints
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
label
,
field
,
resourceVersion
)
return
s
.
Watch
(
ctx
,
options
)
}
}
func
(
s
*
storage
)
GetEndpoints
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Endpoints
,
error
)
{
func
(
s
*
storage
)
GetEndpoints
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Endpoints
,
error
)
{
...
...
pkg/registry/generic/etcd/etcd.go
View file @
9c53f301
...
@@ -159,7 +159,15 @@ func (e *Etcd) NewList() runtime.Object {
...
@@ -159,7 +159,15 @@ func (e *Etcd) NewList() runtime.Object {
}
}
// List returns a list of items matching labels and field
// List returns a list of items matching labels and field
func
(
e
*
Etcd
)
List
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
e
*
Etcd
)
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
label
:=
labels
.
Everything
()
if
options
!=
nil
&&
options
.
LabelSelector
!=
nil
{
label
=
options
.
LabelSelector
}
field
:=
fields
.
Everything
()
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
{
field
=
options
.
FieldSelector
}
return
e
.
ListPredicate
(
ctx
,
e
.
PredicateFunc
(
label
,
field
),
options
)
return
e
.
ListPredicate
(
ctx
,
e
.
PredicateFunc
(
label
,
field
),
options
)
}
}
...
@@ -463,7 +471,19 @@ func (e *Etcd) finalizeDelete(obj runtime.Object, runHooks bool) (runtime.Object
...
@@ -463,7 +471,19 @@ func (e *Etcd) finalizeDelete(obj runtime.Object, runHooks bool) (runtime.Object
// WatchPredicate. If possible, you should customize PredicateFunc to produre a
// WatchPredicate. If possible, you should customize PredicateFunc to produre a
// matcher that matches by key. generic.SelectionPredicate does this for you
// matcher that matches by key. generic.SelectionPredicate does this for you
// automatically.
// automatically.
func
(
e
*
Etcd
)
Watch
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
e
*
Etcd
)
Watch
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
label
:=
labels
.
Everything
()
if
options
!=
nil
&&
options
.
LabelSelector
!=
nil
{
label
=
options
.
LabelSelector
}
field
:=
fields
.
Everything
()
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
{
field
=
options
.
FieldSelector
}
resourceVersion
:=
""
if
options
!=
nil
{
resourceVersion
=
options
.
ResourceVersion
}
return
e
.
WatchPredicate
(
ctx
,
e
.
PredicateFunc
(
label
,
field
),
resourceVersion
)
return
e
.
WatchPredicate
(
ctx
,
e
.
PredicateFunc
(
label
,
field
),
resourceVersion
)
}
}
...
...
pkg/registry/job/registry.go
deleted
100644 → 0
View file @
cd7e4bd6
/*
Copyright 2015 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
job
import
(
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store Jobs.
type
Registry
interface
{
// ListJobs obtains a list of Jobs having labels and fields which match selector.
ListJobs
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
extensions
.
JobList
,
error
)
// WatchJobs watch for new/changed/deleted Jobs.
WatchJobs
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
// GetJobs gets a specific Job.
GetJob
(
ctx
api
.
Context
,
name
string
)
(
*
extensions
.
Job
,
error
)
// CreateJob creates a Job based on a specification.
CreateJob
(
ctx
api
.
Context
,
job
*
extensions
.
Job
)
(
*
extensions
.
Job
,
error
)
// UpdateJob updates an existing Job.
UpdateJob
(
ctx
api
.
Context
,
job
*
extensions
.
Job
)
(
*
extensions
.
Job
,
error
)
// DeleteJob deletes an existing Job.
DeleteJob
(
ctx
api
.
Context
,
name
string
)
error
}
// storage puts strong typing around storage calls
type
storage
struct
{
rest
.
StandardStorage
}
// NewRegistry returns a new Registry interface for the given Storage. Any mismatched
// types will panic.
func
NewRegistry
(
s
rest
.
StandardStorage
)
Registry
{
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListJobs
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
extensions
.
JobList
,
error
)
{
if
!
field
.
Empty
()
{
return
nil
,
fmt
.
Errorf
(
"field selector not supported yet"
)
}
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
if
err
!=
nil
{
return
nil
,
err
}
return
obj
.
(
*
extensions
.
JobList
),
err
}
func
(
s
*
storage
)
WatchJobs
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
label
,
field
,
resourceVersion
)
}
func
(
s
*
storage
)
GetJob
(
ctx
api
.
Context
,
name
string
)
(
*
extensions
.
Job
,
error
)
{
obj
,
err
:=
s
.
Get
(
ctx
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
return
obj
.
(
*
extensions
.
Job
),
nil
}
func
(
s
*
storage
)
CreateJob
(
ctx
api
.
Context
,
job
*
extensions
.
Job
)
(
*
extensions
.
Job
,
error
)
{
obj
,
err
:=
s
.
Create
(
ctx
,
job
)
if
err
!=
nil
{
return
nil
,
err
}
return
obj
.
(
*
extensions
.
Job
),
nil
}
func
(
s
*
storage
)
UpdateJob
(
ctx
api
.
Context
,
job
*
extensions
.
Job
)
(
*
extensions
.
Job
,
error
)
{
obj
,
_
,
err
:=
s
.
Update
(
ctx
,
job
)
if
err
!=
nil
{
return
nil
,
err
}
return
obj
.
(
*
extensions
.
Job
),
nil
}
func
(
s
*
storage
)
DeleteJob
(
ctx
api
.
Context
,
name
string
)
error
{
_
,
err
:=
s
.
Delete
(
ctx
,
name
,
nil
)
return
err
}
pkg/registry/namespace/registry.go
View file @
9c53f301
...
@@ -19,24 +19,16 @@ package namespace
...
@@ -19,24 +19,16 @@ package namespace
import
(
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
// Registry is an interface implemented by things that know how to store Namespace objects.
// Registry is an interface implemented by things that know how to store Namespace objects.
type
Registry
interface
{
type
Registry
interface
{
// ListNamespaces obtains a list of namespaces having labels which match selector.
ListNamespaces
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NamespaceList
,
error
)
ListNamespaces
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
NamespaceList
,
error
)
WatchNamespaces
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
// Watch for new/changed/deleted namespaces
WatchNamespaces
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
// Get a specific namespace
GetNamespace
(
ctx
api
.
Context
,
namespaceID
string
)
(
*
api
.
Namespace
,
error
)
GetNamespace
(
ctx
api
.
Context
,
namespaceID
string
)
(
*
api
.
Namespace
,
error
)
// Create a namespace based on a specification.
CreateNamespace
(
ctx
api
.
Context
,
namespace
*
api
.
Namespace
)
error
CreateNamespace
(
ctx
api
.
Context
,
namespace
*
api
.
Namespace
)
error
// Update an existing namespace
UpdateNamespace
(
ctx
api
.
Context
,
namespace
*
api
.
Namespace
)
error
UpdateNamespace
(
ctx
api
.
Context
,
namespace
*
api
.
Namespace
)
error
// Delete an existing namespace
DeleteNamespace
(
ctx
api
.
Context
,
namespaceID
string
)
error
DeleteNamespace
(
ctx
api
.
Context
,
namespaceID
string
)
error
}
}
...
@@ -51,16 +43,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
...
@@ -51,16 +43,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
return
&
storage
{
s
}
}
}
func
(
s
*
storage
)
ListNamespaces
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
NamespaceList
,
error
)
{
func
(
s
*
storage
)
ListNamespaces
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NamespaceList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
obj
.
(
*
api
.
NamespaceList
),
nil
return
obj
.
(
*
api
.
NamespaceList
),
nil
}
}
func
(
s
*
storage
)
WatchNamespaces
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchNamespaces
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
label
,
field
,
resourceVersion
)
return
s
.
Watch
(
ctx
,
options
)
}
}
func
(
s
*
storage
)
GetNamespace
(
ctx
api
.
Context
,
namespaceName
string
)
(
*
api
.
Namespace
,
error
)
{
func
(
s
*
storage
)
GetNamespace
(
ctx
api
.
Context
,
namespaceName
string
)
(
*
api
.
Namespace
,
error
)
{
...
...
pkg/registry/node/registry.go
View file @
9c53f301
...
@@ -19,19 +19,17 @@ package node
...
@@ -19,19 +19,17 @@ package node
import
(
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
// Registry is an interface for things that know how to store node.
// Registry is an interface for things that know how to store node.
type
Registry
interface
{
type
Registry
interface
{
ListNodes
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
ListNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
CreateNode
(
ctx
api
.
Context
,
node
*
api
.
Node
)
error
CreateNode
(
ctx
api
.
Context
,
node
*
api
.
Node
)
error
UpdateNode
(
ctx
api
.
Context
,
node
*
api
.
Node
)
error
UpdateNode
(
ctx
api
.
Context
,
node
*
api
.
Node
)
error
GetNode
(
ctx
api
.
Context
,
nodeID
string
)
(
*
api
.
Node
,
error
)
GetNode
(
ctx
api
.
Context
,
nodeID
string
)
(
*
api
.
Node
,
error
)
DeleteNode
(
ctx
api
.
Context
,
nodeID
string
)
error
DeleteNode
(
ctx
api
.
Context
,
nodeID
string
)
error
WatchNodes
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
WatchNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
}
}
// storage puts strong typing around storage calls
// storage puts strong typing around storage calls
...
@@ -45,8 +43,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
...
@@ -45,8 +43,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
return
&
storage
{
s
}
}
}
func
(
s
*
storage
)
ListNodes
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
{
func
(
s
*
storage
)
ListNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -64,8 +62,8 @@ func (s *storage) UpdateNode(ctx api.Context, node *api.Node) error {
...
@@ -64,8 +62,8 @@ func (s *storage) UpdateNode(ctx api.Context, node *api.Node) error {
return
err
return
err
}
}
func
(
s
*
storage
)
WatchNodes
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
label
,
field
,
resourceVersion
)
return
s
.
Watch
(
ctx
,
options
)
}
}
func
(
s
*
storage
)
GetNode
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Node
,
error
)
{
func
(
s
*
storage
)
GetNode
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Node
,
error
)
{
...
...
pkg/registry/registrytest/endpoint.go
View file @
9c53f301
...
@@ -22,8 +22,6 @@ import (
...
@@ -22,8 +22,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -36,7 +34,7 @@ type EndpointRegistry struct {
...
@@ -36,7 +34,7 @@ type EndpointRegistry struct {
lock
sync
.
Mutex
lock
sync
.
Mutex
}
}
func
(
e
*
EndpointRegistry
)
ListEndpoints
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
{
func
(
e
*
EndpointRegistry
)
ListEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
{
// TODO: support namespaces in this mock
// TODO: support namespaces in this mock
e
.
lock
.
Lock
()
e
.
lock
.
Lock
()
defer
e
.
lock
.
Unlock
()
defer
e
.
lock
.
Unlock
()
...
@@ -61,7 +59,7 @@ func (e *EndpointRegistry) GetEndpoints(ctx api.Context, name string) (*api.Endp
...
@@ -61,7 +59,7 @@ func (e *EndpointRegistry) GetEndpoints(ctx api.Context, name string) (*api.Endp
return
nil
,
errors
.
NewNotFound
(
"Endpoints"
,
name
)
return
nil
,
errors
.
NewNotFound
(
"Endpoints"
,
name
)
}
}
func
(
e
*
EndpointRegistry
)
WatchEndpoints
(
ctx
api
.
Context
,
labels
labels
.
Selector
,
fields
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
e
*
EndpointRegistry
)
WatchEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
nil
,
fmt
.
Errorf
(
"unimplemented!"
)
return
nil
,
fmt
.
Errorf
(
"unimplemented!"
)
}
}
...
...
pkg/registry/registrytest/node.go
View file @
9c53f301
...
@@ -21,8 +21,6 @@ import (
...
@@ -21,8 +21,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -59,7 +57,7 @@ func (r *NodeRegistry) SetError(err error) {
...
@@ -59,7 +57,7 @@ func (r *NodeRegistry) SetError(err error) {
r
.
Err
=
err
r
.
Err
=
err
}
}
func
(
r
*
NodeRegistry
)
ListNodes
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
{
func
(
r
*
NodeRegistry
)
ListNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
{
r
.
Lock
()
r
.
Lock
()
defer
r
.
Unlock
()
defer
r
.
Unlock
()
return
&
r
.
Nodes
,
r
.
Err
return
&
r
.
Nodes
,
r
.
Err
...
@@ -112,6 +110,6 @@ func (r *NodeRegistry) DeleteNode(ctx api.Context, nodeID string) error {
...
@@ -112,6 +110,6 @@ func (r *NodeRegistry) DeleteNode(ctx api.Context, nodeID string) error {
return
r
.
Err
return
r
.
Err
}
}
func
(
r
*
NodeRegistry
)
WatchNodes
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
r
*
NodeRegistry
)
WatchNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
nil
,
r
.
Err
return
nil
,
r
.
Err
}
}
pkg/registry/registrytest/service.go
View file @
9c53f301
...
@@ -20,8 +20,6 @@ import (
...
@@ -20,8 +20,6 @@ import (
"sync"
"sync"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -46,7 +44,7 @@ func (r *ServiceRegistry) SetError(err error) {
...
@@ -46,7 +44,7 @@ func (r *ServiceRegistry) SetError(err error) {
r
.
Err
=
err
r
.
Err
=
err
}
}
func
(
r
*
ServiceRegistry
)
ListServices
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
{
func
(
r
*
ServiceRegistry
)
ListServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
{
r
.
mu
.
Lock
()
r
.
mu
.
Lock
()
defer
r
.
mu
.
Unlock
()
defer
r
.
mu
.
Unlock
()
...
@@ -106,7 +104,7 @@ func (r *ServiceRegistry) UpdateService(ctx api.Context, svc *api.Service) (*api
...
@@ -106,7 +104,7 @@ func (r *ServiceRegistry) UpdateService(ctx api.Context, svc *api.Service) (*api
return
svc
,
r
.
Err
return
svc
,
r
.
Err
}
}
func
(
r
*
ServiceRegistry
)
WatchServices
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
r
*
ServiceRegistry
)
WatchServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
r
.
mu
.
Lock
()
r
.
mu
.
Lock
()
defer
r
.
mu
.
Unlock
()
defer
r
.
mu
.
Unlock
()
...
...
pkg/registry/secret/registry.go
View file @
9c53f301
...
@@ -19,24 +19,16 @@ package secret
...
@@ -19,24 +19,16 @@ package secret
import
(
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
// Registry is an interface implemented by things that know how to store Secret objects.
// Registry is an interface implemented by things that know how to store Secret objects.
type
Registry
interface
{
type
Registry
interface
{
// ListSecrets obtains a list of Secrets having labels which match selector.
ListSecrets
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
SecretList
,
error
)
ListSecrets
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
SecretList
,
error
)
WatchSecrets
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
// Watch for new/changed/deleted secrets
WatchSecrets
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
// Get a specific Secret
GetSecret
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Secret
,
error
)
GetSecret
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Secret
,
error
)
// Create a Secret based on a specification.
CreateSecret
(
ctx
api
.
Context
,
Secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
CreateSecret
(
ctx
api
.
Context
,
Secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
// Update an existing Secret
UpdateSecret
(
ctx
api
.
Context
,
Secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
UpdateSecret
(
ctx
api
.
Context
,
Secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
// Delete an existing Secret
DeleteSecret
(
ctx
api
.
Context
,
name
string
)
error
DeleteSecret
(
ctx
api
.
Context
,
name
string
)
error
}
}
...
@@ -51,16 +43,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
...
@@ -51,16 +43,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
return
&
storage
{
s
}
}
}
func
(
s
*
storage
)
ListSecrets
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
SecretList
,
error
)
{
func
(
s
*
storage
)
ListSecrets
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
SecretList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
obj
.
(
*
api
.
SecretList
),
nil
return
obj
.
(
*
api
.
SecretList
),
nil
}
}
func
(
s
*
storage
)
WatchSecrets
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchSecrets
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
label
,
field
,
resourceVersion
)
return
s
.
Watch
(
ctx
,
options
)
}
}
func
(
s
*
storage
)
GetSecret
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Secret
,
error
)
{
func
(
s
*
storage
)
GetSecret
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Secret
,
error
)
{
...
...
pkg/registry/service/ipallocator/controller/repair.go
View file @
9c53f301
...
@@ -22,8 +22,6 @@ import (
...
@@ -22,8 +22,6 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service/ipallocator"
"k8s.io/kubernetes/pkg/registry/service/ipallocator"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
...
@@ -95,7 +93,7 @@ func (c *Repair) RunOnce() error {
...
@@ -95,7 +93,7 @@ func (c *Repair) RunOnce() error {
ctx
:=
api
.
WithNamespace
(
api
.
NewDefaultContext
(),
api
.
NamespaceAll
)
ctx
:=
api
.
WithNamespace
(
api
.
NewDefaultContext
(),
api
.
NamespaceAll
)
options
:=
&
api
.
ListOptions
{
ResourceVersion
:
latest
.
ObjectMeta
.
ResourceVersion
}
options
:=
&
api
.
ListOptions
{
ResourceVersion
:
latest
.
ObjectMeta
.
ResourceVersion
}
list
,
err
:=
c
.
registry
.
ListServices
(
ctx
,
labels
.
Everything
(),
fields
.
Everything
(),
options
)
list
,
err
:=
c
.
registry
.
ListServices
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to refresh the service IP block: %v"
,
err
)
return
fmt
.
Errorf
(
"unable to refresh the service IP block: %v"
,
err
)
}
}
...
...
pkg/registry/service/portallocator/controller/repair.go
View file @
9c53f301
...
@@ -21,8 +21,6 @@ import (
...
@@ -21,8 +21,6 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service/portallocator"
"k8s.io/kubernetes/pkg/registry/service/portallocator"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
...
@@ -82,7 +80,7 @@ func (c *Repair) RunOnce() error {
...
@@ -82,7 +80,7 @@ func (c *Repair) RunOnce() error {
ctx
:=
api
.
WithNamespace
(
api
.
NewDefaultContext
(),
api
.
NamespaceAll
)
ctx
:=
api
.
WithNamespace
(
api
.
NewDefaultContext
(),
api
.
NamespaceAll
)
options
:=
&
api
.
ListOptions
{
ResourceVersion
:
latest
.
ObjectMeta
.
ResourceVersion
}
options
:=
&
api
.
ListOptions
{
ResourceVersion
:
latest
.
ObjectMeta
.
ResourceVersion
}
list
,
err
:=
c
.
registry
.
ListServices
(
ctx
,
labels
.
Everything
(),
fields
.
Everything
(),
options
)
list
,
err
:=
c
.
registry
.
ListServices
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to refresh the port block: %v"
,
err
)
return
fmt
.
Errorf
(
"unable to refresh the port block: %v"
,
err
)
}
}
...
...
pkg/registry/service/registry.go
View file @
9c53f301
...
@@ -19,19 +19,17 @@ package service
...
@@ -19,19 +19,17 @@ package service
import
(
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
// Registry is an interface for things that know how to store services.
// Registry is an interface for things that know how to store services.
type
Registry
interface
{
type
Registry
interface
{
ListServices
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
ListServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
CreateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
CreateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
GetService
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Service
,
error
)
GetService
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Service
,
error
)
DeleteService
(
ctx
api
.
Context
,
name
string
)
error
DeleteService
(
ctx
api
.
Context
,
name
string
)
error
UpdateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
UpdateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
WatchServices
(
ctx
api
.
Context
,
labels
labels
.
Selector
,
fields
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
WatchServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
}
}
// storage puts strong typing around storage calls
// storage puts strong typing around storage calls
...
@@ -45,8 +43,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
...
@@ -45,8 +43,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
return
&
storage
{
s
}
}
}
func
(
s
*
storage
)
ListServices
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
{
func
(
s
*
storage
)
ListServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -82,8 +80,8 @@ func (s *storage) UpdateService(ctx api.Context, svc *api.Service) (*api.Service
...
@@ -82,8 +80,8 @@ func (s *storage) UpdateService(ctx api.Context, svc *api.Service) (*api.Service
return
obj
.
(
*
api
.
Service
),
nil
return
obj
.
(
*
api
.
Service
),
nil
}
}
func
(
s
*
storage
)
WatchServices
(
ctx
api
.
Context
,
labels
labels
.
Selector
,
fields
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
labels
,
fields
,
resourceVersion
)
return
s
.
Watch
(
ctx
,
options
)
}
}
// TODO: Move to a general location (as other components may need allocation in future; it's not service specific)
// TODO: Move to a general location (as other components may need allocation in future; it's not service specific)
...
...
pkg/registry/service/rest.go
View file @
9c53f301
...
@@ -30,8 +30,6 @@ import (
...
@@ -30,8 +30,6 @@ import (
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/endpoint"
"k8s.io/kubernetes/pkg/registry/endpoint"
"k8s.io/kubernetes/pkg/registry/service/ipallocator"
"k8s.io/kubernetes/pkg/registry/service/ipallocator"
"k8s.io/kubernetes/pkg/registry/service/portallocator"
"k8s.io/kubernetes/pkg/registry/service/portallocator"
...
@@ -173,14 +171,14 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
...
@@ -173,14 +171,14 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
return
rs
.
registry
.
GetService
(
ctx
,
id
)
return
rs
.
registry
.
GetService
(
ctx
,
id
)
}
}
func
(
rs
*
REST
)
List
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
rs
*
REST
)
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
return
rs
.
registry
.
ListServices
(
ctx
,
label
,
field
,
options
)
return
rs
.
registry
.
ListServices
(
ctx
,
options
)
}
}
// Watch returns Services events via a watch.Interface.
// Watch returns Services events via a watch.Interface.
// It implements rest.Watcher.
// It implements rest.Watcher.
func
(
rs
*
REST
)
Watch
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
rs
*
REST
)
Watch
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
rs
.
registry
.
WatchServices
(
ctx
,
label
,
field
,
resourceVersion
)
return
rs
.
registry
.
WatchServices
(
ctx
,
options
)
}
}
func
(
*
REST
)
New
()
runtime
.
Object
{
func
(
*
REST
)
New
()
runtime
.
Object
{
...
...
pkg/registry/service/rest_test.go
View file @
9c53f301
...
@@ -24,8 +24,6 @@ import (
...
@@ -24,8 +24,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/registry/registrytest"
"k8s.io/kubernetes/pkg/registry/service/ipallocator"
"k8s.io/kubernetes/pkg/registry/service/ipallocator"
"k8s.io/kubernetes/pkg/registry/service/portallocator"
"k8s.io/kubernetes/pkg/registry/service/portallocator"
...
@@ -543,7 +541,7 @@ func TestServiceRegistryList(t *testing.T) {
...
@@ -543,7 +541,7 @@ func TestServiceRegistryList(t *testing.T) {
},
},
})
})
registry
.
List
.
ResourceVersion
=
"1"
registry
.
List
.
ResourceVersion
=
"1"
s
,
_
:=
storage
.
List
(
ctx
,
labels
.
Everything
(),
fields
.
Everything
(),
nil
)
s
,
_
:=
storage
.
List
(
ctx
,
nil
)
sl
:=
s
.
(
*
api
.
ServiceList
)
sl
:=
s
.
(
*
api
.
ServiceList
)
if
len
(
sl
.
Items
)
!=
2
{
if
len
(
sl
.
Items
)
!=
2
{
t
.
Fatalf
(
"Expected 2 services, but got %v"
,
len
(
sl
.
Items
))
t
.
Fatalf
(
"Expected 2 services, but got %v"
,
len
(
sl
.
Items
))
...
...
pkg/registry/serviceaccount/registry.go
View file @
9c53f301
...
@@ -19,24 +19,16 @@ package serviceaccount
...
@@ -19,24 +19,16 @@ package serviceaccount
import
(
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
// Registry is an interface implemented by things that know how to store ServiceAccount objects.
// Registry is an interface implemented by things that know how to store ServiceAccount objects.
type
Registry
interface
{
type
Registry
interface
{
// ListServiceAccounts obtains a list of ServiceAccounts having labels which match selector.
ListServiceAccounts
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceAccountList
,
error
)
ListServiceAccounts
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceAccountList
,
error
)
WatchServiceAccounts
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
// Watch for new/changed/deleted service accounts
WatchServiceAccounts
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
// Get a specific ServiceAccount
GetServiceAccount
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
ServiceAccount
,
error
)
GetServiceAccount
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
ServiceAccount
,
error
)
// Create a ServiceAccount based on a specification.
CreateServiceAccount
(
ctx
api
.
Context
,
ServiceAccount
*
api
.
ServiceAccount
)
error
CreateServiceAccount
(
ctx
api
.
Context
,
ServiceAccount
*
api
.
ServiceAccount
)
error
// Update an existing ServiceAccount
UpdateServiceAccount
(
ctx
api
.
Context
,
ServiceAccount
*
api
.
ServiceAccount
)
error
UpdateServiceAccount
(
ctx
api
.
Context
,
ServiceAccount
*
api
.
ServiceAccount
)
error
// Delete an existing ServiceAccount
DeleteServiceAccount
(
ctx
api
.
Context
,
name
string
)
error
DeleteServiceAccount
(
ctx
api
.
Context
,
name
string
)
error
}
}
...
@@ -51,16 +43,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
...
@@ -51,16 +43,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
return
&
storage
{
s
}
}
}
func
(
s
*
storage
)
ListServiceAccounts
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceAccountList
,
error
)
{
func
(
s
*
storage
)
ListServiceAccounts
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceAccountList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
obj
.
(
*
api
.
ServiceAccountList
),
nil
return
obj
.
(
*
api
.
ServiceAccountList
),
nil
}
}
func
(
s
*
storage
)
WatchServiceAccounts
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchServiceAccounts
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
label
,
field
,
resourceVersion
)
return
s
.
Watch
(
ctx
,
options
)
}
}
func
(
s
*
storage
)
GetServiceAccount
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
ServiceAccount
,
error
)
{
func
(
s
*
storage
)
GetServiceAccount
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
ServiceAccount
,
error
)
{
...
...
pkg/registry/thirdpartyresourcedata/registry.go
View file @
9c53f301
...
@@ -20,24 +20,16 @@ import (
...
@@ -20,24 +20,16 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
// Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects.
// Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects.
type
Registry
interface
{
type
Registry
interface
{
// ListThirdPartyResourceData obtains a list of ThirdPartyResourceData having labels which match selector.
ListThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
extensions
.
ThirdPartyResourceDataList
,
error
)
ListThirdPartyResourceData
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
extensions
.
ThirdPartyResourceDataList
,
error
)
WatchThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
// Watch for new/changed/deleted ThirdPartyResourceData
WatchThirdPartyResourceData
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
// Get a specific ThirdPartyResourceData
GetThirdPartyResourceData
(
ctx
api
.
Context
,
name
string
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
GetThirdPartyResourceData
(
ctx
api
.
Context
,
name
string
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
// Create a ThirdPartyResourceData based on a specification.
CreateThirdPartyResourceData
(
ctx
api
.
Context
,
resource
*
extensions
.
ThirdPartyResourceData
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
CreateThirdPartyResourceData
(
ctx
api
.
Context
,
resource
*
extensions
.
ThirdPartyResourceData
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
// Update an existing ThirdPartyResourceData
UpdateThirdPartyResourceData
(
ctx
api
.
Context
,
resource
*
extensions
.
ThirdPartyResourceData
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
UpdateThirdPartyResourceData
(
ctx
api
.
Context
,
resource
*
extensions
.
ThirdPartyResourceData
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
// Delete an existing ThirdPartyResourceData
DeleteThirdPartyResourceData
(
ctx
api
.
Context
,
name
string
)
error
DeleteThirdPartyResourceData
(
ctx
api
.
Context
,
name
string
)
error
}
}
...
@@ -52,16 +44,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
...
@@ -52,16 +44,16 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
return
&
storage
{
s
}
}
}
func
(
s
*
storage
)
ListThirdPartyResourceData
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
options
*
api
.
ListOptions
)
(
*
extensions
.
ThirdPartyResourceDataList
,
error
)
{
func
(
s
*
storage
)
ListThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
extensions
.
ThirdPartyResourceDataList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
label
,
field
,
options
)
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
obj
.
(
*
extensions
.
ThirdPartyResourceDataList
),
nil
return
obj
.
(
*
extensions
.
ThirdPartyResourceDataList
),
nil
}
}
func
(
s
*
storage
)
WatchThirdPartyResourceData
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
label
,
field
,
resourceVersion
)
return
s
.
Watch
(
ctx
,
options
)
}
}
func
(
s
*
storage
)
GetThirdPartyResourceData
(
ctx
api
.
Context
,
name
string
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
{
func
(
s
*
storage
)
GetThirdPartyResourceData
(
ctx
api
.
Context
,
name
string
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
{
...
...
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