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
bf13bef9
Commit
bf13bef9
authored
Nov 16, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use unversioned.ListOptions in API server.
parent
a5f9a759
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
178 additions
and
135 deletions
+178
-135
conversion.go
pkg/api/conversion.go
+54
-0
rest.go
pkg/api/rest/rest.go
+3
-2
resttest.go
pkg/api/rest/resttest/resttest.go
+5
-5
fuzzer.go
pkg/api/testing/fuzzer.go
+7
-0
apiserver_test.go
pkg/apiserver/apiserver_test.go
+16
-43
resthandler.go
pkg/apiserver/resthandler.go
+15
-22
watch_test.go
pkg/apiserver/watch_test.go
+4
-4
rest.go
pkg/registry/componentstatus/rest.go
+2
-1
registry.go
pkg/registry/controller/registry.go
+6
-5
registry.go
pkg/registry/deployment/registry.go
+4
-3
registry.go
pkg/registry/endpoint/registry.go
+5
-4
etcd.go
pkg/registry/generic/etcd/etcd.go
+12
-12
registry.go
pkg/registry/namespace/registry.go
+5
-4
registry.go
pkg/registry/node/registry.go
+5
-4
endpoint.go
pkg/registry/registrytest/endpoint.go
+3
-2
node.go
pkg/registry/registrytest/node.go
+3
-2
service.go
pkg/registry/registrytest/service.go
+3
-2
registry.go
pkg/registry/secret/registry.go
+5
-4
repair.go
pkg/registry/service/ipallocator/controller/repair.go
+2
-1
repair.go
pkg/registry/service/portallocator/controller/repair.go
+2
-1
registry.go
pkg/registry/service/registry.go
+5
-4
rest.go
pkg/registry/service/rest.go
+2
-2
registry.go
pkg/registry/serviceaccount/registry.go
+5
-4
registry.go
pkg/registry/thirdpartyresourcedata/registry.go
+5
-4
No files found.
pkg/api/conversion.go
View file @
bf13bef9
...
...
@@ -81,6 +81,60 @@ func init() {
*
out
=
(
*
in
)
.
String
()
return
nil
},
func
(
in
*
string
,
out
*
unversioned
.
LabelSelector
,
s
conversion
.
Scope
)
error
{
selector
,
err
:=
labels
.
Parse
(
*
in
)
if
err
!=
nil
{
return
err
}
*
out
=
unversioned
.
LabelSelector
{
selector
}
return
nil
},
func
(
in
*
string
,
out
*
unversioned
.
FieldSelector
,
s
conversion
.
Scope
)
error
{
selector
,
err
:=
fields
.
ParseSelector
(
*
in
)
if
err
!=
nil
{
return
err
}
*
out
=
unversioned
.
FieldSelector
{
selector
}
return
nil
},
func
(
in
*
[]
string
,
out
*
unversioned
.
LabelSelector
,
s
conversion
.
Scope
)
error
{
selectorString
:=
""
if
len
(
*
in
)
>
0
{
selectorString
=
(
*
in
)[
0
]
}
selector
,
err
:=
labels
.
Parse
(
selectorString
)
if
err
!=
nil
{
return
err
}
*
out
=
unversioned
.
LabelSelector
{
selector
}
return
nil
},
func
(
in
*
[]
string
,
out
*
unversioned
.
FieldSelector
,
s
conversion
.
Scope
)
error
{
selectorString
:=
""
if
len
(
*
in
)
>
0
{
selectorString
=
(
*
in
)[
0
]
}
selector
,
err
:=
fields
.
ParseSelector
(
selectorString
)
if
err
!=
nil
{
return
err
}
*
out
=
unversioned
.
FieldSelector
{
selector
}
return
nil
},
func
(
in
*
unversioned
.
LabelSelector
,
out
*
string
,
s
conversion
.
Scope
)
error
{
if
in
.
Selector
==
nil
{
return
nil
}
*
out
=
in
.
Selector
.
String
()
return
nil
},
func
(
in
*
unversioned
.
FieldSelector
,
out
*
string
,
s
conversion
.
Scope
)
error
{
if
in
.
Selector
==
nil
{
return
nil
}
*
out
=
in
.
Selector
.
String
()
return
nil
},
func
(
in
*
resource
.
Quantity
,
out
*
resource
.
Quantity
,
s
conversion
.
Scope
)
error
{
// Cannot deep copy these, because inf.Dec has unexported fields.
*
out
=
*
in
.
Copy
()
...
...
pkg/api/rest/rest.go
View file @
bf13bef9
...
...
@@ -22,6 +22,7 @@ import (
"net/url"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
)
...
...
@@ -60,7 +61,7 @@ type Lister interface {
// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
NewList
()
runtime
.
Object
// List selects resources in the storage which match to the selector. 'options' can be nil.
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
List
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
runtime
.
Object
,
error
)
}
// Getter is an object that can retrieve a named RESTful resource.
...
...
@@ -181,7 +182,7 @@ type Watcher interface {
// 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
// particular version.
Watch
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
Watch
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
}
// StandardStorage is an interface covering the common verbs. Provided for testing whether a
...
...
pkg/api/rest/resttest/resttest.go
View file @
bf13bef9
...
...
@@ -864,7 +864,7 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) {
filtered
:=
[]
runtime
.
Object
{
objs
[
1
]}
selector
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
testLabels
))
options
:=
&
api
.
ListOptions
{
LabelSelector
:
selector
}
options
:=
&
unversioned
.
ListOptions
{
LabelSelector
:
unversioned
.
LabelSelector
{
selector
}
}
listObj
,
err
:=
t
.
storage
.
(
rest
.
Lister
)
.
List
(
ctx
,
options
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
...
@@ -906,7 +906,7 @@ func (t *Tester) testWatchFields(obj runtime.Object, emitFn EmitFunc, fieldsPass
for
_
,
field
:=
range
fieldsPass
{
for
_
,
action
:=
range
actions
{
options
:=
&
api
.
ListOptions
{
FieldSelector
:
field
.
AsSelector
()
,
ResourceVersion
:
"1"
}
options
:=
&
unversioned
.
ListOptions
{
FieldSelector
:
unversioned
.
FieldSelector
{
field
.
AsSelector
()}
,
ResourceVersion
:
"1"
}
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
options
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v, %v"
,
err
,
action
)
...
...
@@ -930,7 +930,7 @@ func (t *Tester) testWatchFields(obj runtime.Object, emitFn EmitFunc, fieldsPass
for
_
,
field
:=
range
fieldsFail
{
for
_
,
action
:=
range
actions
{
options
:=
&
api
.
ListOptions
{
FieldSelector
:
field
.
AsSelector
()
,
ResourceVersion
:
"1"
}
options
:=
&
unversioned
.
ListOptions
{
FieldSelector
:
unversioned
.
FieldSelector
{
field
.
AsSelector
()}
,
ResourceVersion
:
"1"
}
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
options
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
...
@@ -955,7 +955,7 @@ func (t *Tester) testWatchLabels(obj runtime.Object, emitFn EmitFunc, labelsPass
for
_
,
label
:=
range
labelsPass
{
for
_
,
action
:=
range
actions
{
options
:=
&
api
.
ListOptions
{
LabelSelector
:
label
.
AsSelector
()
,
ResourceVersion
:
"1"
}
options
:=
&
unversioned
.
ListOptions
{
LabelSelector
:
unversioned
.
LabelSelector
{
label
.
AsSelector
()}
,
ResourceVersion
:
"1"
}
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
options
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
...
@@ -978,7 +978,7 @@ func (t *Tester) testWatchLabels(obj runtime.Object, emitFn EmitFunc, labelsPass
for
_
,
label
:=
range
labelsFail
{
for
_
,
action
:=
range
actions
{
options
:=
&
api
.
ListOptions
{
LabelSelector
:
label
.
AsSelector
()
,
ResourceVersion
:
"1"
}
options
:=
&
unversioned
.
ListOptions
{
LabelSelector
:
unversioned
.
LabelSelector
{
label
.
AsSelector
()}
,
ResourceVersion
:
"1"
}
watcher
,
err
:=
t
.
storage
.
(
rest
.
Watcher
)
.
Watch
(
ctx
,
options
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
...
pkg/api/testing/fuzzer.go
View file @
bf13bef9
...
...
@@ -91,6 +91,13 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
j
.
LabelSelector
,
_
=
labels
.
Parse
(
"a=b"
)
j
.
FieldSelector
,
_
=
fields
.
ParseSelector
(
"a=b"
)
},
func
(
j
*
unversioned
.
ListOptions
,
c
fuzz
.
Continue
)
{
// TODO: add some parsing
label
,
_
:=
labels
.
Parse
(
"a=b"
)
j
.
LabelSelector
=
unversioned
.
LabelSelector
{
label
}
field
,
_
:=
fields
.
ParseSelector
(
"a=b"
)
j
.
FieldSelector
=
unversioned
.
FieldSelector
{
field
}
},
func
(
s
*
api
.
PodSpec
,
c
fuzz
.
Continue
)
{
c
.
FuzzNoCustom
(
s
)
// has a default value
...
...
pkg/apiserver/apiserver_test.go
View file @
bf13bef9
...
...
@@ -112,50 +112,23 @@ func newMapper() *meta.DefaultRESTMapper {
}
func
addGrouplessTypes
()
{
type
ListOptions
struct
{
runtime
.
Object
unversioned
.
TypeMeta
`json:",inline"`
LabelSelector
string
`json:"labelSelector,omitempty"`
FieldSelector
string
`json:"fieldSelector,omitempty"`
Watch
bool
`json:"watch,omitempty"`
ResourceVersion
string
`json:"resourceVersion,omitempty"`
TimeoutSeconds
*
int64
`json:"timeoutSeconds,omitempty"`
}
api
.
Scheme
.
AddKnownTypes
(
grouplessGroupVersion
.
String
(),
&
apiservertesting
.
Simple
{},
&
apiservertesting
.
SimpleList
{},
&
unversioned
.
Status
{},
&
ListOptions
{},
&
api
.
DeleteOptions
{},
&
apiservertesting
.
SimpleGetOptions
{},
&
apiservertesting
.
SimpleRoot
{})
&
unversioned
.
ListOptions
{},
&
api
.
DeleteOptions
{},
&
apiservertesting
.
SimpleGetOptions
{},
&
apiservertesting
.
SimpleRoot
{})
api
.
Scheme
.
AddKnownTypes
(
grouplessGroupVersion
.
String
(),
&
api
.
Pod
{})
}
func
addTestTypes
()
{
type
ListOptions
struct
{
runtime
.
Object
unversioned
.
TypeMeta
`json:",inline"`
LabelSelector
string
`json:"labels,omitempty"`
FieldSelector
string
`json:"fields,omitempty"`
Watch
bool
`json:"watch,omitempty"`
ResourceVersion
string
`json:"resourceVersion,omitempty"`
TimeoutSeconds
*
int64
`json:"timeoutSeconds,omitempty"`
}
api
.
Scheme
.
AddKnownTypes
(
testGroupVersion
.
String
(),
&
apiservertesting
.
Simple
{},
&
apiservertesting
.
SimpleList
{},
&
unversioned
.
Status
{},
&
ListOptions
{},
&
api
.
DeleteOptions
{},
&
apiservertesting
.
SimpleGetOptions
{},
&
apiservertesting
.
SimpleRoot
{})
&
unversioned
.
ListOptions
{},
&
api
.
DeleteOptions
{},
&
apiservertesting
.
SimpleGetOptions
{},
&
apiservertesting
.
SimpleRoot
{})
api
.
Scheme
.
AddKnownTypes
(
testGroupVersion
.
String
(),
&
api
.
Pod
{})
}
func
addNewTestTypes
()
{
type
ListOptions
struct
{
runtime
.
Object
unversioned
.
TypeMeta
`json:",inline"`
LabelSelector
string
`json:"labelSelector,omitempty"`
FieldSelector
string
`json:"fieldSelector,omitempty"`
Watch
bool
`json:"watch,omitempty"`
ResourceVersion
string
`json:"resourceVersion,omitempty"`
TimeoutSeconds
*
int64
`json:"timeoutSeconds,omitempty"`
}
api
.
Scheme
.
AddKnownTypes
(
newGroupVersion
.
String
(),
&
apiservertesting
.
Simple
{},
&
apiservertesting
.
SimpleList
{},
&
unversioned
.
Status
{},
&
ListOptions
{},
&
api
.
DeleteOptions
{},
&
apiservertesting
.
SimpleGetOptions
{},
&
apiservertesting
.
SimpleRoot
{})
&
unversioned
.
ListOptions
{},
&
api
.
DeleteOptions
{},
&
apiservertesting
.
SimpleGetOptions
{},
&
apiservertesting
.
SimpleRoot
{})
}
func
init
()
{
...
...
@@ -165,7 +138,7 @@ func init() {
// "internal" version
api
.
Scheme
.
AddKnownTypes
(
""
,
&
apiservertesting
.
Simple
{},
&
apiservertesting
.
SimpleList
{},
&
unversioned
.
Status
{},
&
api
.
ListOptions
{},
&
apiservertesting
.
SimpleGetOptions
{},
&
apiservertesting
.
SimpleRoot
{})
&
unversioned
.
ListOptions
{},
&
apiservertesting
.
SimpleGetOptions
{},
&
apiservertesting
.
SimpleRoot
{})
addGrouplessTypes
()
addTestTypes
()
addNewTestTypes
()
...
...
@@ -363,18 +336,18 @@ type SimpleRESTStorage struct {
injectedFunction
func
(
obj
runtime
.
Object
)
(
returnObj
runtime
.
Object
,
err
error
)
}
func
(
storage
*
SimpleRESTStorage
)
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
storage
*
SimpleRESTStorage
)
List
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
storage
.
checkContext
(
ctx
)
result
:=
&
apiservertesting
.
SimpleList
{
Items
:
storage
.
list
,
}
storage
.
requestedLabelSelector
=
labels
.
Everything
()
if
options
!=
nil
&&
options
.
LabelSelector
!=
nil
{
storage
.
requestedLabelSelector
=
options
.
LabelSelector
if
options
!=
nil
&&
options
.
LabelSelector
.
Selector
!=
nil
{
storage
.
requestedLabelSelector
=
options
.
LabelSelector
.
Selector
}
storage
.
requestedFieldSelector
=
fields
.
Everything
()
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
{
storage
.
requestedFieldSelector
=
options
.
FieldSelector
if
options
!=
nil
&&
options
.
FieldSelector
.
Selector
!=
nil
{
storage
.
requestedFieldSelector
=
options
.
FieldSelector
.
Selector
}
return
result
,
storage
.
errors
[
"list"
]
}
...
...
@@ -472,15 +445,15 @@ func (storage *SimpleRESTStorage) Update(ctx api.Context, obj runtime.Object) (r
}
// Implement ResourceWatcher.
func
(
storage
*
SimpleRESTStorage
)
Watch
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
storage
*
SimpleRESTStorage
)
Watch
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
storage
.
checkContext
(
ctx
)
storage
.
requestedLabelSelector
=
labels
.
Everything
()
if
options
!=
nil
&&
options
.
LabelSelector
!=
nil
{
storage
.
requestedLabelSelector
=
options
.
LabelSelector
if
options
!=
nil
&&
options
.
LabelSelector
.
Selector
!=
nil
{
storage
.
requestedLabelSelector
=
options
.
LabelSelector
.
Selector
}
storage
.
requestedFieldSelector
=
fields
.
Everything
()
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
{
storage
.
requestedFieldSelector
=
options
.
FieldSelector
if
options
!=
nil
&&
options
.
FieldSelector
.
Selector
!=
nil
{
storage
.
requestedFieldSelector
=
options
.
FieldSelector
.
Selector
}
storage
.
requestedResourceVersion
=
""
if
options
!=
nil
{
...
...
@@ -931,7 +904,7 @@ func TestList(t *testing.T) {
legacy
:
true
,
},
{
url
:
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple?namespace=other&label
s=a%3Db&fields
=c%3Dd"
,
url
:
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple?namespace=other&label
Selector=a%3Db&fieldSelector
=c%3Dd"
,
namespace
:
""
,
selfLink
:
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple"
,
legacy
:
true
,
...
...
@@ -952,7 +925,7 @@ func TestList(t *testing.T) {
legacy
:
true
,
},
{
url
:
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/namespaces/other/simple?label
s=a%3Db&fields
=c%3Dd"
,
url
:
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/namespaces/other/simple?label
Selector=a%3Db&fieldSelector
=c%3Dd"
,
namespace
:
"other"
,
selfLink
:
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/namespaces/other/simple"
,
legacy
:
true
,
...
...
pkg/apiserver/resthandler.go
View file @
bf13bef9
...
...
@@ -240,31 +240,24 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
ctx
:=
scope
.
ContextFunc
(
req
)
ctx
=
api
.
WithNamespace
(
ctx
,
namespace
)
versioned
,
err
:=
scope
.
Creater
.
New
(
scope
.
ServerAPIVersion
,
"ListOptions"
)
if
err
!=
nil
{
errorJSON
(
err
,
scope
.
Codec
,
w
)
return
}
if
err
:=
scope
.
Codec
.
DecodeParametersInto
(
req
.
Request
.
URL
.
Query
(),
versioned
);
err
!=
nil
{
errorJSON
(
err
,
scope
.
Codec
,
w
)
return
}
opts
:=
api
.
ListOptions
{}
if
err
:=
scope
.
Convertor
.
Convert
(
versioned
,
&
opts
);
err
!=
nil
{
opts
:=
unversioned
.
ListOptions
{}
if
err
:=
scope
.
Codec
.
DecodeParametersInto
(
req
.
Request
.
URL
.
Query
(),
&
opts
);
err
!=
nil
{
errorJSON
(
err
,
scope
.
Codec
,
w
)
return
}
// transform fields
// TODO: Should this be done as part of convertion?
fn
:=
func
(
label
,
value
string
)
(
newLabel
,
newValue
string
,
err
error
)
{
return
scope
.
Convertor
.
ConvertFieldLabel
(
scope
.
APIVersion
,
scope
.
Kind
,
label
,
value
)
}
if
opts
.
FieldSelector
,
err
=
opts
.
FieldSelector
.
Transform
(
fn
);
err
!=
nil
{
// TODO: allow bad request to set field causes based on query parameters
err
=
errors
.
NewBadRequest
(
err
.
Error
())
errorJSON
(
err
,
scope
.
Codec
,
w
)
return
// TODO: DecodeParametersInto should do this.
if
opts
.
FieldSelector
.
Selector
!=
nil
{
fn
:=
func
(
label
,
value
string
)
(
newLabel
,
newValue
string
,
err
error
)
{
return
scope
.
Convertor
.
ConvertFieldLabel
(
scope
.
APIVersion
,
scope
.
Kind
,
label
,
value
)
}
if
opts
.
FieldSelector
.
Selector
,
err
=
opts
.
FieldSelector
.
Selector
.
Transform
(
fn
);
err
!=
nil
{
// TODO: allow bad request to set field causes based on query parameters
err
=
errors
.
NewBadRequest
(
err
.
Error
())
errorJSON
(
err
,
scope
.
Codec
,
w
)
return
}
}
if
hasName
{
...
...
@@ -273,7 +266,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
// a request for a single object and optimize the
// storage query accordingly.
nameSelector
:=
fields
.
OneTermEqualSelector
(
"metadata.name"
,
name
)
if
opts
.
FieldSelector
!=
nil
&&
!
opts
.
Field
Selector
.
Empty
()
{
if
opts
.
FieldSelector
.
Selector
!=
nil
&&
!
opts
.
FieldSelector
.
Selector
.
Empty
()
{
// It doesn't make sense to ask for both a name
// and a field selector, since just the name is
// sufficient to narrow down the request to a
...
...
@@ -285,7 +278,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
)
return
}
opts
.
FieldSelector
=
nameSelector
opts
.
FieldSelector
.
Selector
=
nameSelector
}
if
(
opts
.
Watch
||
forceWatch
)
&&
rw
!=
nil
{
...
...
pkg/apiserver/watch_test.go
View file @
bf13bef9
...
...
@@ -198,14 +198,14 @@ func TestWatchParamParsing(t *testing.T) {
namespace
:
api
.
NamespaceAll
,
},
{
path
:
rootPath
,
rawQuery
:
"resourceVersion=314159&field
s=Host%3D&labels
=name%3Dfoo"
,
rawQuery
:
"resourceVersion=314159&field
Selector=Host%3D&labelSelector
=name%3Dfoo"
,
resourceVersion
:
"314159"
,
labelSelector
:
"name=foo"
,
fieldSelector
:
"Host="
,
namespace
:
api
.
NamespaceAll
,
},
{
path
:
rootPath
,
rawQuery
:
"field
s
=id%3dfoo&resourceVersion=1492"
,
rawQuery
:
"field
Selector
=id%3dfoo&resourceVersion=1492"
,
resourceVersion
:
"1492"
,
labelSelector
:
""
,
fieldSelector
:
"id=foo"
,
...
...
@@ -227,14 +227,14 @@ func TestWatchParamParsing(t *testing.T) {
namespace
:
"other"
,
},
{
path
:
namespacedPath
,
rawQuery
:
"resourceVersion=314159&field
s=Host%3D&labels
=name%3Dfoo"
,
rawQuery
:
"resourceVersion=314159&field
Selector=Host%3D&labelSelector
=name%3Dfoo"
,
resourceVersion
:
"314159"
,
labelSelector
:
"name=foo"
,
fieldSelector
:
"Host="
,
namespace
:
"other"
,
},
{
path
:
namespacedPath
,
rawQuery
:
"field
s
=id%3dfoo&resourceVersion=1492"
,
rawQuery
:
"field
Selector
=id%3dfoo&resourceVersion=1492"
,
resourceVersion
:
"1492"
,
labelSelector
:
""
,
fieldSelector
:
"id=foo"
,
...
...
pkg/registry/componentstatus/rest.go
View file @
bf13bef9
...
...
@@ -21,6 +21,7 @@ import (
"net/http"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/runtime"
...
...
@@ -49,7 +50,7 @@ func (rs *REST) NewList() runtime.Object {
// 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.
func
(
rs
*
REST
)
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
rs
*
REST
)
List
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
servers
:=
rs
.
GetServersToValidate
()
// TODO: This should be parallelized.
...
...
pkg/registry/controller/registry.go
View file @
bf13bef9
...
...
@@ -21,13 +21,14 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store ReplicationControllers.
type
Registry
interface
{
ListControllers
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ReplicationControllerList
,
error
)
WatchControllers
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
ListControllers
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
ReplicationControllerList
,
error
)
WatchControllers
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
GetController
(
ctx
api
.
Context
,
controllerID
string
)
(
*
api
.
ReplicationController
,
error
)
CreateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
UpdateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
...
...
@@ -45,8 +46,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListControllers
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ReplicationControllerList
,
error
)
{
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
&&
!
options
.
Field
Selector
.
Empty
()
{
func
(
s
*
storage
)
ListControllers
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
ReplicationControllerList
,
error
)
{
if
options
!=
nil
&&
options
.
FieldSelector
.
Selector
!=
nil
&&
!
options
.
FieldSelector
.
Selector
.
Empty
()
{
return
nil
,
fmt
.
Errorf
(
"field selector not supported yet"
)
}
obj
,
err
:=
s
.
List
(
ctx
,
options
)
...
...
@@ -56,7 +57,7 @@ func (s *storage) ListControllers(ctx api.Context, options *api.ListOptions) (*a
return
obj
.
(
*
api
.
ReplicationControllerList
),
err
}
func
(
s
*
storage
)
WatchControllers
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchControllers
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
options
)
}
...
...
pkg/registry/deployment/registry.go
View file @
bf13bef9
...
...
@@ -21,12 +21,13 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
)
// Registry is an interface for things that know how to store Deployments.
type
Registry
interface
{
ListDeployments
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
extensions
.
DeploymentList
,
error
)
ListDeployments
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
extensions
.
DeploymentList
,
error
)
GetDeployment
(
ctx
api
.
Context
,
deploymentID
string
)
(
*
extensions
.
Deployment
,
error
)
CreateDeployment
(
ctx
api
.
Context
,
deployment
*
extensions
.
Deployment
)
(
*
extensions
.
Deployment
,
error
)
UpdateDeployment
(
ctx
api
.
Context
,
deployment
*
extensions
.
Deployment
)
(
*
extensions
.
Deployment
,
error
)
...
...
@@ -43,8 +44,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListDeployments
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
extensions
.
DeploymentList
,
error
)
{
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
&&
!
options
.
Field
Selector
.
Empty
()
{
func
(
s
*
storage
)
ListDeployments
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
extensions
.
DeploymentList
,
error
)
{
if
options
!=
nil
&&
options
.
FieldSelector
.
Selector
!=
nil
&&
!
options
.
FieldSelector
.
Selector
.
Empty
()
{
return
nil
,
fmt
.
Errorf
(
"field selector not supported yet"
)
}
obj
,
err
:=
s
.
List
(
ctx
,
options
)
...
...
pkg/registry/endpoint/registry.go
View file @
bf13bef9
...
...
@@ -19,14 +19,15 @@ package endpoint
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store endpoints.
type
Registry
interface
{
ListEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
ListEndpoints
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
GetEndpoints
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Endpoints
,
error
)
WatchEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
WatchEndpoints
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
UpdateEndpoints
(
ctx
api
.
Context
,
e
*
api
.
Endpoints
)
error
DeleteEndpoints
(
ctx
api
.
Context
,
name
string
)
error
}
...
...
@@ -42,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
{
func
(
s
*
storage
)
ListEndpoints
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -50,7 +51,7 @@ func (s *storage) ListEndpoints(ctx api.Context, options *api.ListOptions) (*api
return
obj
.
(
*
api
.
EndpointsList
),
nil
}
func
(
s
*
storage
)
WatchEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchEndpoints
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
options
)
}
...
...
pkg/registry/generic/etcd/etcd.go
View file @
bf13bef9
...
...
@@ -161,20 +161,20 @@ func (e *Etcd) NewList() runtime.Object {
}
// List returns a list of items matching labels and field
func
(
e
*
Etcd
)
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
e
*
Etcd
)
List
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
label
:=
labels
.
Everything
()
if
options
!=
nil
&&
options
.
LabelSelector
!=
nil
{
label
=
options
.
LabelSelector
if
options
!=
nil
&&
options
.
LabelSelector
.
Selector
!=
nil
{
label
=
options
.
LabelSelector
.
Selector
}
field
:=
fields
.
Everything
()
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
{
field
=
options
.
FieldSelector
if
options
!=
nil
&&
options
.
FieldSelector
.
Selector
!=
nil
{
field
=
options
.
FieldSelector
.
Selector
}
return
e
.
ListPredicate
(
ctx
,
e
.
PredicateFunc
(
label
,
field
),
options
)
}
// ListPredicate returns a list of all the items matching m.
func
(
e
*
Etcd
)
ListPredicate
(
ctx
api
.
Context
,
m
generic
.
Matcher
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
e
*
Etcd
)
ListPredicate
(
ctx
api
.
Context
,
m
generic
.
Matcher
,
options
*
unversioned
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
list
:=
e
.
NewListFunc
()
trace
:=
util
.
NewTrace
(
"List "
+
reflect
.
TypeOf
(
list
)
.
String
())
filterFunc
:=
e
.
filterAndDecorateFunction
(
m
)
...
...
@@ -191,7 +191,7 @@ func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher, options *api.Li
trace
.
Step
(
"About to list directory"
)
if
options
==
nil
{
options
=
&
api
.
ListOptions
{
ResourceVersion
:
"0"
}
options
=
&
unversioned
.
ListOptions
{
ResourceVersion
:
"0"
}
}
version
,
err
:=
storage
.
ParseWatchResourceVersion
(
options
.
ResourceVersion
,
e
.
EndpointName
)
if
err
!=
nil
{
...
...
@@ -467,14 +467,14 @@ func (e *Etcd) finalizeDelete(obj runtime.Object, runHooks bool) (runtime.Object
// WatchPredicate. If possible, you should customize PredicateFunc to produre a
// matcher that matches by key. generic.SelectionPredicate does this for you
// automatically.
func
(
e
*
Etcd
)
Watch
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
e
*
Etcd
)
Watch
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
label
:=
labels
.
Everything
()
if
options
!=
nil
&&
options
.
LabelSelector
!=
nil
{
label
=
options
.
LabelSelector
if
options
!=
nil
&&
options
.
LabelSelector
.
Selector
!=
nil
{
label
=
options
.
LabelSelector
.
Selector
}
field
:=
fields
.
Everything
()
if
options
!=
nil
&&
options
.
FieldSelector
!=
nil
{
field
=
options
.
FieldSelector
if
options
!=
nil
&&
options
.
FieldSelector
.
Selector
!=
nil
{
field
=
options
.
FieldSelector
.
Selector
}
resourceVersion
:=
""
if
options
!=
nil
{
...
...
pkg/registry/namespace/registry.go
View file @
bf13bef9
...
...
@@ -19,13 +19,14 @@ package namespace
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface implemented by things that know how to store Namespace objects.
type
Registry
interface
{
ListNamespaces
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NamespaceList
,
error
)
WatchNamespaces
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
ListNamespaces
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
NamespaceList
,
error
)
WatchNamespaces
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
GetNamespace
(
ctx
api
.
Context
,
namespaceID
string
)
(
*
api
.
Namespace
,
error
)
CreateNamespace
(
ctx
api
.
Context
,
namespace
*
api
.
Namespace
)
error
UpdateNamespace
(
ctx
api
.
Context
,
namespace
*
api
.
Namespace
)
error
...
...
@@ -43,7 +44,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListNamespaces
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NamespaceList
,
error
)
{
func
(
s
*
storage
)
ListNamespaces
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
NamespaceList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -51,7 +52,7 @@ func (s *storage) ListNamespaces(ctx api.Context, options *api.ListOptions) (*ap
return
obj
.
(
*
api
.
NamespaceList
),
nil
}
func
(
s
*
storage
)
WatchNamespaces
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchNamespaces
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
options
)
}
...
...
pkg/registry/node/registry.go
View file @
bf13bef9
...
...
@@ -19,17 +19,18 @@ package node
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store node.
type
Registry
interface
{
ListNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
ListNodes
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
CreateNode
(
ctx
api
.
Context
,
node
*
api
.
Node
)
error
UpdateNode
(
ctx
api
.
Context
,
node
*
api
.
Node
)
error
GetNode
(
ctx
api
.
Context
,
nodeID
string
)
(
*
api
.
Node
,
error
)
DeleteNode
(
ctx
api
.
Context
,
nodeID
string
)
error
WatchNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
WatchNodes
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
}
// storage puts strong typing around storage calls
...
...
@@ -43,7 +44,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
{
func
(
s
*
storage
)
ListNodes
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -62,7 +63,7 @@ func (s *storage) UpdateNode(ctx api.Context, node *api.Node) error {
return
err
}
func
(
s
*
storage
)
WatchNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchNodes
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
options
)
}
...
...
pkg/registry/registrytest/endpoint.go
View file @
bf13bef9
...
...
@@ -22,6 +22,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
...
...
@@ -34,7 +35,7 @@ type EndpointRegistry struct {
lock
sync
.
Mutex
}
func
(
e
*
EndpointRegistry
)
ListEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
{
func
(
e
*
EndpointRegistry
)
ListEndpoints
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
EndpointsList
,
error
)
{
// TODO: support namespaces in this mock
e
.
lock
.
Lock
()
defer
e
.
lock
.
Unlock
()
...
...
@@ -59,7 +60,7 @@ func (e *EndpointRegistry) GetEndpoints(ctx api.Context, name string) (*api.Endp
return
nil
,
errors
.
NewNotFound
(
"Endpoints"
,
name
)
}
func
(
e
*
EndpointRegistry
)
WatchEndpoints
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
e
*
EndpointRegistry
)
WatchEndpoints
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
nil
,
fmt
.
Errorf
(
"unimplemented!"
)
}
...
...
pkg/registry/registrytest/node.go
View file @
bf13bef9
...
...
@@ -21,6 +21,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
...
...
@@ -57,7 +58,7 @@ func (r *NodeRegistry) SetError(err error) {
r
.
Err
=
err
}
func
(
r
*
NodeRegistry
)
ListNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
{
func
(
r
*
NodeRegistry
)
ListNodes
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
{
r
.
Lock
()
defer
r
.
Unlock
()
return
&
r
.
Nodes
,
r
.
Err
...
...
@@ -110,6 +111,6 @@ func (r *NodeRegistry) DeleteNode(ctx api.Context, nodeID string) error {
return
r
.
Err
}
func
(
r
*
NodeRegistry
)
WatchNodes
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
r
*
NodeRegistry
)
WatchNodes
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
nil
,
r
.
Err
}
pkg/registry/registrytest/service.go
View file @
bf13bef9
...
...
@@ -20,6 +20,7 @@ import (
"sync"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
...
...
@@ -45,7 +46,7 @@ func (r *ServiceRegistry) SetError(err error) {
r
.
Err
=
err
}
func
(
r
*
ServiceRegistry
)
ListServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
{
func
(
r
*
ServiceRegistry
)
ListServices
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
{
r
.
mu
.
Lock
()
defer
r
.
mu
.
Unlock
()
...
...
@@ -106,7 +107,7 @@ func (r *ServiceRegistry) UpdateService(ctx api.Context, svc *api.Service) (*api
return
svc
,
r
.
Err
}
func
(
r
*
ServiceRegistry
)
WatchServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
r
*
ServiceRegistry
)
WatchServices
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
r
.
mu
.
Lock
()
defer
r
.
mu
.
Unlock
()
...
...
pkg/registry/secret/registry.go
View file @
bf13bef9
...
...
@@ -19,13 +19,14 @@ package secret
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface implemented by things that know how to store Secret objects.
type
Registry
interface
{
ListSecrets
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
SecretList
,
error
)
WatchSecrets
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
ListSecrets
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
SecretList
,
error
)
WatchSecrets
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
GetSecret
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Secret
,
error
)
CreateSecret
(
ctx
api
.
Context
,
Secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
UpdateSecret
(
ctx
api
.
Context
,
Secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
...
...
@@ -43,7 +44,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListSecrets
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
SecretList
,
error
)
{
func
(
s
*
storage
)
ListSecrets
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
SecretList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -51,7 +52,7 @@ func (s *storage) ListSecrets(ctx api.Context, options *api.ListOptions) (*api.S
return
obj
.
(
*
api
.
SecretList
),
nil
}
func
(
s
*
storage
)
WatchSecrets
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchSecrets
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
options
)
}
...
...
pkg/registry/service/ipallocator/controller/repair.go
View file @
bf13bef9
...
...
@@ -22,6 +22,7 @@ import (
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service/ipallocator"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -92,7 +93,7 @@ func (c *Repair) RunOnce() error {
}
ctx
:=
api
.
WithNamespace
(
api
.
NewDefaultContext
(),
api
.
NamespaceAll
)
options
:=
&
api
.
ListOptions
{
ResourceVersion
:
latest
.
ObjectMeta
.
ResourceVersion
}
options
:=
&
unversioned
.
ListOptions
{
ResourceVersion
:
latest
.
ObjectMeta
.
ResourceVersion
}
list
,
err
:=
c
.
registry
.
ListServices
(
ctx
,
options
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to refresh the service IP block: %v"
,
err
)
...
...
pkg/registry/service/portallocator/controller/repair.go
View file @
bf13bef9
...
...
@@ -21,6 +21,7 @@ import (
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service/portallocator"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -79,7 +80,7 @@ func (c *Repair) RunOnce() error {
}
ctx
:=
api
.
WithNamespace
(
api
.
NewDefaultContext
(),
api
.
NamespaceAll
)
options
:=
&
api
.
ListOptions
{
ResourceVersion
:
latest
.
ObjectMeta
.
ResourceVersion
}
options
:=
&
unversioned
.
ListOptions
{
ResourceVersion
:
latest
.
ObjectMeta
.
ResourceVersion
}
list
,
err
:=
c
.
registry
.
ListServices
(
ctx
,
options
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to refresh the port block: %v"
,
err
)
...
...
pkg/registry/service/registry.go
View file @
bf13bef9
...
...
@@ -19,17 +19,18 @@ package service
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface for things that know how to store services.
type
Registry
interface
{
ListServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
ListServices
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
CreateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
GetService
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Service
,
error
)
DeleteService
(
ctx
api
.
Context
,
name
string
)
error
UpdateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
WatchServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
WatchServices
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
}
// storage puts strong typing around storage calls
...
...
@@ -43,7 +44,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
{
func
(
s
*
storage
)
ListServices
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
ServiceList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -80,7 +81,7 @@ func (s *storage) UpdateService(ctx api.Context, svc *api.Service) (*api.Service
return
obj
.
(
*
api
.
Service
),
nil
}
func
(
s
*
storage
)
WatchServices
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchServices
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
options
)
}
...
...
pkg/registry/service/rest.go
View file @
bf13bef9
...
...
@@ -172,13 +172,13 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
return
rs
.
registry
.
GetService
(
ctx
,
id
)
}
func
(
rs
*
REST
)
List
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
func
(
rs
*
REST
)
List
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
return
rs
.
registry
.
ListServices
(
ctx
,
options
)
}
// Watch returns Services events via a watch.Interface.
// It implements rest.Watcher.
func
(
rs
*
REST
)
Watch
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
rs
*
REST
)
Watch
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
rs
.
registry
.
WatchServices
(
ctx
,
options
)
}
...
...
pkg/registry/serviceaccount/registry.go
View file @
bf13bef9
...
...
@@ -19,13 +19,14 @@ package serviceaccount
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface implemented by things that know how to store ServiceAccount objects.
type
Registry
interface
{
ListServiceAccounts
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceAccountList
,
error
)
WatchServiceAccounts
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
ListServiceAccounts
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
ServiceAccountList
,
error
)
WatchServiceAccounts
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
GetServiceAccount
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
ServiceAccount
,
error
)
CreateServiceAccount
(
ctx
api
.
Context
,
ServiceAccount
*
api
.
ServiceAccount
)
error
UpdateServiceAccount
(
ctx
api
.
Context
,
ServiceAccount
*
api
.
ServiceAccount
)
error
...
...
@@ -43,7 +44,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListServiceAccounts
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
api
.
ServiceAccountList
,
error
)
{
func
(
s
*
storage
)
ListServiceAccounts
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
api
.
ServiceAccountList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -51,7 +52,7 @@ func (s *storage) ListServiceAccounts(ctx api.Context, options *api.ListOptions)
return
obj
.
(
*
api
.
ServiceAccountList
),
nil
}
func
(
s
*
storage
)
WatchServiceAccounts
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchServiceAccounts
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
options
)
}
...
...
pkg/registry/thirdpartyresourcedata/registry.go
View file @
bf13bef9
...
...
@@ -19,14 +19,15 @@ package thirdpartyresourcedata
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/watch"
)
// Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects.
type
Registry
interface
{
ListThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
extensions
.
ThirdPartyResourceDataList
,
error
)
WatchThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
ListThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
extensions
.
ThirdPartyResourceDataList
,
error
)
WatchThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
GetThirdPartyResourceData
(
ctx
api
.
Context
,
name
string
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
CreateThirdPartyResourceData
(
ctx
api
.
Context
,
resource
*
extensions
.
ThirdPartyResourceData
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
UpdateThirdPartyResourceData
(
ctx
api
.
Context
,
resource
*
extensions
.
ThirdPartyResourceData
)
(
*
extensions
.
ThirdPartyResourceData
,
error
)
...
...
@@ -44,7 +45,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return
&
storage
{
s
}
}
func
(
s
*
storage
)
ListThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
*
extensions
.
ThirdPartyResourceDataList
,
error
)
{
func
(
s
*
storage
)
ListThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
*
extensions
.
ThirdPartyResourceDataList
,
error
)
{
obj
,
err
:=
s
.
List
(
ctx
,
options
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -52,7 +53,7 @@ func (s *storage) ListThirdPartyResourceData(ctx api.Context, options *api.ListO
return
obj
.
(
*
extensions
.
ThirdPartyResourceDataList
),
nil
}
func
(
s
*
storage
)
WatchThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
s
*
storage
)
WatchThirdPartyResourceData
(
ctx
api
.
Context
,
options
*
unversioned
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
s
.
Watch
(
ctx
,
options
)
}
...
...
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