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
501c76ce
Commit
501c76ce
authored
Oct 16, 2015
by
feihujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support namespace selector in all namespaces endpoint
parent
e3642f1b
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
55 additions
and
38 deletions
+55
-38
strategy.go
pkg/registry/controller/strategy.go
+4
-3
strategy.go
pkg/registry/daemonset/strategy.go
+1
-3
strategy.go
pkg/registry/deployment/strategy.go
+1
-3
strategy.go
pkg/registry/endpoint/strategy.go
+1
-3
strategy.go
pkg/registry/event/strategy.go
+5
-3
strategy_test.go
pkg/registry/event/strategy_test.go
+5
-1
matcher.go
pkg/registry/generic/matcher.go
+17
-0
strategy.go
pkg/registry/ingress/strategy.go
+2
-4
strategy.go
pkg/registry/job/strategy.go
+3
-2
strategy.go
pkg/registry/namespace/strategy.go
+4
-3
strategy.go
pkg/registry/persistentvolume/strategy.go
+3
-2
strategy.go
pkg/registry/persistentvolumeclaim/strategy.go
+3
-2
strategy.go
pkg/registry/pod/strategy.go
+4
-3
strategy.go
pkg/registry/resourcequota/strategy.go
+1
-3
strategy.go
pkg/registry/serviceaccount/strategy.go
+1
-3
No files found.
pkg/registry/controller/strategy.go
View file @
501c76ce
...
@@ -98,12 +98,13 @@ func (rcStrategy) AllowUnconditionalUpdate() bool {
...
@@ -98,12 +98,13 @@ func (rcStrategy) AllowUnconditionalUpdate() bool {
return
true
return
true
}
}
// ControllerToSelectableFields returns a
label
set that represents the object.
// ControllerToSelectableFields returns a
field
set that represents the object.
func
ControllerToSelectableFields
(
controller
*
api
.
ReplicationController
)
fields
.
Set
{
func
ControllerToSelectableFields
(
controller
*
api
.
ReplicationController
)
fields
.
Set
{
return
fields
.
Set
{
objectMetaFieldsSet
:=
generic
.
ObjectMetaFieldsSet
(
controller
.
ObjectMeta
)
"metadata.name"
:
controller
.
Name
,
controllerSpecificFieldsSet
:=
fields
.
Set
{
"status.replicas"
:
strconv
.
Itoa
(
controller
.
Status
.
Replicas
),
"status.replicas"
:
strconv
.
Itoa
(
controller
.
Status
.
Replicas
),
}
}
return
generic
.
MergeFieldsSets
(
objectMetaFieldsSet
,
controllerSpecificFieldsSet
)
}
}
// MatchController is the filter used by the generic etcd backend to route
// MatchController is the filter used by the generic etcd backend to route
...
...
pkg/registry/daemonset/strategy.go
View file @
501c76ce
...
@@ -102,9 +102,7 @@ func (daemonSetStrategy) AllowUnconditionalUpdate() bool {
...
@@ -102,9 +102,7 @@ func (daemonSetStrategy) AllowUnconditionalUpdate() bool {
// DaemonSetToSelectableFields returns a field set that represents the object.
// DaemonSetToSelectableFields returns a field set that represents the object.
func
DaemonSetToSelectableFields
(
daemon
*
extensions
.
DaemonSet
)
fields
.
Set
{
func
DaemonSetToSelectableFields
(
daemon
*
extensions
.
DaemonSet
)
fields
.
Set
{
return
fields
.
Set
{
return
generic
.
ObjectMetaFieldsSet
(
daemon
.
ObjectMeta
)
"metadata.name"
:
daemon
.
Name
,
}
}
}
// MatchSetDaemon is the filter used by the generic etcd backend to route
// MatchSetDaemon is the filter used by the generic etcd backend to route
...
...
pkg/registry/deployment/strategy.go
View file @
501c76ce
...
@@ -74,9 +74,7 @@ func (deploymentStrategy) AllowUnconditionalUpdate() bool {
...
@@ -74,9 +74,7 @@ func (deploymentStrategy) AllowUnconditionalUpdate() bool {
// DeploymentToSelectableFields returns a field set that represents the object.
// DeploymentToSelectableFields returns a field set that represents the object.
func
DeploymentToSelectableFields
(
deployment
*
extensions
.
Deployment
)
fields
.
Set
{
func
DeploymentToSelectableFields
(
deployment
*
extensions
.
Deployment
)
fields
.
Set
{
return
fields
.
Set
{
return
generic
.
ObjectMetaFieldsSet
(
deployment
.
ObjectMeta
)
"metadata.name"
:
deployment
.
Name
,
}
}
}
// MatchDeployment is the filter used by the generic etcd backend to route
// MatchDeployment is the filter used by the generic etcd backend to route
...
...
pkg/registry/endpoint/strategy.go
View file @
501c76ce
...
@@ -89,7 +89,5 @@ func EndpointsAttributes(obj runtime.Object) (objLabels labels.Set, objFields fi
...
@@ -89,7 +89,5 @@ func EndpointsAttributes(obj runtime.Object) (objLabels labels.Set, objFields fi
if
!
ok
{
if
!
ok
{
return
nil
,
nil
,
fmt
.
Errorf
(
"invalid object type %#v"
,
obj
)
return
nil
,
nil
,
fmt
.
Errorf
(
"invalid object type %#v"
,
obj
)
}
}
return
endpoints
.
Labels
,
fields
.
Set
{
return
endpoints
.
Labels
,
generic
.
ObjectMetaFieldsSet
(
endpoints
.
ObjectMeta
),
nil
"metadata.name"
:
endpoints
.
Name
,
},
nil
}
}
pkg/registry/event/strategy.go
View file @
501c76ce
...
@@ -79,8 +79,9 @@ func getAttrs(obj runtime.Object) (objLabels labels.Set, objFields fields.Set, e
...
@@ -79,8 +79,9 @@ func getAttrs(obj runtime.Object) (objLabels labels.Set, objFields fields.Set, e
if
l
==
nil
{
if
l
==
nil
{
l
=
labels
.
Set
{}
l
=
labels
.
Set
{}
}
}
return
l
,
fields
.
Set
{
"metadata.name"
:
event
.
Name
,
objectMetaFieldsSet
:=
generic
.
ObjectMetaFieldsSet
(
event
.
ObjectMeta
)
specificFieldsSet
:=
fields
.
Set
{
"involvedObject.kind"
:
event
.
InvolvedObject
.
Kind
,
"involvedObject.kind"
:
event
.
InvolvedObject
.
Kind
,
"involvedObject.namespace"
:
event
.
InvolvedObject
.
Namespace
,
"involvedObject.namespace"
:
event
.
InvolvedObject
.
Namespace
,
"involvedObject.name"
:
event
.
InvolvedObject
.
Name
,
"involvedObject.name"
:
event
.
InvolvedObject
.
Name
,
...
@@ -90,5 +91,6 @@ func getAttrs(obj runtime.Object) (objLabels labels.Set, objFields fields.Set, e
...
@@ -90,5 +91,6 @@ func getAttrs(obj runtime.Object) (objLabels labels.Set, objFields fields.Set, e
"involvedObject.fieldPath"
:
event
.
InvolvedObject
.
FieldPath
,
"involvedObject.fieldPath"
:
event
.
InvolvedObject
.
FieldPath
,
"reason"
:
event
.
Reason
,
"reason"
:
event
.
Reason
,
"source"
:
event
.
Source
.
Component
,
"source"
:
event
.
Source
.
Component
,
},
nil
}
return
l
,
generic
.
MergeFieldsSets
(
objectMetaFieldsSet
,
specificFieldsSet
),
nil
}
}
pkg/registry/event/strategy_test.go
View file @
501c76ce
...
@@ -42,7 +42,10 @@ func testEvent(name string) *api.Event {
...
@@ -42,7 +42,10 @@ func testEvent(name string) *api.Event {
func
TestGetAttrs
(
t
*
testing
.
T
)
{
func
TestGetAttrs
(
t
*
testing
.
T
)
{
eventA
:=
&
api
.
Event
{
eventA
:=
&
api
.
Event
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"f0118"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"f0118"
,
Namespace
:
"default"
,
},
InvolvedObject
:
api
.
ObjectReference
{
InvolvedObject
:
api
.
ObjectReference
{
Kind
:
"Pod"
,
Kind
:
"Pod"
,
Name
:
"foo"
,
Name
:
"foo"
,
...
@@ -64,6 +67,7 @@ func TestGetAttrs(t *testing.T) {
...
@@ -64,6 +67,7 @@ func TestGetAttrs(t *testing.T) {
}
}
expect
:=
fields
.
Set
{
expect
:=
fields
.
Set
{
"metadata.name"
:
"f0118"
,
"metadata.name"
:
"f0118"
,
"metadata.namespace"
:
"default"
,
"involvedObject.kind"
:
"Pod"
,
"involvedObject.kind"
:
"Pod"
,
"involvedObject.name"
:
"foo"
,
"involvedObject.name"
:
"foo"
,
"involvedObject.namespace"
:
"baz"
,
"involvedObject.namespace"
:
"baz"
,
...
...
pkg/registry/generic/matcher.go
View file @
501c76ce
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
generic
package
generic
import
(
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
...
@@ -25,6 +26,22 @@ import (
...
@@ -25,6 +26,22 @@ import (
// AttrFunc returns label and field sets for List or Watch to compare against, or an error.
// AttrFunc returns label and field sets for List or Watch to compare against, or an error.
type
AttrFunc
func
(
obj
runtime
.
Object
)
(
label
labels
.
Set
,
field
fields
.
Set
,
err
error
)
type
AttrFunc
func
(
obj
runtime
.
Object
)
(
label
labels
.
Set
,
field
fields
.
Set
,
err
error
)
// ObjectMetaFieldsSet returns a fields set that represents the ObjectMeta.
func
ObjectMetaFieldsSet
(
objectMeta
api
.
ObjectMeta
)
fields
.
Set
{
return
fields
.
Set
{
"metadata.name"
:
objectMeta
.
Name
,
"metadata.namespace"
:
objectMeta
.
Namespace
,
}
}
// MergeFieldsSets merges a fields'set from fragment into the source.
func
MergeFieldsSets
(
source
fields
.
Set
,
fragment
fields
.
Set
)
fields
.
Set
{
for
k
,
value
:=
range
fragment
{
source
[
k
]
=
value
}
return
source
}
// SelectionPredicate implements a generic predicate that can be passed to
// SelectionPredicate implements a generic predicate that can be passed to
// GenericRegistry's List or Watch methods. Implements the Matcher interface.
// GenericRegistry's List or Watch methods. Implements the Matcher interface.
type
SelectionPredicate
struct
{
type
SelectionPredicate
struct
{
...
...
pkg/registry/ingress/strategy.go
View file @
501c76ce
...
@@ -93,11 +93,9 @@ func (ingressStrategy) AllowUnconditionalUpdate() bool {
...
@@ -93,11 +93,9 @@ func (ingressStrategy) AllowUnconditionalUpdate() bool {
return
true
return
true
}
}
// IngressToSelectableFields returns a
label
set that represents the object.
// IngressToSelectableFields returns a
field
set that represents the object.
func
IngressToSelectableFields
(
ingress
*
extensions
.
Ingress
)
fields
.
Set
{
func
IngressToSelectableFields
(
ingress
*
extensions
.
Ingress
)
fields
.
Set
{
return
fields
.
Set
{
return
generic
.
ObjectMetaFieldsSet
(
ingress
.
ObjectMeta
)
"metadata.name"
:
ingress
.
Name
,
}
}
}
// MatchIngress is the filter used by the generic etcd backend to ingress
// MatchIngress is the filter used by the generic etcd backend to ingress
...
...
pkg/registry/job/strategy.go
View file @
501c76ce
...
@@ -97,10 +97,11 @@ func (jobStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object
...
@@ -97,10 +97,11 @@ func (jobStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object
// JobSelectableFields returns a field set that represents the object for matching purposes.
// JobSelectableFields returns a field set that represents the object for matching purposes.
func
JobToSelectableFields
(
job
*
extensions
.
Job
)
fields
.
Set
{
func
JobToSelectableFields
(
job
*
extensions
.
Job
)
fields
.
Set
{
return
fields
.
Set
{
objectMetaFieldsSet
:=
generic
.
ObjectMetaFieldsSet
(
job
.
ObjectMeta
)
"metadata.name"
:
job
.
Name
,
specificFieldsSet
:=
fields
.
Set
{
"status.successful"
:
strconv
.
Itoa
(
job
.
Status
.
Succeeded
),
"status.successful"
:
strconv
.
Itoa
(
job
.
Status
.
Succeeded
),
}
}
return
generic
.
MergeFieldsSets
(
objectMetaFieldsSet
,
specificFieldsSet
)
}
}
// MatchJob is the filter used by the generic etcd backend to route
// MatchJob is the filter used by the generic etcd backend to route
...
...
pkg/registry/namespace/strategy.go
View file @
501c76ce
...
@@ -144,10 +144,11 @@ func MatchNamespace(label labels.Selector, field fields.Selector) generic.Matche
...
@@ -144,10 +144,11 @@ func MatchNamespace(label labels.Selector, field fields.Selector) generic.Matche
// NamespaceToSelectableFields returns a label set that represents the object
// NamespaceToSelectableFields returns a label set that represents the object
func
NamespaceToSelectableFields
(
namespace
*
api
.
Namespace
)
labels
.
Set
{
func
NamespaceToSelectableFields
(
namespace
*
api
.
Namespace
)
labels
.
Set
{
return
labels
.
Set
{
objectMetaFieldsSet
:=
generic
.
ObjectMetaFieldsSet
(
namespace
.
ObjectMeta
)
"metadata.name"
:
namespace
.
Name
,
specificFieldsSet
:=
fields
.
Set
{
"status.phase"
:
string
(
namespace
.
Status
.
Phase
),
"status.phase"
:
string
(
namespace
.
Status
.
Phase
),
// This is a bug, but we need to support it for backward compatibility.
// This is a bug, but we need to support it for backward compatibility.
"name"
:
namespace
.
Name
,
"name"
:
namespace
.
Name
,
}
}
return
labels
.
Set
(
generic
.
MergeFieldsSets
(
objectMetaFieldsSet
,
specificFieldsSet
))
}
}
pkg/registry/persistentvolume/strategy.go
View file @
501c76ce
...
@@ -104,9 +104,10 @@ func MatchPersistentVolumes(label labels.Selector, field fields.Selector) generi
...
@@ -104,9 +104,10 @@ func MatchPersistentVolumes(label labels.Selector, field fields.Selector) generi
// PersistentVolumeToSelectableFields returns a label set that represents the object
// PersistentVolumeToSelectableFields returns a label set that represents the object
func
PersistentVolumeToSelectableFields
(
persistentvolume
*
api
.
PersistentVolume
)
labels
.
Set
{
func
PersistentVolumeToSelectableFields
(
persistentvolume
*
api
.
PersistentVolume
)
labels
.
Set
{
return
labels
.
Set
{
objectMetaFieldsSet
:=
generic
.
ObjectMetaFieldsSet
(
persistentvolume
.
ObjectMeta
)
"metadata.name"
:
persistentvolume
.
Name
,
specificFieldsSet
:=
fields
.
Set
{
// This is a bug, but we need to support it for backward compatibility.
// This is a bug, but we need to support it for backward compatibility.
"name"
:
persistentvolume
.
Name
,
"name"
:
persistentvolume
.
Name
,
}
}
return
labels
.
Set
(
generic
.
MergeFieldsSets
(
objectMetaFieldsSet
,
specificFieldsSet
))
}
}
pkg/registry/persistentvolumeclaim/strategy.go
View file @
501c76ce
...
@@ -104,9 +104,10 @@ func MatchPersistentVolumeClaim(label labels.Selector, field fields.Selector) ge
...
@@ -104,9 +104,10 @@ func MatchPersistentVolumeClaim(label labels.Selector, field fields.Selector) ge
// PersistentVolumeClaimToSelectableFields returns a label set that represents the object
// PersistentVolumeClaimToSelectableFields returns a label set that represents the object
func
PersistentVolumeClaimToSelectableFields
(
persistentvolumeclaim
*
api
.
PersistentVolumeClaim
)
labels
.
Set
{
func
PersistentVolumeClaimToSelectableFields
(
persistentvolumeclaim
*
api
.
PersistentVolumeClaim
)
labels
.
Set
{
return
labels
.
Set
{
objectMetaFieldsSet
:=
generic
.
ObjectMetaFieldsSet
(
persistentvolumeclaim
.
ObjectMeta
)
"metadata.name"
:
persistentvolumeclaim
.
Name
,
specificFieldsSet
:=
fields
.
Set
{
// This is a bug, but we need to support it for backward compatibility.
// This is a bug, but we need to support it for backward compatibility.
"name"
:
persistentvolumeclaim
.
Name
,
"name"
:
persistentvolumeclaim
.
Name
,
}
}
return
labels
.
Set
(
generic
.
MergeFieldsSets
(
objectMetaFieldsSet
,
specificFieldsSet
))
}
}
pkg/registry/pod/strategy.go
View file @
501c76ce
...
@@ -159,14 +159,15 @@ func MatchPod(label labels.Selector, field fields.Selector) generic.Matcher {
...
@@ -159,14 +159,15 @@ func MatchPod(label labels.Selector, field fields.Selector) generic.Matcher {
}
}
}
}
// PodToSelectableFields returns a
label
set that represents the object
// PodToSelectableFields returns a
field
set that represents the object
// TODO: fields are not labels, and the validation rules for them do not apply.
// TODO: fields are not labels, and the validation rules for them do not apply.
func
PodToSelectableFields
(
pod
*
api
.
Pod
)
fields
.
Set
{
func
PodToSelectableFields
(
pod
*
api
.
Pod
)
fields
.
Set
{
return
fields
.
Set
{
objectMetaFieldsSet
:=
generic
.
ObjectMetaFieldsSet
(
pod
.
ObjectMeta
)
"metadata.name"
:
pod
.
Name
,
podSpecificFieldsSet
:=
fields
.
Set
{
"spec.nodeName"
:
pod
.
Spec
.
NodeName
,
"spec.nodeName"
:
pod
.
Spec
.
NodeName
,
"status.phase"
:
string
(
pod
.
Status
.
Phase
),
"status.phase"
:
string
(
pod
.
Status
.
Phase
),
}
}
return
generic
.
MergeFieldsSets
(
objectMetaFieldsSet
,
podSpecificFieldsSet
)
}
}
// ResourceGetter is an interface for retrieving resources by ResourceLocation.
// ResourceGetter is an interface for retrieving resources by ResourceLocation.
...
...
pkg/registry/resourcequota/strategy.go
View file @
501c76ce
...
@@ -107,7 +107,5 @@ func MatchResourceQuota(label labels.Selector, field fields.Selector) generic.Ma
...
@@ -107,7 +107,5 @@ func MatchResourceQuota(label labels.Selector, field fields.Selector) generic.Ma
// ResourceQuotaToSelectableFields returns a label set that represents the object
// ResourceQuotaToSelectableFields returns a label set that represents the object
func
ResourceQuotaToSelectableFields
(
resourcequota
*
api
.
ResourceQuota
)
labels
.
Set
{
func
ResourceQuotaToSelectableFields
(
resourcequota
*
api
.
ResourceQuota
)
labels
.
Set
{
return
labels
.
Set
{
return
labels
.
Set
(
generic
.
ObjectMetaFieldsSet
(
resourcequota
.
ObjectMeta
))
"metadata.name"
:
resourcequota
.
Name
,
}
}
}
pkg/registry/serviceaccount/strategy.go
View file @
501c76ce
...
@@ -86,7 +86,5 @@ func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
...
@@ -86,7 +86,5 @@ func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
// SelectableFields returns a label set that represents the object
// SelectableFields returns a label set that represents the object
func
SelectableFields
(
obj
*
api
.
ServiceAccount
)
labels
.
Set
{
func
SelectableFields
(
obj
*
api
.
ServiceAccount
)
labels
.
Set
{
return
labels
.
Set
{
return
labels
.
Set
(
generic
.
ObjectMetaFieldsSet
(
obj
.
ObjectMeta
))
"metadata.name"
:
obj
.
Name
,
}
}
}
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