mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 21:53:52 +00:00
Fix incorrect reference to name in v1beta3 API.
This commit is contained in:
@@ -291,7 +291,7 @@ func TestListPodListSelection(t *testing.T) {
|
||||
{
|
||||
expectedIDs: util.NewStringSet("foo", "bar", "baz", "qux", "zot"),
|
||||
}, {
|
||||
field: "name=zot",
|
||||
field: "metadata.name=zot",
|
||||
expectedIDs: util.NewStringSet("zot"),
|
||||
}, {
|
||||
label: "label=qux",
|
||||
|
@@ -105,23 +105,26 @@ func (podStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object
|
||||
|
||||
// MatchPod returns a generic matcher for a given label and field selector.
|
||||
func MatchPod(label labels.Selector, field fields.Selector) generic.Matcher {
|
||||
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
|
||||
podObj, ok := obj.(*api.Pod)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("not a pod")
|
||||
}
|
||||
fields := PodToSelectableFields(podObj)
|
||||
return label.Matches(labels.Set(podObj.Labels)) && field.Matches(fields), nil
|
||||
})
|
||||
return &generic.SelectionPredicate{
|
||||
Label: label,
|
||||
Field: field,
|
||||
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||
pod, ok := obj.(*api.Pod)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("not a pod")
|
||||
}
|
||||
return labels.Set(pod.ObjectMeta.Labels), PodToSelectableFields(pod), nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// PodToSelectableFields returns a label set that represents the object
|
||||
// TODO: fields are not labels, and the validation rules for them do not apply.
|
||||
func PodToSelectableFields(pod *api.Pod) labels.Set {
|
||||
return labels.Set{
|
||||
"name": pod.Name,
|
||||
"spec.host": pod.Spec.Host,
|
||||
"status.phase": string(pod.Status.Phase),
|
||||
func PodToSelectableFields(pod *api.Pod) fields.Set {
|
||||
return fields.Set{
|
||||
"metadata.name": pod.Name,
|
||||
"spec.host": pod.Spec.Host,
|
||||
"status.phase": string(pod.Status.Phase),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user