From c6cafa576ce0cda74548a5ed142af94eb7ccc494 Mon Sep 17 00:00:00 2001 From: Di Xu Date: Thu, 3 Aug 2017 18:26:25 +0800 Subject: [PATCH] add fieldSelector podIP --- pkg/registry/core/pod/strategy.go | 1 + pkg/registry/core/pod/strategy_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/registry/core/pod/strategy.go b/pkg/registry/core/pod/strategy.go index 00a3c4f991e..590042ad18d 100644 --- a/pkg/registry/core/pod/strategy.go +++ b/pkg/registry/core/pod/strategy.go @@ -200,6 +200,7 @@ func PodToSelectableFields(pod *api.Pod) fields.Set { podSpecificFieldsSet["spec.nodeName"] = pod.Spec.NodeName podSpecificFieldsSet["spec.restartPolicy"] = string(pod.Spec.RestartPolicy) podSpecificFieldsSet["status.phase"] = string(pod.Status.Phase) + podSpecificFieldsSet["status.podIP"] = string(pod.Status.PodIP) return generic.AddObjectMetaFieldsSet(podSpecificFieldsSet, &pod.ObjectMeta, true) } diff --git a/pkg/registry/core/pod/strategy_test.go b/pkg/registry/core/pod/strategy_test.go index 1f9e78c25cc..eed6fcf15fd 100644 --- a/pkg/registry/core/pod/strategy_test.go +++ b/pkg/registry/core/pod/strategy_test.go @@ -82,6 +82,20 @@ func TestMatchPod(t *testing.T) { fieldSelector: fields.ParseSelectorOrDie("status.phase=Pending"), expectMatch: false, }, + { + in: &api.Pod{ + Status: api.PodStatus{PodIP: "1.2.3.4"}, + }, + fieldSelector: fields.ParseSelectorOrDie("status.podIP=1.2.3.4"), + expectMatch: true, + }, + { + in: &api.Pod{ + Status: api.PodStatus{PodIP: "1.2.3.4"}, + }, + fieldSelector: fields.ParseSelectorOrDie("status.podIP=4.3.2.1"), + expectMatch: false, + }, } for _, testCase := range testCases { m := MatchPod(labels.Everything(), testCase.fieldSelector)