Commit e2679abd authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #18011 from sdminonne/podSelector_labelSelector

Auto commit by PR queue bot
parents f481ec3b 80575c30
...@@ -2941,7 +2941,7 @@ ...@@ -2941,7 +2941,7 @@
"description": "Completions specifies the desired number of successfully finished pods the job should be run with. Defaults to 1. More info: http://releases.k8s.io/HEAD/docs/user-guide/jobs.md" "description": "Completions specifies the desired number of successfully finished pods the job should be run with. Defaults to 1. More info: http://releases.k8s.io/HEAD/docs/user-guide/jobs.md"
}, },
"selector": { "selector": {
"$ref": "v1beta1.PodSelector", "$ref": "v1beta1.LabelSelector",
"description": "Selector is a label query over pods that should match the pod count. More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors" "description": "Selector is a label query over pods that should match the pod count. More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors"
}, },
"template": { "template": {
...@@ -2950,9 +2950,9 @@ ...@@ -2950,9 +2950,9 @@
} }
} }
}, },
"v1beta1.PodSelector": { "v1beta1.LabelSelector": {
"id": "v1beta1.PodSelector", "id": "v1beta1.LabelSelector",
"description": "A pod selector is a label query over a set of pods. The result of matchLabels and matchExpressions are ANDed. An empty pod selector matches all objects. A null pod selector matches no objects.", "description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.",
"properties": { "properties": {
"matchLabels": { "matchLabels": {
"type": "any", "type": "any",
...@@ -2961,15 +2961,15 @@ ...@@ -2961,15 +2961,15 @@
"matchExpressions": { "matchExpressions": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "v1beta1.PodSelectorRequirement" "$ref": "v1beta1.LabelSelectorRequirement"
}, },
"description": "matchExpressions is a list of pod selector requirements. The requirements are ANDed." "description": "matchExpressions is a list of label selector requirements. The requirements are ANDed."
} }
} }
}, },
"v1beta1.PodSelectorRequirement": { "v1beta1.LabelSelectorRequirement": {
"id": "v1beta1.PodSelectorRequirement", "id": "v1beta1.LabelSelectorRequirement",
"description": "A pod selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", "description": "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.",
"required": [ "required": [
"key", "key",
"operator" "operator"
......
...@@ -982,8 +982,8 @@ func deepCopy_extensions_DaemonSetList(in DaemonSetList, out *DaemonSetList, c * ...@@ -982,8 +982,8 @@ func deepCopy_extensions_DaemonSetList(in DaemonSetList, out *DaemonSetList, c *
func deepCopy_extensions_DaemonSetSpec(in DaemonSetSpec, out *DaemonSetSpec, c *conversion.Cloner) error { func deepCopy_extensions_DaemonSetSpec(in DaemonSetSpec, out *DaemonSetSpec, c *conversion.Cloner) error {
if in.Selector != nil { if in.Selector != nil {
out.Selector = new(PodSelector) out.Selector = new(LabelSelector)
if err := deepCopy_extensions_PodSelector(*in.Selector, out.Selector, c); err != nil { if err := deepCopy_extensions_LabelSelector(*in.Selector, out.Selector, c); err != nil {
return err return err
} }
} else { } else {
...@@ -1345,8 +1345,8 @@ func deepCopy_extensions_JobSpec(in JobSpec, out *JobSpec, c *conversion.Cloner) ...@@ -1345,8 +1345,8 @@ func deepCopy_extensions_JobSpec(in JobSpec, out *JobSpec, c *conversion.Cloner)
out.Completions = nil out.Completions = nil
} }
if in.Selector != nil { if in.Selector != nil {
out.Selector = new(PodSelector) out.Selector = new(LabelSelector)
if err := deepCopy_extensions_PodSelector(*in.Selector, out.Selector, c); err != nil { if err := deepCopy_extensions_LabelSelector(*in.Selector, out.Selector, c); err != nil {
return err return err
} }
} else { } else {
...@@ -1391,13 +1391,7 @@ func deepCopy_extensions_JobStatus(in JobStatus, out *JobStatus, c *conversion.C ...@@ -1391,13 +1391,7 @@ func deepCopy_extensions_JobStatus(in JobStatus, out *JobStatus, c *conversion.C
return nil return nil
} }
func deepCopy_extensions_NodeUtilization(in NodeUtilization, out *NodeUtilization, c *conversion.Cloner) error { func deepCopy_extensions_LabelSelector(in LabelSelector, out *LabelSelector, c *conversion.Cloner) error {
out.Resource = in.Resource
out.Value = in.Value
return nil
}
func deepCopy_extensions_PodSelector(in PodSelector, out *PodSelector, c *conversion.Cloner) error {
if in.MatchLabels != nil { if in.MatchLabels != nil {
out.MatchLabels = make(map[string]string) out.MatchLabels = make(map[string]string)
for key, val := range in.MatchLabels { for key, val := range in.MatchLabels {
...@@ -1407,9 +1401,9 @@ func deepCopy_extensions_PodSelector(in PodSelector, out *PodSelector, c *conver ...@@ -1407,9 +1401,9 @@ func deepCopy_extensions_PodSelector(in PodSelector, out *PodSelector, c *conver
out.MatchLabels = nil out.MatchLabels = nil
} }
if in.MatchExpressions != nil { if in.MatchExpressions != nil {
out.MatchExpressions = make([]PodSelectorRequirement, len(in.MatchExpressions)) out.MatchExpressions = make([]LabelSelectorRequirement, len(in.MatchExpressions))
for i := range in.MatchExpressions { for i := range in.MatchExpressions {
if err := deepCopy_extensions_PodSelectorRequirement(in.MatchExpressions[i], &out.MatchExpressions[i], c); err != nil { if err := deepCopy_extensions_LabelSelectorRequirement(in.MatchExpressions[i], &out.MatchExpressions[i], c); err != nil {
return err return err
} }
} }
...@@ -1419,7 +1413,7 @@ func deepCopy_extensions_PodSelector(in PodSelector, out *PodSelector, c *conver ...@@ -1419,7 +1413,7 @@ func deepCopy_extensions_PodSelector(in PodSelector, out *PodSelector, c *conver
return nil return nil
} }
func deepCopy_extensions_PodSelectorRequirement(in PodSelectorRequirement, out *PodSelectorRequirement, c *conversion.Cloner) error { func deepCopy_extensions_LabelSelectorRequirement(in LabelSelectorRequirement, out *LabelSelectorRequirement, c *conversion.Cloner) error {
out.Key = in.Key out.Key = in.Key
out.Operator = in.Operator out.Operator = in.Operator
if in.Values != nil { if in.Values != nil {
...@@ -1433,6 +1427,12 @@ func deepCopy_extensions_PodSelectorRequirement(in PodSelectorRequirement, out * ...@@ -1433,6 +1427,12 @@ func deepCopy_extensions_PodSelectorRequirement(in PodSelectorRequirement, out *
return nil return nil
} }
func deepCopy_extensions_NodeUtilization(in NodeUtilization, out *NodeUtilization, c *conversion.Cloner) error {
out.Resource = in.Resource
out.Value = in.Value
return nil
}
func deepCopy_extensions_ReplicationControllerDummy(in ReplicationControllerDummy, out *ReplicationControllerDummy, c *conversion.Cloner) error { func deepCopy_extensions_ReplicationControllerDummy(in ReplicationControllerDummy, out *ReplicationControllerDummy, c *conversion.Cloner) error {
if err := deepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { if err := deepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err return err
...@@ -1659,9 +1659,9 @@ func init() { ...@@ -1659,9 +1659,9 @@ func init() {
deepCopy_extensions_JobList, deepCopy_extensions_JobList,
deepCopy_extensions_JobSpec, deepCopy_extensions_JobSpec,
deepCopy_extensions_JobStatus, deepCopy_extensions_JobStatus,
deepCopy_extensions_LabelSelector,
deepCopy_extensions_LabelSelectorRequirement,
deepCopy_extensions_NodeUtilization, deepCopy_extensions_NodeUtilization,
deepCopy_extensions_PodSelector,
deepCopy_extensions_PodSelectorRequirement,
deepCopy_extensions_ReplicationControllerDummy, deepCopy_extensions_ReplicationControllerDummy,
deepCopy_extensions_RollingUpdateDeployment, deepCopy_extensions_RollingUpdateDeployment,
deepCopy_extensions_Scale, deepCopy_extensions_Scale,
......
...@@ -25,9 +25,9 @@ import ( ...@@ -25,9 +25,9 @@ import (
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
) )
// PodSelectorAsSelector converts the PodSelector api type into a struct that implements // LabelSelectorAsSelector converts the LabelSelector api type into a struct that implements
// labels.Selector // labels.Selector
func PodSelectorAsSelector(ps *PodSelector) (labels.Selector, error) { func LabelSelectorAsSelector(ps *LabelSelector) (labels.Selector, error) {
if ps == nil { if ps == nil {
return labels.Nothing(), nil return labels.Nothing(), nil
} }
...@@ -45,13 +45,13 @@ func PodSelectorAsSelector(ps *PodSelector) (labels.Selector, error) { ...@@ -45,13 +45,13 @@ func PodSelectorAsSelector(ps *PodSelector) (labels.Selector, error) {
for _, expr := range ps.MatchExpressions { for _, expr := range ps.MatchExpressions {
var op labels.Operator var op labels.Operator
switch expr.Operator { switch expr.Operator {
case PodSelectorOpIn: case LabelSelectorOpIn:
op = labels.InOperator op = labels.InOperator
case PodSelectorOpNotIn: case LabelSelectorOpNotIn:
op = labels.NotInOperator op = labels.NotInOperator
case PodSelectorOpExists: case LabelSelectorOpExists:
op = labels.ExistsOperator op = labels.ExistsOperator
case PodSelectorOpDoesNotExist: case LabelSelectorOpDoesNotExist:
op = labels.DoesNotExistOperator op = labels.DoesNotExistOperator
default: default:
return nil, fmt.Errorf("%q is not a valid pod selector operator", expr.Operator) return nil, fmt.Errorf("%q is not a valid pod selector operator", expr.Operator)
......
...@@ -23,11 +23,11 @@ import ( ...@@ -23,11 +23,11 @@ import (
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
) )
func TestPodSelectorAsSelector(t *testing.T) { func TestLabelSelectorAsSelector(t *testing.T) {
matchLabels := map[string]string{"foo": "bar"} matchLabels := map[string]string{"foo": "bar"}
matchExpressions := []PodSelectorRequirement{{ matchExpressions := []LabelSelectorRequirement{{
Key: "baz", Key: "baz",
Operator: PodSelectorOpIn, Operator: LabelSelectorOpIn,
Values: []string{"qux", "norf"}, Values: []string{"qux", "norf"},
}} }}
mustParse := func(s string) labels.Selector { mustParse := func(s string) labels.Selector {
...@@ -38,29 +38,29 @@ func TestPodSelectorAsSelector(t *testing.T) { ...@@ -38,29 +38,29 @@ func TestPodSelectorAsSelector(t *testing.T) {
return out return out
} }
tc := []struct { tc := []struct {
in *PodSelector in *LabelSelector
out labels.Selector out labels.Selector
expectErr bool expectErr bool
}{ }{
{in: nil, out: labels.Nothing()}, {in: nil, out: labels.Nothing()},
{in: &PodSelector{}, out: labels.Everything()}, {in: &LabelSelector{}, out: labels.Everything()},
{ {
in: &PodSelector{MatchLabels: matchLabels}, in: &LabelSelector{MatchLabels: matchLabels},
out: mustParse("foo in (bar)"), out: mustParse("foo in (bar)"),
}, },
{ {
in: &PodSelector{MatchExpressions: matchExpressions}, in: &LabelSelector{MatchExpressions: matchExpressions},
out: mustParse("baz in (norf,qux)"), out: mustParse("baz in (norf,qux)"),
}, },
{ {
in: &PodSelector{MatchLabels: matchLabels, MatchExpressions: matchExpressions}, in: &LabelSelector{MatchLabels: matchLabels, MatchExpressions: matchExpressions},
out: mustParse("foo in (bar),baz in (norf,qux)"), out: mustParse("foo in (bar),baz in (norf,qux)"),
}, },
{ {
in: &PodSelector{ in: &LabelSelector{
MatchExpressions: []PodSelectorRequirement{{ MatchExpressions: []LabelSelectorRequirement{{
Key: "baz", Key: "baz",
Operator: PodSelectorOpExists, Operator: LabelSelectorOpExists,
Values: []string{"qux", "norf"}, Values: []string{"qux", "norf"},
}}, }},
}, },
...@@ -69,7 +69,7 @@ func TestPodSelectorAsSelector(t *testing.T) { ...@@ -69,7 +69,7 @@ func TestPodSelectorAsSelector(t *testing.T) {
} }
for i, tc := range tc { for i, tc := range tc {
out, err := PodSelectorAsSelector(tc.in) out, err := LabelSelectorAsSelector(tc.in)
if err == nil && tc.expectErr { if err == nil && tc.expectErr {
t.Errorf("[%v]expected error but got none.", i) t.Errorf("[%v]expected error but got none.", i)
} }
......
...@@ -298,7 +298,7 @@ type DaemonSetSpec struct { ...@@ -298,7 +298,7 @@ type DaemonSetSpec struct {
// Must match in order to be controlled. // Must match in order to be controlled.
// If empty, defaulted to labels on Pod template. // If empty, defaulted to labels on Pod template.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors // More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
Selector *PodSelector `json:"selector,omitempty"` Selector *LabelSelector `json:"selector,omitempty"`
// Template is the object that describes the pod that will be created. // Template is the object that describes the pod that will be created.
// The DaemonSet will create exactly one copy of this pod on every node // The DaemonSet will create exactly one copy of this pod on every node
...@@ -403,7 +403,7 @@ type JobSpec struct { ...@@ -403,7 +403,7 @@ type JobSpec struct {
Completions *int `json:"completions,omitempty"` Completions *int `json:"completions,omitempty"`
// Selector is a label query over pods that should match the pod count. // Selector is a label query over pods that should match the pod count.
Selector *PodSelector `json:"selector,omitempty"` Selector *LabelSelector `json:"selector,omitempty"`
// Template is the object that describes the pod that will be created when // Template is the object that describes the pod that will be created when
// executing a job. // executing a job.
...@@ -647,26 +647,26 @@ type ClusterAutoscalerList struct { ...@@ -647,26 +647,26 @@ type ClusterAutoscalerList struct {
Items []ClusterAutoscaler `json:"items"` Items []ClusterAutoscaler `json:"items"`
} }
// A pod selector is a label query over a set of pods. The result of matchLabels and // A label selector is a label query over a set of resources. The result of matchLabels and
// matchExpressions are ANDed. An empty pod selector matches all objects. A null // matchExpressions are ANDed. An empty label selector matches all objects. A null
// pod selector matches no objects. // label selector matches no objects.
type PodSelector struct { type LabelSelector struct {
// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels // matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
// map is equivalent to an element of matchExpressions, whose key field is "key", the // map is equivalent to an element of matchExpressions, whose key field is "key", the
// operator is "In", and the values array contains only "value". The requirements are ANDed. // operator is "In", and the values array contains only "value". The requirements are ANDed.
MatchLabels map[string]string `json:"matchLabels,omitempty"` MatchLabels map[string]string `json:"matchLabels,omitempty"`
// matchExpressions is a list of pod selector requirements. The requirements are ANDed. // matchExpressions is a list of label selector requirements. The requirements are ANDed.
MatchExpressions []PodSelectorRequirement `json:"matchExpressions,omitempty"` MatchExpressions []LabelSelectorRequirement `json:"matchExpressions,omitempty"`
} }
// A pod selector requirement is a selector that contains values, a key, and an operator that // A label selector requirement is a selector that contains values, a key, and an operator that
// relates the key and values. // relates the key and values.
type PodSelectorRequirement struct { type LabelSelectorRequirement struct {
// key is the label key that the selector applies to. // key is the label key that the selector applies to.
Key string `json:"key" patchStrategy:"merge" patchMergeKey:"key"` Key string `json:"key" patchStrategy:"merge" patchMergeKey:"key"`
// operator represents a key's relationship to a set of values. // operator represents a key's relationship to a set of values.
// Valid operators ard In, NotIn, Exists and DoesNotExist. // Valid operators ard In, NotIn, Exists and DoesNotExist.
Operator PodSelectorOperator `json:"operator"` Operator LabelSelectorOperator `json:"operator"`
// values is an array of string values. If the operator is In or NotIn, // values is an array of string values. If the operator is In or NotIn,
// the values array must be non-empty. If the operator is Exists or DoesNotExist, // the values array must be non-empty. If the operator is Exists or DoesNotExist,
// the values array must be empty. This array is replaced during a strategic // the values array must be empty. This array is replaced during a strategic
...@@ -674,12 +674,12 @@ type PodSelectorRequirement struct { ...@@ -674,12 +674,12 @@ type PodSelectorRequirement struct {
Values []string `json:"values,omitempty"` Values []string `json:"values,omitempty"`
} }
// A pod selector operator is the set of operators that can be used in a selector requirement. // A label selector operator is the set of operators that can be used in a selector requirement.
type PodSelectorOperator string type LabelSelectorOperator string
const ( const (
PodSelectorOpIn PodSelectorOperator = "In" LabelSelectorOpIn LabelSelectorOperator = "In"
PodSelectorOpNotIn PodSelectorOperator = "NotIn" LabelSelectorOpNotIn LabelSelectorOperator = "NotIn"
PodSelectorOpExists PodSelectorOperator = "Exists" LabelSelectorOpExists LabelSelectorOperator = "Exists"
PodSelectorOpDoesNotExist PodSelectorOperator = "DoesNotExist" LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist"
) )
...@@ -984,8 +984,8 @@ func deepCopy_v1beta1_DaemonSetList(in DaemonSetList, out *DaemonSetList, c *con ...@@ -984,8 +984,8 @@ func deepCopy_v1beta1_DaemonSetList(in DaemonSetList, out *DaemonSetList, c *con
func deepCopy_v1beta1_DaemonSetSpec(in DaemonSetSpec, out *DaemonSetSpec, c *conversion.Cloner) error { func deepCopy_v1beta1_DaemonSetSpec(in DaemonSetSpec, out *DaemonSetSpec, c *conversion.Cloner) error {
if in.Selector != nil { if in.Selector != nil {
out.Selector = new(PodSelector) out.Selector = new(LabelSelector)
if err := deepCopy_v1beta1_PodSelector(*in.Selector, out.Selector, c); err != nil { if err := deepCopy_v1beta1_LabelSelector(*in.Selector, out.Selector, c); err != nil {
return err return err
} }
} else { } else {
...@@ -1357,8 +1357,8 @@ func deepCopy_v1beta1_JobSpec(in JobSpec, out *JobSpec, c *conversion.Cloner) er ...@@ -1357,8 +1357,8 @@ func deepCopy_v1beta1_JobSpec(in JobSpec, out *JobSpec, c *conversion.Cloner) er
out.Completions = nil out.Completions = nil
} }
if in.Selector != nil { if in.Selector != nil {
out.Selector = new(PodSelector) out.Selector = new(LabelSelector)
if err := deepCopy_v1beta1_PodSelector(*in.Selector, out.Selector, c); err != nil { if err := deepCopy_v1beta1_LabelSelector(*in.Selector, out.Selector, c); err != nil {
return err return err
} }
} else { } else {
...@@ -1403,13 +1403,7 @@ func deepCopy_v1beta1_JobStatus(in JobStatus, out *JobStatus, c *conversion.Clon ...@@ -1403,13 +1403,7 @@ func deepCopy_v1beta1_JobStatus(in JobStatus, out *JobStatus, c *conversion.Clon
return nil return nil
} }
func deepCopy_v1beta1_NodeUtilization(in NodeUtilization, out *NodeUtilization, c *conversion.Cloner) error { func deepCopy_v1beta1_LabelSelector(in LabelSelector, out *LabelSelector, c *conversion.Cloner) error {
out.Resource = in.Resource
out.Value = in.Value
return nil
}
func deepCopy_v1beta1_PodSelector(in PodSelector, out *PodSelector, c *conversion.Cloner) error {
if in.MatchLabels != nil { if in.MatchLabels != nil {
out.MatchLabels = make(map[string]string) out.MatchLabels = make(map[string]string)
for key, val := range in.MatchLabels { for key, val := range in.MatchLabels {
...@@ -1419,9 +1413,9 @@ func deepCopy_v1beta1_PodSelector(in PodSelector, out *PodSelector, c *conversio ...@@ -1419,9 +1413,9 @@ func deepCopy_v1beta1_PodSelector(in PodSelector, out *PodSelector, c *conversio
out.MatchLabels = nil out.MatchLabels = nil
} }
if in.MatchExpressions != nil { if in.MatchExpressions != nil {
out.MatchExpressions = make([]PodSelectorRequirement, len(in.MatchExpressions)) out.MatchExpressions = make([]LabelSelectorRequirement, len(in.MatchExpressions))
for i := range in.MatchExpressions { for i := range in.MatchExpressions {
if err := deepCopy_v1beta1_PodSelectorRequirement(in.MatchExpressions[i], &out.MatchExpressions[i], c); err != nil { if err := deepCopy_v1beta1_LabelSelectorRequirement(in.MatchExpressions[i], &out.MatchExpressions[i], c); err != nil {
return err return err
} }
} }
...@@ -1431,7 +1425,7 @@ func deepCopy_v1beta1_PodSelector(in PodSelector, out *PodSelector, c *conversio ...@@ -1431,7 +1425,7 @@ func deepCopy_v1beta1_PodSelector(in PodSelector, out *PodSelector, c *conversio
return nil return nil
} }
func deepCopy_v1beta1_PodSelectorRequirement(in PodSelectorRequirement, out *PodSelectorRequirement, c *conversion.Cloner) error { func deepCopy_v1beta1_LabelSelectorRequirement(in LabelSelectorRequirement, out *LabelSelectorRequirement, c *conversion.Cloner) error {
out.Key = in.Key out.Key = in.Key
out.Operator = in.Operator out.Operator = in.Operator
if in.Values != nil { if in.Values != nil {
...@@ -1445,6 +1439,12 @@ func deepCopy_v1beta1_PodSelectorRequirement(in PodSelectorRequirement, out *Pod ...@@ -1445,6 +1439,12 @@ func deepCopy_v1beta1_PodSelectorRequirement(in PodSelectorRequirement, out *Pod
return nil return nil
} }
func deepCopy_v1beta1_NodeUtilization(in NodeUtilization, out *NodeUtilization, c *conversion.Cloner) error {
out.Resource = in.Resource
out.Value = in.Value
return nil
}
func deepCopy_v1beta1_ReplicationControllerDummy(in ReplicationControllerDummy, out *ReplicationControllerDummy, c *conversion.Cloner) error { func deepCopy_v1beta1_ReplicationControllerDummy(in ReplicationControllerDummy, out *ReplicationControllerDummy, c *conversion.Cloner) error {
if err := deepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { if err := deepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err return err
...@@ -1681,9 +1681,9 @@ func init() { ...@@ -1681,9 +1681,9 @@ func init() {
deepCopy_v1beta1_JobList, deepCopy_v1beta1_JobList,
deepCopy_v1beta1_JobSpec, deepCopy_v1beta1_JobSpec,
deepCopy_v1beta1_JobStatus, deepCopy_v1beta1_JobStatus,
deepCopy_v1beta1_LabelSelector,
deepCopy_v1beta1_LabelSelectorRequirement,
deepCopy_v1beta1_NodeUtilization, deepCopy_v1beta1_NodeUtilization,
deepCopy_v1beta1_PodSelector,
deepCopy_v1beta1_PodSelectorRequirement,
deepCopy_v1beta1_ReplicationControllerDummy, deepCopy_v1beta1_ReplicationControllerDummy,
deepCopy_v1beta1_RollingUpdateDeployment, deepCopy_v1beta1_RollingUpdateDeployment,
deepCopy_v1beta1_Scale, deepCopy_v1beta1_Scale,
......
...@@ -36,7 +36,7 @@ func addDefaultingFuncs() { ...@@ -36,7 +36,7 @@ func addDefaultingFuncs() {
// TODO: support templates defined elsewhere when we support them in the API // TODO: support templates defined elsewhere when we support them in the API
if labels != nil { if labels != nil {
if obj.Spec.Selector == nil { if obj.Spec.Selector == nil {
obj.Spec.Selector = &PodSelector{ obj.Spec.Selector = &LabelSelector{
MatchLabels: labels, MatchLabels: labels,
} }
} }
...@@ -93,7 +93,7 @@ func addDefaultingFuncs() { ...@@ -93,7 +93,7 @@ func addDefaultingFuncs() {
// TODO: support templates defined elsewhere when we support them in the API // TODO: support templates defined elsewhere when we support them in the API
if labels != nil { if labels != nil {
if obj.Spec.Selector == nil { if obj.Spec.Selector == nil {
obj.Spec.Selector = &PodSelector{ obj.Spec.Selector = &LabelSelector{
MatchLabels: labels, MatchLabels: labels,
} }
} }
......
...@@ -205,7 +205,7 @@ func TestSetDefaultDeployment(t *testing.T) { ...@@ -205,7 +205,7 @@ func TestSetDefaultDeployment(t *testing.T) {
func TestSetDefaultJob(t *testing.T) { func TestSetDefaultJob(t *testing.T) {
expected := &Job{ expected := &Job{
Spec: JobSpec{ Spec: JobSpec{
Selector: &PodSelector{ Selector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"}, MatchLabels: map[string]string{"job": "selector"},
}, },
Completions: newInt32(1), Completions: newInt32(1),
...@@ -216,7 +216,7 @@ func TestSetDefaultJob(t *testing.T) { ...@@ -216,7 +216,7 @@ func TestSetDefaultJob(t *testing.T) {
// selector set explicitly, completions and parallelism - default // selector set explicitly, completions and parallelism - default
{ {
Spec: JobSpec{ Spec: JobSpec{
Selector: &PodSelector{ Selector: &LabelSelector{
MatchLabels: map[string]string{"job": "selector"}, MatchLabels: map[string]string{"job": "selector"},
}, },
}, },
......
...@@ -296,7 +296,7 @@ type DaemonSetSpec struct { ...@@ -296,7 +296,7 @@ type DaemonSetSpec struct {
// Must match in order to be controlled. // Must match in order to be controlled.
// If empty, defaulted to labels on Pod template. // If empty, defaulted to labels on Pod template.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors // More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
Selector *PodSelector `json:"selector,omitempty"` Selector *LabelSelector `json:"selector,omitempty"`
// Template is the object that describes the pod that will be created. // Template is the object that describes the pod that will be created.
// The DaemonSet will create exactly one copy of this pod on every node // The DaemonSet will create exactly one copy of this pod on every node
...@@ -409,7 +409,7 @@ type JobSpec struct { ...@@ -409,7 +409,7 @@ type JobSpec struct {
// Selector is a label query over pods that should match the pod count. // Selector is a label query over pods that should match the pod count.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors // More info: http://releases.k8s.io/HEAD/docs/user-guide/labels.md#label-selectors
Selector *PodSelector `json:"selector,omitempty"` Selector *LabelSelector `json:"selector,omitempty"`
// Template is the object that describes the pod that will be created when // Template is the object that describes the pod that will be created when
// executing a job. // executing a job.
...@@ -655,26 +655,26 @@ type ClusterAutoscalerList struct { ...@@ -655,26 +655,26 @@ type ClusterAutoscalerList struct {
Items []ClusterAutoscaler `json:"items"` Items []ClusterAutoscaler `json:"items"`
} }
// A pod selector is a label query over a set of pods. The result of matchLabels and // A label selector is a label query over a set of resources. The result of matchLabels and
// matchExpressions are ANDed. An empty pod selector matches all objects. A null // matchExpressions are ANDed. An empty label selector matches all objects. A null
// pod selector matches no objects. // label selector matches no objects.
type PodSelector struct { type LabelSelector struct {
// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels // matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
// map is equivalent to an element of matchExpressions, whose key field is "key", the // map is equivalent to an element of matchExpressions, whose key field is "key", the
// operator is "In", and the values array contains only "value". The requirements are ANDed. // operator is "In", and the values array contains only "value". The requirements are ANDed.
MatchLabels map[string]string `json:"matchLabels,omitempty"` MatchLabels map[string]string `json:"matchLabels,omitempty"`
// matchExpressions is a list of pod selector requirements. The requirements are ANDed. // matchExpressions is a list of label selector requirements. The requirements are ANDed.
MatchExpressions []PodSelectorRequirement `json:"matchExpressions,omitempty"` MatchExpressions []LabelSelectorRequirement `json:"matchExpressions,omitempty"`
} }
// A pod selector requirement is a selector that contains values, a key, and an operator that // A label selector requirement is a selector that contains values, a key, and an operator that
// relates the key and values. // relates the key and values.
type PodSelectorRequirement struct { type LabelSelectorRequirement struct {
// key is the label key that the selector applies to. // key is the label key that the selector applies to.
Key string `json:"key" patchStrategy:"merge" patchMergeKey:"key"` Key string `json:"key" patchStrategy:"merge" patchMergeKey:"key"`
// operator represents a key's relationship to a set of values. // operator represents a key's relationship to a set of values.
// Valid operators ard In, NotIn, Exists and DoesNotExist. // Valid operators ard In, NotIn, Exists and DoesNotExist.
Operator PodSelectorOperator `json:"operator"` Operator LabelSelectorOperator `json:"operator"`
// values is an array of string values. If the operator is In or NotIn, // values is an array of string values. If the operator is In or NotIn,
// the values array must be non-empty. If the operator is Exists or DoesNotExist, // the values array must be non-empty. If the operator is Exists or DoesNotExist,
// the values array must be empty. This array is replaced during a strategic // the values array must be empty. This array is replaced during a strategic
...@@ -682,12 +682,12 @@ type PodSelectorRequirement struct { ...@@ -682,12 +682,12 @@ type PodSelectorRequirement struct {
Values []string `json:"values,omitempty"` Values []string `json:"values,omitempty"`
} }
// A pod selector operator is the set of operators that can be used in a selector requirement. // A label selector operator is the set of operators that can be used in a selector requirement.
type PodSelectorOperator string type LabelSelectorOperator string
const ( const (
PodSelectorOpIn PodSelectorOperator = "In" LabelSelectorOpIn LabelSelectorOperator = "In"
PodSelectorOpNotIn PodSelectorOperator = "NotIn" LabelSelectorOpNotIn LabelSelectorOperator = "NotIn"
PodSelectorOpExists PodSelectorOperator = "Exists" LabelSelectorOpExists LabelSelectorOperator = "Exists"
PodSelectorOpDoesNotExist PodSelectorOperator = "DoesNotExist" LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist"
) )
...@@ -363,34 +363,34 @@ func (JobStatus) SwaggerDoc() map[string]string { ...@@ -363,34 +363,34 @@ func (JobStatus) SwaggerDoc() map[string]string {
return map_JobStatus return map_JobStatus
} }
var map_NodeUtilization = map[string]string{ var map_LabelSelector = map[string]string{
"": "NodeUtilization describes what percentage of a particular resource is used on a node.", "": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.",
"value": "The accepted values are from 0 to 1.",
}
func (NodeUtilization) SwaggerDoc() map[string]string {
return map_NodeUtilization
}
var map_PodSelector = map[string]string{
"": "A pod selector is a label query over a set of pods. The result of matchLabels and matchExpressions are ANDed. An empty pod selector matches all objects. A null pod selector matches no objects.",
"matchLabels": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed.", "matchLabels": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed.",
"matchExpressions": "matchExpressions is a list of pod selector requirements. The requirements are ANDed.", "matchExpressions": "matchExpressions is a list of label selector requirements. The requirements are ANDed.",
} }
func (PodSelector) SwaggerDoc() map[string]string { func (LabelSelector) SwaggerDoc() map[string]string {
return map_PodSelector return map_LabelSelector
} }
var map_PodSelectorRequirement = map[string]string{ var map_LabelSelectorRequirement = map[string]string{
"": "A pod selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", "": "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.",
"key": "key is the label key that the selector applies to.", "key": "key is the label key that the selector applies to.",
"operator": "operator represents a key's relationship to a set of values. Valid operators ard In, NotIn, Exists and DoesNotExist.", "operator": "operator represents a key's relationship to a set of values. Valid operators ard In, NotIn, Exists and DoesNotExist.",
"values": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.", "values": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.",
} }
func (PodSelectorRequirement) SwaggerDoc() map[string]string { func (LabelSelectorRequirement) SwaggerDoc() map[string]string {
return map_PodSelectorRequirement return map_LabelSelectorRequirement
}
var map_NodeUtilization = map[string]string{
"": "NodeUtilization describes what percentage of a particular resource is used on a node.",
"value": "The accepted values are from 0 to 1.",
}
func (NodeUtilization) SwaggerDoc() map[string]string {
return map_NodeUtilization
} }
var map_ReplicationControllerDummy = map[string]string{ var map_ReplicationControllerDummy = map[string]string{
......
...@@ -188,14 +188,14 @@ func ValidateDaemonSetTemplateUpdate(podTemplate, oldPodTemplate *api.PodTemplat ...@@ -188,14 +188,14 @@ func ValidateDaemonSetTemplateUpdate(podTemplate, oldPodTemplate *api.PodTemplat
func ValidateDaemonSetSpec(spec *extensions.DaemonSetSpec, fldPath *validation.FieldPath) validation.ErrorList { func ValidateDaemonSetSpec(spec *extensions.DaemonSetSpec, fldPath *validation.FieldPath) validation.ErrorList {
allErrs := validation.ErrorList{} allErrs := validation.ErrorList{}
allErrs = append(allErrs, ValidatePodSelector(spec.Selector, fldPath.Child("selector"))...) allErrs = append(allErrs, ValidateLabelSelector(spec.Selector, fldPath.Child("selector"))...)
if spec.Template == nil { if spec.Template == nil {
allErrs = append(allErrs, validation.NewRequiredError(fldPath.Child("template"))) allErrs = append(allErrs, validation.NewRequiredError(fldPath.Child("template")))
return allErrs return allErrs
} }
selector, err := extensions.PodSelectorAsSelector(spec.Selector) selector, err := extensions.LabelSelectorAsSelector(spec.Selector)
if err == nil && !selector.Matches(labels.Set(spec.Template.Labels)) { if err == nil && !selector.Matches(labels.Set(spec.Template.Labels)) {
allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("template", "metadata", "labels"), spec.Template.Labels, "selector does not match template")) allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("template", "metadata", "labels"), spec.Template.Labels, "selector does not match template"))
} }
...@@ -349,10 +349,10 @@ func ValidateJobSpec(spec *extensions.JobSpec, fldPath *validation.FieldPath) va ...@@ -349,10 +349,10 @@ func ValidateJobSpec(spec *extensions.JobSpec, fldPath *validation.FieldPath) va
if spec.Selector == nil { if spec.Selector == nil {
allErrs = append(allErrs, validation.NewRequiredError(fldPath.Child("selector"))) allErrs = append(allErrs, validation.NewRequiredError(fldPath.Child("selector")))
} else { } else {
allErrs = append(allErrs, ValidatePodSelector(spec.Selector, fldPath.Child("selector"))...) allErrs = append(allErrs, ValidateLabelSelector(spec.Selector, fldPath.Child("selector"))...)
} }
if selector, err := extensions.PodSelectorAsSelector(spec.Selector); err == nil { if selector, err := extensions.LabelSelectorAsSelector(spec.Selector); err == nil {
labels := labels.Set(spec.Template.Labels) labels := labels.Set(spec.Template.Labels)
if !selector.Matches(labels) { if !selector.Matches(labels) {
allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("template", "metadata", "labels"), spec.Template.Labels, "selector does not match template")) allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("template", "metadata", "labels"), spec.Template.Labels, "selector does not match template"))
...@@ -567,26 +567,26 @@ func ValidateClusterAutoscaler(autoscaler *extensions.ClusterAutoscaler) validat ...@@ -567,26 +567,26 @@ func ValidateClusterAutoscaler(autoscaler *extensions.ClusterAutoscaler) validat
return allErrs return allErrs
} }
func ValidatePodSelector(ps *extensions.PodSelector, fldPath *validation.FieldPath) validation.ErrorList { func ValidateLabelSelector(ps *extensions.LabelSelector, fldPath *validation.FieldPath) validation.ErrorList {
allErrs := validation.ErrorList{} allErrs := validation.ErrorList{}
if ps == nil { if ps == nil {
return allErrs return allErrs
} }
allErrs = append(allErrs, apivalidation.ValidateLabels(ps.MatchLabels, fldPath.Child("matchLabels"))...) allErrs = append(allErrs, apivalidation.ValidateLabels(ps.MatchLabels, fldPath.Child("matchLabels"))...)
for i, expr := range ps.MatchExpressions { for i, expr := range ps.MatchExpressions {
allErrs = append(allErrs, ValidatePodSelectorRequirement(expr, fldPath.Child("matchExpressions").Index(i))...) allErrs = append(allErrs, ValidateLabelSelectorRequirement(expr, fldPath.Child("matchExpressions").Index(i))...)
} }
return allErrs return allErrs
} }
func ValidatePodSelectorRequirement(sr extensions.PodSelectorRequirement, fldPath *validation.FieldPath) validation.ErrorList { func ValidateLabelSelectorRequirement(sr extensions.LabelSelectorRequirement, fldPath *validation.FieldPath) validation.ErrorList {
allErrs := validation.ErrorList{} allErrs := validation.ErrorList{}
switch sr.Operator { switch sr.Operator {
case extensions.PodSelectorOpIn, extensions.PodSelectorOpNotIn: case extensions.LabelSelectorOpIn, extensions.LabelSelectorOpNotIn:
if len(sr.Values) == 0 { if len(sr.Values) == 0 {
allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("values"), sr.Values, "must be non-empty when operator is In or NotIn")) allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("values"), sr.Values, "must be non-empty when operator is In or NotIn"))
} }
case extensions.PodSelectorOpExists, extensions.PodSelectorOpDoesNotExist: case extensions.LabelSelectorOpExists, extensions.LabelSelectorOpDoesNotExist:
if len(sr.Values) > 0 { if len(sr.Values) > 0 {
allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("values"), sr.Values, "must be empty when operator is Exists or DoesNotExist")) allErrs = append(allErrs, validation.NewInvalidError(fldPath.Child("values"), sr.Values, "must be empty when operator is Exists or DoesNotExist"))
} }
......
...@@ -368,14 +368,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) { ...@@ -368,14 +368,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
...@@ -384,14 +384,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) { ...@@ -384,14 +384,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector2}, Selector: &extensions.LabelSelector{MatchLabels: validSelector2},
Template: &validPodTemplateAbc2.Template, Template: &validPodTemplateAbc2.Template,
}, },
}, },
...@@ -400,14 +400,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) { ...@@ -400,14 +400,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateNodeSelector.Template, Template: &validPodTemplateNodeSelector.Template,
}, },
}, },
...@@ -425,14 +425,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) { ...@@ -425,14 +425,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
...@@ -441,14 +441,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) { ...@@ -441,14 +441,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: invalidSelector}, Selector: &extensions.LabelSelector{MatchLabels: invalidSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
...@@ -457,14 +457,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) { ...@@ -457,14 +457,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &invalidPodTemplate.Template, Template: &invalidPodTemplate.Template,
}, },
}, },
...@@ -473,14 +473,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) { ...@@ -473,14 +473,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateDef.Template, Template: &validPodTemplateDef.Template,
}, },
}, },
...@@ -489,14 +489,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) { ...@@ -489,14 +489,14 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
old: extensions.DaemonSet{ old: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplateAbc.Template, Template: &validPodTemplateAbc.Template,
}, },
}, },
update: extensions.DaemonSet{ update: extensions.DaemonSet{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &readWriteVolumePodTemplate.Template, Template: &readWriteVolumePodTemplate.Template,
}, },
}, },
...@@ -539,14 +539,14 @@ func TestValidateDaemonSet(t *testing.T) { ...@@ -539,14 +539,14 @@ func TestValidateDaemonSet(t *testing.T) {
{ {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
{ {
ObjectMeta: api.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
...@@ -561,14 +561,14 @@ func TestValidateDaemonSet(t *testing.T) { ...@@ -561,14 +561,14 @@ func TestValidateDaemonSet(t *testing.T) {
"zero-length ID": { "zero-length ID": {
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
"missing-namespace": { "missing-namespace": {
ObjectMeta: api.ObjectMeta{Name: "abc-123"}, ObjectMeta: api.ObjectMeta{Name: "abc-123"},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
...@@ -581,14 +581,14 @@ func TestValidateDaemonSet(t *testing.T) { ...@@ -581,14 +581,14 @@ func TestValidateDaemonSet(t *testing.T) {
"selector_doesnt_match": { "selector_doesnt_match": {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: map[string]string{"foo": "bar"}}, Selector: &extensions.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
"invalid manifest": { "invalid manifest": {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault}, ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
}, },
}, },
"invalid_label": { "invalid_label": {
...@@ -600,7 +600,7 @@ func TestValidateDaemonSet(t *testing.T) { ...@@ -600,7 +600,7 @@ func TestValidateDaemonSet(t *testing.T) {
}, },
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
...@@ -625,7 +625,7 @@ func TestValidateDaemonSet(t *testing.T) { ...@@ -625,7 +625,7 @@ func TestValidateDaemonSet(t *testing.T) {
}, },
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &validPodTemplate.Template, Template: &validPodTemplate.Template,
}, },
}, },
...@@ -635,7 +635,7 @@ func TestValidateDaemonSet(t *testing.T) { ...@@ -635,7 +635,7 @@ func TestValidateDaemonSet(t *testing.T) {
Namespace: api.NamespaceDefault, Namespace: api.NamespaceDefault,
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &api.PodTemplateSpec{ Template: &api.PodTemplateSpec{
Spec: api.PodSpec{ Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyOnFailure, RestartPolicy: api.RestartPolicyOnFailure,
...@@ -654,7 +654,7 @@ func TestValidateDaemonSet(t *testing.T) { ...@@ -654,7 +654,7 @@ func TestValidateDaemonSet(t *testing.T) {
Namespace: api.NamespaceDefault, Namespace: api.NamespaceDefault,
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: validSelector}, Selector: &extensions.LabelSelector{MatchLabels: validSelector},
Template: &api.PodTemplateSpec{ Template: &api.PodTemplateSpec{
Spec: api.PodSpec{ Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyNever, RestartPolicy: api.RestartPolicyNever,
...@@ -808,7 +808,7 @@ func TestValidateDeployment(t *testing.T) { ...@@ -808,7 +808,7 @@ func TestValidateDeployment(t *testing.T) {
} }
func TestValidateJob(t *testing.T) { func TestValidateJob(t *testing.T) {
validSelector := &extensions.PodSelector{ validSelector := &extensions.LabelSelector{
MatchLabels: map[string]string{"a": "b"}, MatchLabels: map[string]string{"a": "b"},
} }
validPodTemplateSpec := api.PodTemplateSpec{ validPodTemplateSpec := api.PodTemplateSpec{
......
...@@ -230,7 +230,7 @@ func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []ex ...@@ -230,7 +230,7 @@ func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []ex
if daemonSet.Namespace != pod.Namespace { if daemonSet.Namespace != pod.Namespace {
continue continue
} }
selector, err = extensions.PodSelectorAsSelector(daemonSet.Spec.Selector) selector, err = extensions.LabelSelectorAsSelector(daemonSet.Spec.Selector)
if err != nil { if err != nil {
// this should not happen if the DaemonSet passed validation // this should not happen if the DaemonSet passed validation
return nil, err return nil, err
...@@ -352,7 +352,7 @@ func (s *StoreToJobLister) GetPodJobs(pod *api.Pod) (jobs []extensions.Job, err ...@@ -352,7 +352,7 @@ func (s *StoreToJobLister) GetPodJobs(pod *api.Pod) (jobs []extensions.Job, err
continue continue
} }
selector, _ = extensions.PodSelectorAsSelector(job.Spec.Selector) selector, _ = extensions.LabelSelectorAsSelector(job.Spec.Selector)
if !selector.Matches(labels.Set(pod.Labels)) { if !selector.Matches(labels.Set(pod.Labels)) {
continue continue
} }
......
...@@ -272,7 +272,7 @@ func TestStoreToDaemonSetLister(t *testing.T) { ...@@ -272,7 +272,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
{ {
ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"}, ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: map[string]string{"foo": "baz"}}, Selector: &extensions.LabelSelector{MatchLabels: map[string]string{"foo": "baz"}},
}, },
}, },
}, },
...@@ -311,13 +311,13 @@ func TestStoreToDaemonSetLister(t *testing.T) { ...@@ -311,13 +311,13 @@ func TestStoreToDaemonSetLister(t *testing.T) {
{ {
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: map[string]string{"foo": "bar"}}, Selector: &extensions.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
}, },
}, },
{ {
ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"}, ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"},
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: map[string]string{"foo": "bar"}}, Selector: &extensions.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
}, },
}, },
}, },
...@@ -401,7 +401,7 @@ func TestStoreToJobLister(t *testing.T) { ...@@ -401,7 +401,7 @@ func TestStoreToJobLister(t *testing.T) {
{ {
ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"}, ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"foo": "baz"}, MatchLabels: map[string]string{"foo": "baz"},
}, },
}, },
...@@ -444,7 +444,7 @@ func TestStoreToJobLister(t *testing.T) { ...@@ -444,7 +444,7 @@ func TestStoreToJobLister(t *testing.T) {
{ {
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"}, MatchLabels: map[string]string{"foo": "bar"},
}, },
}, },
...@@ -452,7 +452,7 @@ func TestStoreToJobLister(t *testing.T) { ...@@ -452,7 +452,7 @@ func TestStoreToJobLister(t *testing.T) {
{ {
ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"}, ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"},
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"}, MatchLabels: map[string]string{"foo": "bar"},
}, },
}, },
...@@ -477,7 +477,7 @@ func TestStoreToJobLister(t *testing.T) { ...@@ -477,7 +477,7 @@ func TestStoreToJobLister(t *testing.T) {
{ {
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "foo"},
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"}, MatchLabels: map[string]string{"foo": "bar"},
}, },
}, },
...@@ -485,7 +485,7 @@ func TestStoreToJobLister(t *testing.T) { ...@@ -485,7 +485,7 @@ func TestStoreToJobLister(t *testing.T) {
{ {
ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "bar"}, ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "bar"},
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"}, MatchLabels: map[string]string{"foo": "bar"},
}, },
}, },
......
...@@ -346,7 +346,7 @@ func (dsc *DaemonSetsController) updateNode(old, cur interface{}) { ...@@ -346,7 +346,7 @@ func (dsc *DaemonSetsController) updateNode(old, cur interface{}) {
// getNodesToDaemonSetPods returns a map from nodes to daemon pods (corresponding to ds) running on the nodes. // getNodesToDaemonSetPods returns a map from nodes to daemon pods (corresponding to ds) running on the nodes.
func (dsc *DaemonSetsController) getNodesToDaemonPods(ds *extensions.DaemonSet) (map[string][]*api.Pod, error) { func (dsc *DaemonSetsController) getNodesToDaemonPods(ds *extensions.DaemonSet) (map[string][]*api.Pod, error) {
nodeToDaemonPods := make(map[string][]*api.Pod) nodeToDaemonPods := make(map[string][]*api.Pod)
selector, err := extensions.PodSelectorAsSelector(ds.Spec.Selector) selector, err := extensions.LabelSelectorAsSelector(ds.Spec.Selector)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -55,7 +55,7 @@ func newDaemonSet(name string) *extensions.DaemonSet { ...@@ -55,7 +55,7 @@ func newDaemonSet(name string) *extensions.DaemonSet {
Namespace: api.NamespaceDefault, Namespace: api.NamespaceDefault,
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: simpleDaemonSetLabel}, Selector: &extensions.LabelSelector{MatchLabels: simpleDaemonSetLabel},
Template: &api.PodTemplateSpec{ Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Labels: simpleDaemonSetLabel, Labels: simpleDaemonSetLabel,
......
...@@ -311,7 +311,7 @@ func (jm *JobController) syncJob(key string) error { ...@@ -311,7 +311,7 @@ func (jm *JobController) syncJob(key string) error {
return err return err
} }
jobNeedsSync := jm.expectations.SatisfiedExpectations(jobKey) jobNeedsSync := jm.expectations.SatisfiedExpectations(jobKey)
selector, _ := extensions.PodSelectorAsSelector(job.Spec.Selector) selector, _ := extensions.LabelSelectorAsSelector(job.Spec.Selector)
podList, err := jm.podStore.Pods(job.Namespace).List(selector) podList, err := jm.podStore.Pods(job.Namespace).List(selector)
if err != nil { if err != nil {
glog.Errorf("Error getting pods for job %q: %v", key, err) glog.Errorf("Error getting pods for job %q: %v", key, err)
......
...@@ -43,7 +43,7 @@ func newJob(parallelism, completions int) *extensions.Job { ...@@ -43,7 +43,7 @@ func newJob(parallelism, completions int) *extensions.Job {
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Parallelism: &parallelism, Parallelism: &parallelism,
Completions: &completions, Completions: &completions,
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"}, MatchLabels: map[string]string{"foo": "bar"},
}, },
Template: api.PodTemplateSpec{ Template: api.PodTemplateSpec{
...@@ -291,7 +291,7 @@ func TestJobPodLookup(t *testing.T) { ...@@ -291,7 +291,7 @@ func TestJobPodLookup(t *testing.T) {
job: &extensions.Job{ job: &extensions.Job{
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"}, MatchLabels: map[string]string{"foo": "bar"},
}, },
}, },
...@@ -310,11 +310,11 @@ func TestJobPodLookup(t *testing.T) { ...@@ -310,11 +310,11 @@ func TestJobPodLookup(t *testing.T) {
job: &extensions.Job{ job: &extensions.Job{
ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"}, ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"},
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchExpressions: []extensions.PodSelectorRequirement{ MatchExpressions: []extensions.LabelSelectorRequirement{
{ {
Key: "foo", Key: "foo",
Operator: extensions.PodSelectorOpIn, Operator: extensions.LabelSelectorOpIn,
Values: []string{"bar"}, Values: []string{"bar"},
}, },
}, },
......
...@@ -888,7 +888,7 @@ func describeJob(job *extensions.Job, events *api.EventList) (string, error) { ...@@ -888,7 +888,7 @@ func describeJob(job *extensions.Job, events *api.EventList) (string, error) {
fmt.Fprintf(out, "Name:\t%s\n", job.Name) fmt.Fprintf(out, "Name:\t%s\n", job.Name)
fmt.Fprintf(out, "Namespace:\t%s\n", job.Namespace) fmt.Fprintf(out, "Namespace:\t%s\n", job.Namespace)
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(&job.Spec.Template.Spec)) fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(&job.Spec.Template.Spec))
selector, _ := extensions.PodSelectorAsSelector(job.Spec.Selector) selector, _ := extensions.LabelSelectorAsSelector(job.Spec.Selector)
fmt.Fprintf(out, "Selector:\t%s\n", selector) fmt.Fprintf(out, "Selector:\t%s\n", selector)
fmt.Fprintf(out, "Parallelism:\t%d\n", *job.Spec.Parallelism) fmt.Fprintf(out, "Parallelism:\t%d\n", *job.Spec.Parallelism)
fmt.Fprintf(out, "Completions:\t%d\n", *job.Spec.Completions) fmt.Fprintf(out, "Completions:\t%d\n", *job.Spec.Completions)
...@@ -916,7 +916,7 @@ func (d *DaemonSetDescriber) Describe(namespace, name string) (string, error) { ...@@ -916,7 +916,7 @@ func (d *DaemonSetDescriber) Describe(namespace, name string) (string, error) {
return "", err return "", err
} }
selector, err := extensions.PodSelectorAsSelector(daemon.Spec.Selector) selector, err := extensions.LabelSelectorAsSelector(daemon.Spec.Selector)
if err != nil { if err != nil {
return "", err return "", err
} }
...@@ -938,9 +938,9 @@ func describeDaemonSet(daemon *extensions.DaemonSet, events *api.EventList, runn ...@@ -938,9 +938,9 @@ func describeDaemonSet(daemon *extensions.DaemonSet, events *api.EventList, runn
} else { } else {
fmt.Fprintf(out, "Image(s):\t%s\n", "<no template>") fmt.Fprintf(out, "Image(s):\t%s\n", "<no template>")
} }
selector, err := extensions.PodSelectorAsSelector(daemon.Spec.Selector) selector, err := extensions.LabelSelectorAsSelector(daemon.Spec.Selector)
if err != nil { if err != nil {
// this shouldn't happen if PodSelector passed validation // this shouldn't happen if LabelSelector passed validation
return err return err
} }
fmt.Fprintf(out, "Selector:\t%s\n", selector) fmt.Fprintf(out, "Selector:\t%s\n", selector)
...@@ -1554,7 +1554,7 @@ func getDaemonSetsForLabels(c client.DaemonSetInterface, labelsToMatch labels.La ...@@ -1554,7 +1554,7 @@ func getDaemonSetsForLabels(c client.DaemonSetInterface, labelsToMatch labels.La
// Find the ones that match labelsToMatch. // Find the ones that match labelsToMatch.
var matchingDaemonSets []extensions.DaemonSet var matchingDaemonSets []extensions.DaemonSet
for _, ds := range dss.Items { for _, ds := range dss.Items {
selector, err := extensions.PodSelectorAsSelector(ds.Spec.Selector) selector, err := extensions.LabelSelectorAsSelector(ds.Spec.Selector)
if err != nil { if err != nil {
// this should never happen if the DaemonSet passed validation // this should never happen if the DaemonSet passed validation
return nil, err return nil, err
......
...@@ -730,7 +730,7 @@ func printJob(job *extensions.Job, w io.Writer, withNamespace bool, wide bool, s ...@@ -730,7 +730,7 @@ func printJob(job *extensions.Job, w io.Writer, withNamespace bool, wide bool, s
} }
} }
selector, _ := extensions.PodSelectorAsSelector(job.Spec.Selector) selector, _ := extensions.LabelSelectorAsSelector(job.Spec.Selector)
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d", _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d",
name, name,
firstContainer.Name, firstContainer.Name,
...@@ -931,9 +931,9 @@ func printDaemonSet(ds *extensions.DaemonSet, w io.Writer, withNamespace bool, w ...@@ -931,9 +931,9 @@ func printDaemonSet(ds *extensions.DaemonSet, w io.Writer, withNamespace bool, w
return err return err
} }
} }
selector, err := extensions.PodSelectorAsSelector(ds.Spec.Selector) selector, err := extensions.LabelSelectorAsSelector(ds.Spec.Selector)
if err != nil { if err != nil {
// this shouldn't happen if PodSelector passed validation // this shouldn't happen if LabelSelector passed validation
return err return err
} }
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s", if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s",
......
...@@ -266,7 +266,7 @@ func (JobV1Beta1) Generate(genericParams map[string]interface{}) (runtime.Object ...@@ -266,7 +266,7 @@ func (JobV1Beta1) Generate(genericParams map[string]interface{}) (runtime.Object
Labels: labels, Labels: labels,
}, },
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: labels, MatchLabels: labels,
}, },
Template: api.PodTemplateSpec{ Template: api.PodTemplateSpec{
......
...@@ -746,7 +746,7 @@ func TestGenerateJob(t *testing.T) { ...@@ -746,7 +746,7 @@ func TestGenerateJob(t *testing.T) {
Labels: map[string]string{"foo": "bar", "baz": "blah"}, Labels: map[string]string{"foo": "bar", "baz": "blah"},
}, },
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"foo": "bar", "baz": "blah"}, MatchLabels: map[string]string{"foo": "bar", "baz": "blah"},
}, },
Template: api.PodTemplateSpec{ Template: api.PodTemplateSpec{
......
...@@ -250,7 +250,7 @@ func (reaper *JobReaper) Stop(namespace, name string, timeout time.Duration, gra ...@@ -250,7 +250,7 @@ func (reaper *JobReaper) Stop(namespace, name string, timeout time.Duration, gra
return err return err
} }
// at this point only dead pods are left, that should be removed // at this point only dead pods are left, that should be removed
selector, _ := extensions.PodSelectorAsSelector(job.Spec.Selector) selector, _ := extensions.LabelSelectorAsSelector(job.Spec.Selector)
options := unversioned.ListOptions{LabelSelector: unversioned.LabelSelector{selector}} options := unversioned.ListOptions{LabelSelector: unversioned.LabelSelector{selector}}
podList, err := pods.List(options) podList, err := pods.List(options)
if err != nil { if err != nil {
......
...@@ -284,7 +284,7 @@ func TestJobStop(t *testing.T) { ...@@ -284,7 +284,7 @@ func TestJobStop(t *testing.T) {
}, },
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Parallelism: &zero, Parallelism: &zero,
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"k1": "v1"}, MatchLabels: map[string]string{"k1": "v1"},
}, },
}, },
...@@ -298,7 +298,7 @@ func TestJobStop(t *testing.T) { ...@@ -298,7 +298,7 @@ func TestJobStop(t *testing.T) {
}, },
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Parallelism: &zero, Parallelism: &zero,
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"k1": "v1"}, MatchLabels: map[string]string{"k1": "v1"},
}, },
}, },
...@@ -320,7 +320,7 @@ func TestJobStop(t *testing.T) { ...@@ -320,7 +320,7 @@ func TestJobStop(t *testing.T) {
}, },
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Parallelism: &zero, Parallelism: &zero,
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"k1": "v1"}, MatchLabels: map[string]string{"k1": "v1"},
}, },
}, },
...@@ -334,7 +334,7 @@ func TestJobStop(t *testing.T) { ...@@ -334,7 +334,7 @@ func TestJobStop(t *testing.T) {
}, },
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Parallelism: &zero, Parallelism: &zero,
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"k1": "v1"}, MatchLabels: map[string]string{"k1": "v1"},
}, },
}, },
......
...@@ -42,7 +42,7 @@ func newValidDaemonSet() *extensions.DaemonSet { ...@@ -42,7 +42,7 @@ func newValidDaemonSet() *extensions.DaemonSet {
Namespace: api.NamespaceDefault, Namespace: api.NamespaceDefault,
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: map[string]string{"a": "b"}}, Selector: &extensions.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
Template: &api.PodTemplateSpec{ Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Labels: map[string]string{"a": "b"}, Labels: map[string]string{"a": "b"},
...@@ -77,7 +77,7 @@ func TestCreate(t *testing.T) { ...@@ -77,7 +77,7 @@ func TestCreate(t *testing.T) {
// invalid (invalid selector) // invalid (invalid selector)
&extensions.DaemonSet{ &extensions.DaemonSet{
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: map[string]string{}}, Selector: &extensions.LabelSelector{MatchLabels: map[string]string{}},
Template: validDaemonSet.Spec.Template, Template: validDaemonSet.Spec.Template,
}, },
}, },
...@@ -115,7 +115,7 @@ func TestUpdate(t *testing.T) { ...@@ -115,7 +115,7 @@ func TestUpdate(t *testing.T) {
}, },
func(obj runtime.Object) runtime.Object { func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.DaemonSet) object := obj.(*extensions.DaemonSet)
object.Spec.Selector = &extensions.PodSelector{MatchLabels: map[string]string{}} object.Spec.Selector = &extensions.LabelSelector{MatchLabels: map[string]string{}}
return object return object
}, },
) )
......
...@@ -48,7 +48,7 @@ func validNewJob() *extensions.Job { ...@@ -48,7 +48,7 @@ func validNewJob() *extensions.Job {
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Completions: &completions, Completions: &completions,
Parallelism: &parallelism, Parallelism: &parallelism,
Selector: &extensions.PodSelector{ Selector: &extensions.LabelSelector{
MatchLabels: map[string]string{"a": "b"}, MatchLabels: map[string]string{"a": "b"},
}, },
Template: api.PodTemplateSpec{ Template: api.PodTemplateSpec{
...@@ -84,7 +84,7 @@ func TestCreate(t *testing.T) { ...@@ -84,7 +84,7 @@ func TestCreate(t *testing.T) {
&extensions.Job{ &extensions.Job{
Spec: extensions.JobSpec{ Spec: extensions.JobSpec{
Completions: validJob.Spec.Completions, Completions: validJob.Spec.Completions,
Selector: &extensions.PodSelector{}, Selector: &extensions.LabelSelector{},
Template: validJob.Spec.Template, Template: validJob.Spec.Template,
}, },
}, },
...@@ -108,7 +108,7 @@ func TestUpdate(t *testing.T) { ...@@ -108,7 +108,7 @@ func TestUpdate(t *testing.T) {
// invalid updateFunc // invalid updateFunc
func(obj runtime.Object) runtime.Object { func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.Job) object := obj.(*extensions.Job)
object.Spec.Selector = &extensions.PodSelector{} object.Spec.Selector = &extensions.LabelSelector{}
return object return object
}, },
func(obj runtime.Object) runtime.Object { func(obj runtime.Object) runtime.Object {
......
...@@ -32,7 +32,7 @@ func TestJobStrategy(t *testing.T) { ...@@ -32,7 +32,7 @@ func TestJobStrategy(t *testing.T) {
t.Errorf("Job should not allow create on update") t.Errorf("Job should not allow create on update")
} }
validSelector := &extensions.PodSelector{ validSelector := &extensions.LabelSelector{
MatchLabels: map[string]string{"a": "b"}, MatchLabels: map[string]string{"a": "b"},
} }
validPodTemplateSpec := api.PodTemplateSpec{ validPodTemplateSpec := api.PodTemplateSpec{
...@@ -97,7 +97,7 @@ func TestJobStatusStrategy(t *testing.T) { ...@@ -97,7 +97,7 @@ func TestJobStatusStrategy(t *testing.T) {
if StatusStrategy.AllowCreateOnUpdate() { if StatusStrategy.AllowCreateOnUpdate() {
t.Errorf("Job should not allow create on update") t.Errorf("Job should not allow create on update")
} }
validSelector := &extensions.PodSelector{ validSelector := &extensions.LabelSelector{
MatchLabels: map[string]string{"a": "b"}, MatchLabels: map[string]string{"a": "b"},
} }
validPodTemplateSpec := api.PodTemplateSpec{ validPodTemplateSpec := api.PodTemplateSpec{
......
...@@ -135,7 +135,7 @@ var _ = Describe("Daemon set", func() { ...@@ -135,7 +135,7 @@ var _ = Describe("Daemon set", func() {
Name: dsName, Name: dsName,
}, },
Spec: extensions.DaemonSetSpec{ Spec: extensions.DaemonSetSpec{
Selector: &extensions.PodSelector{MatchLabels: complexLabel}, Selector: &extensions.LabelSelector{MatchLabels: complexLabel},
Template: &api.PodTemplateSpec{ Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Labels: complexLabel, Labels: complexLabel,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment