Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make rootscoped resources no namespace selectable field #16639

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/registry/controller/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (rcStrategy) AllowUnconditionalUpdate() bool {

// ControllerToSelectableFields returns a field set that represents the object.
func ControllerToSelectableFields(controller *api.ReplicationController) fields.Set {
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(controller.ObjectMeta)
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(controller.ObjectMeta, true)
controllerSpecificFieldsSet := fields.Set{
"status.replicas": strconv.Itoa(controller.Status.Replicas),
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/daemonset/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (daemonSetStrategy) AllowUnconditionalUpdate() bool {

// DaemonSetToSelectableFields returns a field set that represents the object.
func DaemonSetToSelectableFields(daemon *extensions.DaemonSet) fields.Set {
return generic.ObjectMetaFieldsSet(daemon.ObjectMeta)
return generic.ObjectMetaFieldsSet(daemon.ObjectMeta, true)
}

// MatchSetDaemon is the filter used by the generic etcd backend to route
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/deployment/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (deploymentStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime

// DeploymentToSelectableFields returns a field set that represents the object.
func DeploymentToSelectableFields(deployment *extensions.Deployment) fields.Set {
return generic.ObjectMetaFieldsSet(deployment.ObjectMeta)
return generic.ObjectMetaFieldsSet(deployment.ObjectMeta, true)
}

// MatchDeployment is the filter used by the generic etcd backend to route
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/endpoint/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ func EndpointsAttributes(obj runtime.Object) (objLabels labels.Set, objFields fi
if !ok {
return nil, nil, fmt.Errorf("invalid object type %#v", obj)
}
return endpoints.Labels, generic.ObjectMetaFieldsSet(endpoints.ObjectMeta), nil
return endpoints.Labels, generic.ObjectMetaFieldsSet(endpoints.ObjectMeta, true), nil
}
2 changes: 1 addition & 1 deletion pkg/registry/event/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func getAttrs(obj runtime.Object) (objLabels labels.Set, objFields fields.Set, e
l = labels.Set{}
}

objectMetaFieldsSet := generic.ObjectMetaFieldsSet(event.ObjectMeta)
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(event.ObjectMeta, true)
specificFieldsSet := fields.Set{
"involvedObject.kind": event.InvolvedObject.Kind,
"involvedObject.namespace": event.InvolvedObject.Namespace,
Expand Down
7 changes: 6 additions & 1 deletion pkg/registry/generic/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ import (
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 {
func ObjectMetaFieldsSet(objectMeta api.ObjectMeta, hasNamespaceField bool) fields.Set {
if !hasNamespaceField {
return fields.Set{
"metadata.name": objectMeta.Name,
}
}
return fields.Set{
"metadata.name": objectMeta.Name,
"metadata.namespace": objectMeta.Namespace,
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/ingress/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (ingressStrategy) AllowUnconditionalUpdate() bool {

// IngressToSelectableFields returns a field set that represents the object.
func IngressToSelectableFields(ingress *extensions.Ingress) fields.Set {
return generic.ObjectMetaFieldsSet(ingress.ObjectMeta)
return generic.ObjectMetaFieldsSet(ingress.ObjectMeta, true)
}

// MatchIngress is the filter used by the generic etcd backend to ingress
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/job/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (jobStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object

// JobSelectableFields returns a field set that represents the object for matching purposes.
func JobToSelectableFields(job *extensions.Job) fields.Set {
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(job.ObjectMeta)
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(job.ObjectMeta, true)
specificFieldsSet := fields.Set{
"status.successful": strconv.Itoa(job.Status.Succeeded),
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/namespace/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func MatchNamespace(label labels.Selector, field fields.Selector) generic.Matche

// NamespaceToSelectableFields returns a label set that represents the object
func NamespaceToSelectableFields(namespace *api.Namespace) labels.Set {
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(namespace.ObjectMeta)
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(namespace.ObjectMeta, false)
specificFieldsSet := fields.Set{
"status.phase": string(namespace.Status.Phase),
// This is a bug, but we need to support it for backward compatibility.
Expand Down
5 changes: 3 additions & 2 deletions pkg/registry/node/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ type ResourceGetter interface {

// NodeToSelectableFields returns a label set that represents the object.
func NodeToSelectableFields(node *api.Node) fields.Set {
return fields.Set{
"metadata.name": node.Name,
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(node.ObjectMeta, false)
specificFieldsSet := fields.Set{
"spec.unschedulable": fmt.Sprint(node.Spec.Unschedulable),
}
return generic.MergeFieldsSets(objectMetaFieldsSet, specificFieldsSet)
}

// MatchNode returns a generic matcher for a given label and field selector.
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/persistentvolume/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func MatchPersistentVolumes(label labels.Selector, field fields.Selector) generi

// PersistentVolumeToSelectableFields returns a label set that represents the object
func PersistentVolumeToSelectableFields(persistentvolume *api.PersistentVolume) labels.Set {
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(persistentvolume.ObjectMeta)
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(persistentvolume.ObjectMeta, false)
specificFieldsSet := fields.Set{
// This is a bug, but we need to support it for backward compatibility.
"name": persistentvolume.Name,
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/persistentvolumeclaim/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func MatchPersistentVolumeClaim(label labels.Selector, field fields.Selector) ge

// PersistentVolumeClaimToSelectableFields returns a label set that represents the object
func PersistentVolumeClaimToSelectableFields(persistentvolumeclaim *api.PersistentVolumeClaim) labels.Set {
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(persistentvolumeclaim.ObjectMeta)
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(persistentvolumeclaim.ObjectMeta, true)
specificFieldsSet := fields.Set{
// This is a bug, but we need to support it for backward compatibility.
"name": persistentvolumeclaim.Name,
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/pod/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func MatchPod(label labels.Selector, field fields.Selector) generic.Matcher {
// PodToSelectableFields returns a field set that represents the object
// TODO: fields are not labels, and the validation rules for them do not apply.
func PodToSelectableFields(pod *api.Pod) fields.Set {
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(pod.ObjectMeta)
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(pod.ObjectMeta, true)
podSpecificFieldsSet := fields.Set{
"spec.nodeName": pod.Spec.NodeName,
"status.phase": string(pod.Status.Phase),
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/resourcequota/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ func MatchResourceQuota(label labels.Selector, field fields.Selector) generic.Ma

// ResourceQuotaToSelectableFields returns a label set that represents the object
func ResourceQuotaToSelectableFields(resourcequota *api.ResourceQuota) labels.Set {
return labels.Set(generic.ObjectMetaFieldsSet(resourcequota.ObjectMeta))
return labels.Set(generic.ObjectMetaFieldsSet(resourcequota.ObjectMeta, true))
}
2 changes: 1 addition & 1 deletion pkg/registry/serviceaccount/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {

// SelectableFields returns a label set that represents the object
func SelectableFields(obj *api.ServiceAccount) labels.Set {
return labels.Set(generic.ObjectMetaFieldsSet(obj.ObjectMeta))
return labels.Set(generic.ObjectMetaFieldsSet(obj.ObjectMeta, true))
}