From 1931931494518d5b60f61435a77fa39189546c00 Mon Sep 17 00:00:00 2001 From: Avesh Agarwal Date: Mon, 23 May 2016 18:08:22 -0400 Subject: [PATCH] Downward API implementation for resources limits and requests --- api/swagger-spec/apps_v1alpha1.json | 32 +- api/swagger-spec/batch_v1.json | 32 +- api/swagger-spec/extensions_v1beta1.json | 32 +- api/swagger-spec/v1.json | 32 +- docs/api-reference/batch/v1/definitions.html | 66 +- .../extensions/v1beta1/definitions.html | 148 +- docs/api-reference/v1/definitions.html | 66 +- pkg/api/deep_copy_generated.go | 38 +- pkg/api/testing/fuzzer.go | 1 + pkg/api/types.generated.go | 551 +++++++- pkg/api/types.go | 18 +- pkg/api/v1/conversion_generated.go | 84 +- pkg/api/v1/deep_copy_generated.go | 38 +- pkg/api/v1/generated.pb.go | 1235 ++++++++++------- pkg/api/v1/generated.proto | 24 +- pkg/api/v1/types.generated.go | 551 +++++++- pkg/api/v1/types.go | 22 +- pkg/api/v1/types_swagger_doc_generated.go | 27 +- pkg/api/validation/validation.go | 52 +- pkg/api/validation/validation_test.go | 51 +- pkg/fieldpath/fieldpath.go | 62 + pkg/kubectl/describe.go | 13 +- pkg/kubelet/kubelet.go | 15 + pkg/volume/downwardapi/downwardapi.go | 37 +- pkg/volume/downwardapi/downwardapi_test.go | 18 +- test/e2e/downward_api.go | 60 +- test/e2e/downwardapi_volume.go | 106 +- 27 files changed, 2686 insertions(+), 725 deletions(-) diff --git a/api/swagger-spec/apps_v1alpha1.json b/api/swagger-spec/apps_v1alpha1.json index 1077951cc27..26a5211c56b 100644 --- a/api/swagger-spec/apps_v1alpha1.json +++ b/api/swagger-spec/apps_v1alpha1.json @@ -1709,8 +1709,7 @@ "id": "v1.DownwardAPIVolumeFile", "description": "DownwardAPIVolumeFile represents information to create the file containing the pod field", "required": [ - "path", - "fieldRef" + "path" ], "properties": { "path": { @@ -1720,6 +1719,10 @@ "fieldRef": { "$ref": "v1.ObjectFieldSelector", "description": "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported." + }, + "resourceFieldRef": { + "$ref": "v1.ResourceFieldSelector", + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported." } } }, @@ -1740,6 +1743,27 @@ } } }, + "v1.ResourceFieldSelector": { + "id": "v1.ResourceFieldSelector", + "description": "ResourceFieldSelector represents container resources (cpu, memory) and their output format", + "required": [ + "resource" + ], + "properties": { + "containerName": { + "type": "string", + "description": "Container name: required for volumes, optional for env vars" + }, + "resource": { + "type": "string", + "description": "Required: resource to select" + }, + "divisor": { + "type": "string", + "description": "Specifies the output format of the exposed resources, defaults to \"1\"" + } + } + }, "v1.FCVolumeSource": { "id": "v1.FCVolumeSource", "description": "Represents a Fibre Channel volume. Fibre Channel volumes can only be mounted as read/write once. Fibre Channel volumes support ownership management and SELinux relabeling.", @@ -1982,6 +2006,10 @@ "$ref": "v1.ObjectFieldSelector", "description": "Selects a field of the pod; only name and namespace are supported." }, + "resourceFieldRef": { + "$ref": "v1.ResourceFieldSelector", + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported." + }, "configMapKeyRef": { "$ref": "v1.ConfigMapKeySelector", "description": "Selects a key of a ConfigMap." diff --git a/api/swagger-spec/batch_v1.json b/api/swagger-spec/batch_v1.json index bd8f0e5cf74..82ed612f06f 100644 --- a/api/swagger-spec/batch_v1.json +++ b/api/swagger-spec/batch_v1.json @@ -1714,8 +1714,7 @@ "id": "v1.DownwardAPIVolumeFile", "description": "DownwardAPIVolumeFile represents information to create the file containing the pod field", "required": [ - "path", - "fieldRef" + "path" ], "properties": { "path": { @@ -1725,6 +1724,10 @@ "fieldRef": { "$ref": "v1.ObjectFieldSelector", "description": "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported." + }, + "resourceFieldRef": { + "$ref": "v1.ResourceFieldSelector", + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported." } } }, @@ -1745,6 +1748,27 @@ } } }, + "v1.ResourceFieldSelector": { + "id": "v1.ResourceFieldSelector", + "description": "ResourceFieldSelector represents container resources (cpu, memory) and their output format", + "required": [ + "resource" + ], + "properties": { + "containerName": { + "type": "string", + "description": "Container name: required for volumes, optional for env vars" + }, + "resource": { + "type": "string", + "description": "Required: resource to select" + }, + "divisor": { + "type": "string", + "description": "Specifies the output format of the exposed resources, defaults to \"1\"" + } + } + }, "v1.FCVolumeSource": { "id": "v1.FCVolumeSource", "description": "Represents a Fibre Channel volume. Fibre Channel volumes can only be mounted as read/write once. Fibre Channel volumes support ownership management and SELinux relabeling.", @@ -1987,6 +2011,10 @@ "$ref": "v1.ObjectFieldSelector", "description": "Selects a field of the pod; only name and namespace are supported." }, + "resourceFieldRef": { + "$ref": "v1.ResourceFieldSelector", + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported." + }, "configMapKeyRef": { "$ref": "v1.ConfigMapKeySelector", "description": "Selects a key of a ConfigMap." diff --git a/api/swagger-spec/extensions_v1beta1.json b/api/swagger-spec/extensions_v1beta1.json index 6a4915f1773..4a4e3e9c830 100644 --- a/api/swagger-spec/extensions_v1beta1.json +++ b/api/swagger-spec/extensions_v1beta1.json @@ -7021,8 +7021,7 @@ "id": "v1.DownwardAPIVolumeFile", "description": "DownwardAPIVolumeFile represents information to create the file containing the pod field", "required": [ - "path", - "fieldRef" + "path" ], "properties": { "path": { @@ -7032,6 +7031,10 @@ "fieldRef": { "$ref": "v1.ObjectFieldSelector", "description": "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported." + }, + "resourceFieldRef": { + "$ref": "v1.ResourceFieldSelector", + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported." } } }, @@ -7052,6 +7055,27 @@ } } }, + "v1.ResourceFieldSelector": { + "id": "v1.ResourceFieldSelector", + "description": "ResourceFieldSelector represents container resources (cpu, memory) and their output format", + "required": [ + "resource" + ], + "properties": { + "containerName": { + "type": "string", + "description": "Container name: required for volumes, optional for env vars" + }, + "resource": { + "type": "string", + "description": "Required: resource to select" + }, + "divisor": { + "type": "string", + "description": "Specifies the output format of the exposed resources, defaults to \"1\"" + } + } + }, "v1.FCVolumeSource": { "id": "v1.FCVolumeSource", "description": "Represents a Fibre Channel volume. Fibre Channel volumes can only be mounted as read/write once. Fibre Channel volumes support ownership management and SELinux relabeling.", @@ -7294,6 +7318,10 @@ "$ref": "v1.ObjectFieldSelector", "description": "Selects a field of the pod; only name and namespace are supported." }, + "resourceFieldRef": { + "$ref": "v1.ResourceFieldSelector", + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported." + }, "configMapKeyRef": { "$ref": "v1.ConfigMapKeySelector", "description": "Selects a key of a ConfigMap." diff --git a/api/swagger-spec/v1.json b/api/swagger-spec/v1.json index d29448bfde4..cdd51058fc5 100644 --- a/api/swagger-spec/v1.json +++ b/api/swagger-spec/v1.json @@ -17105,8 +17105,7 @@ "id": "v1.DownwardAPIVolumeFile", "description": "DownwardAPIVolumeFile represents information to create the file containing the pod field", "required": [ - "path", - "fieldRef" + "path" ], "properties": { "path": { @@ -17116,6 +17115,10 @@ "fieldRef": { "$ref": "v1.ObjectFieldSelector", "description": "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported." + }, + "resourceFieldRef": { + "$ref": "v1.ResourceFieldSelector", + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported." } } }, @@ -17136,6 +17139,27 @@ } } }, + "v1.ResourceFieldSelector": { + "id": "v1.ResourceFieldSelector", + "description": "ResourceFieldSelector represents container resources (cpu, memory) and their output format", + "required": [ + "resource" + ], + "properties": { + "containerName": { + "type": "string", + "description": "Container name: required for volumes, optional for env vars" + }, + "resource": { + "type": "string", + "description": "Required: resource to select" + }, + "divisor": { + "type": "string", + "description": "Specifies the output format of the exposed resources, defaults to \"1\"" + } + } + }, "v1.ConfigMapVolumeSource": { "id": "v1.ConfigMapVolumeSource", "description": "Adapts a ConfigMap into a volume.\n\nThe contents of the target ConfigMap's Data field will be presented in a volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. ConfigMap volumes support ownership management and SELinux relabeling.", @@ -17309,6 +17333,10 @@ "$ref": "v1.ObjectFieldSelector", "description": "Selects a field of the pod; only name and namespace are supported." }, + "resourceFieldRef": { + "$ref": "v1.ResourceFieldSelector", + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported." + }, "configMapKeyRef": { "$ref": "v1.ConfigMapKeySelector", "description": "Selects a key of a ConfigMap." diff --git a/docs/api-reference/batch/v1/definitions.html b/docs/api-reference/batch/v1/definitions.html index 8dc608dff71..ae27256e332 100755 --- a/docs/api-reference/batch/v1/definitions.html +++ b/docs/api-reference/batch/v1/definitions.html @@ -2754,6 +2754,13 @@ Populated by the system when a graceful deletion is requested. Read-only. More i +

resourceFieldRef

+

Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.

+

false

+

v1.ResourceFieldSelector

+ + +

configMapKeyRef

Selects a key of a ConfigMap.

false

@@ -3198,6 +3205,54 @@ Populated by the system when a graceful deletion is requested. Read-only. More i + +
+

v1.ResourceFieldSelector

+
+

ResourceFieldSelector represents container resources (cpu, memory) and their output format

+
+ +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionRequiredSchemaDefault

containerName

Container name: required for volumes, optional for env vars

false

string

resource

Required: resource to select

true

string

divisor

Specifies the output format of the exposed resources, defaults to "1"

false

string

+

v1.Probe

@@ -3546,10 +3601,17 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

fieldRef

Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.

-

true

+

false

v1.ObjectFieldSelector

+ +

resourceFieldRef

+

Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.

+

false

+

v1.ResourceFieldSelector

+ + @@ -4034,7 +4096,7 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
diff --git a/docs/api-reference/extensions/v1beta1/definitions.html b/docs/api-reference/extensions/v1beta1/definitions.html index a2f025c191e..28b4cd3e876 100755 --- a/docs/api-reference/extensions/v1beta1/definitions.html +++ b/docs/api-reference/extensions/v1beta1/definitions.html @@ -1342,47 +1342,6 @@ Examples:

*versioned.Event

-
-
-

v1.Capabilities

-
-

Adds and removes POSIX capabilities from running containers.

-
- ------- - - - - - - - - - - - - - - - - - - - - - - - - - -
NameDescriptionRequiredSchemaDefault

add

Added capabilities

false

v1.Capability array

drop

Removed capabilities

false

v1.Capability array

-

v1beta1.JobStatus

@@ -1452,6 +1411,47 @@ Examples:
+
+
+

v1.Capabilities

+
+

Adds and removes POSIX capabilities from running containers.

+
+ +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionRequiredSchemaDefault

add

Added capabilities

false

v1.Capability array

drop

Removed capabilities

false

v1.Capability array

+

v1.LocalObjectReference

@@ -2345,6 +2345,13 @@ Populated by the system when a graceful deletion is requested. Read-only. More i +

resourceFieldRef

+

Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.

+

false

+

v1.ResourceFieldSelector

+ + +

configMapKeyRef

Selects a key of a ConfigMap.

false

@@ -2940,6 +2947,54 @@ Populated by the system when a graceful deletion is requested. Read-only. More i +
+
+

v1.ResourceFieldSelector

+
+

ResourceFieldSelector represents container resources (cpu, memory) and their output format

+
+ +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionRequiredSchemaDefault

containerName

Container name: required for volumes, optional for env vars

false

string

resource

Required: resource to select

true

string

divisor

Specifies the output format of the exposed resources, defaults to "1"

false

string

+

v1.Probe

@@ -3288,10 +3343,17 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

fieldRef

Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.

-

true

+

false

v1.ObjectFieldSelector

+ +

resourceFieldRef

+

Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.

+

false

+

v1.ResourceFieldSelector

+ + @@ -6024,7 +6086,7 @@ Both these may change in the future. Incoming requests are matched against the h
diff --git a/docs/api-reference/v1/definitions.html b/docs/api-reference/v1/definitions.html index 9a1efc126e7..b2d1b491849 100755 --- a/docs/api-reference/v1/definitions.html +++ b/docs/api-reference/v1/definitions.html @@ -2952,6 +2952,13 @@ The resulting set of endpoints can be viewed as:
+

resourceFieldRef

+

Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.

+

false

+

v1.ResourceFieldSelector

+ + +

configMapKeyRef

Selects a key of a ConfigMap.

false

@@ -3627,6 +3634,54 @@ The resulting set of endpoints can be viewed as:
+ +
+

v1.ResourceFieldSelector

+
+

ResourceFieldSelector represents container resources (cpu, memory) and their output format

+
+ +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionRequiredSchemaDefault

containerName

Container name: required for volumes, optional for env vars

false

string

resource

Required: resource to select

true

string

divisor

Specifies the output format of the exposed resources, defaults to "1"

false

string

+

v1.Probe

@@ -4092,10 +4147,17 @@ The resulting set of endpoints can be viewed as:

fieldRef

Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.

-

true

+

false

v1.ObjectFieldSelector

+ +

resourceFieldRef

+

Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.

+

false

+

v1.ResourceFieldSelector

+ + @@ -7922,7 +7984,7 @@ The resulting set of endpoints can be viewed as:
diff --git a/pkg/api/deep_copy_generated.go b/pkg/api/deep_copy_generated.go index 013e59d256b..e07dc76ebbf 100644 --- a/pkg/api/deep_copy_generated.go +++ b/pkg/api/deep_copy_generated.go @@ -154,6 +154,7 @@ func init() { DeepCopy_api_ReplicationControllerList, DeepCopy_api_ReplicationControllerSpec, DeepCopy_api_ReplicationControllerStatus, + DeepCopy_api_ResourceFieldSelector, DeepCopy_api_ResourceQuota, DeepCopy_api_ResourceQuotaList, DeepCopy_api_ResourceQuotaSpec, @@ -666,8 +667,23 @@ func DeepCopy_api_DeleteOptions(in DeleteOptions, out *DeleteOptions, c *convers func DeepCopy_api_DownwardAPIVolumeFile(in DownwardAPIVolumeFile, out *DownwardAPIVolumeFile, c *conversion.Cloner) error { out.Path = in.Path - if err := DeepCopy_api_ObjectFieldSelector(in.FieldRef, &out.FieldRef, c); err != nil { - return err + if in.FieldRef != nil { + in, out := in.FieldRef, &out.FieldRef + *out = new(ObjectFieldSelector) + if err := DeepCopy_api_ObjectFieldSelector(*in, *out, c); err != nil { + return err + } + } else { + out.FieldRef = nil + } + if in.ResourceFieldRef != nil { + in, out := in.ResourceFieldRef, &out.ResourceFieldRef + *out = new(ResourceFieldSelector) + if err := DeepCopy_api_ResourceFieldSelector(*in, *out, c); err != nil { + return err + } + } else { + out.ResourceFieldRef = nil } return nil } @@ -818,6 +834,15 @@ func DeepCopy_api_EnvVarSource(in EnvVarSource, out *EnvVarSource, c *conversion } else { out.FieldRef = nil } + if in.ResourceFieldRef != nil { + in, out := in.ResourceFieldRef, &out.ResourceFieldRef + *out = new(ResourceFieldSelector) + if err := DeepCopy_api_ResourceFieldSelector(*in, *out, c); err != nil { + return err + } + } else { + out.ResourceFieldRef = nil + } if in.ConfigMapKeyRef != nil { in, out := in.ConfigMapKeyRef, &out.ConfigMapKeyRef *out = new(ConfigMapKeySelector) @@ -2572,6 +2597,15 @@ func DeepCopy_api_ReplicationControllerStatus(in ReplicationControllerStatus, ou return nil } +func DeepCopy_api_ResourceFieldSelector(in ResourceFieldSelector, out *ResourceFieldSelector, c *conversion.Cloner) error { + out.ContainerName = in.ContainerName + out.Resource = in.Resource + if err := resource.DeepCopy_resource_Quantity(in.Divisor, &out.Divisor, c); err != nil { + return err + } + return nil +} + func DeepCopy_api_ResourceQuota(in ResourceQuota, out *ResourceQuota, c *conversion.Cloner) error { if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { return err diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index 0195b47cc96..2b88e50f97e 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -243,6 +243,7 @@ func FuzzerFor(t *testing.T, version unversioned.GroupVersion, src rand.Source) func(m *api.DownwardAPIVolumeFile, c fuzz.Continue) { m.Path = c.RandString() versions := []string{"v1"} + m.FieldRef = &api.ObjectFieldSelector{} m.FieldRef.APIVersion = versions[c.Rand.Intn(len(versions))] m.FieldRef.FieldPath = c.RandString() }, diff --git a/pkg/api/types.generated.go b/pkg/api/types.generated.go index 77c65ff8c7e..c7fcf4b12b6 100644 --- a/pkg/api/types.generated.go +++ b/pkg/api/types.generated.go @@ -13445,14 +13445,16 @@ func (x *DownwardAPIVolumeFile) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [2]bool + var yyq2 [3]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false + yyq2[1] = x.FieldRef != nil + yyq2[2] = x.ResourceFieldRef != nil var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(2) + r.EncodeArrayStart(3) } else { - yynn2 = 2 + yynn2 = 1 for _, b := range yyq2 { if b { yynn2++ @@ -13482,14 +13484,49 @@ func (x *DownwardAPIVolumeFile) CodecEncodeSelf(e *codec1978.Encoder) { } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy7 := &x.FieldRef - yy7.CodecEncodeSelf(e) + if yyq2[1] { + if x.FieldRef == nil { + r.EncodeNil() + } else { + x.FieldRef.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } } else { - z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("fieldRef")) - z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy9 := &x.FieldRef - yy9.CodecEncodeSelf(e) + if yyq2[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("fieldRef")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.FieldRef == nil { + r.EncodeNil() + } else { + x.FieldRef.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[2] { + if x.ResourceFieldRef == nil { + r.EncodeNil() + } else { + x.ResourceFieldRef.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[2] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("resourceFieldRef")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.ResourceFieldRef == nil { + r.EncodeNil() + } else { + x.ResourceFieldRef.CodecEncodeSelf(e) + } + } } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) @@ -13560,10 +13597,25 @@ func (x *DownwardAPIVolumeFile) codecDecodeSelfFromMap(l int, d *codec1978.Decod } case "fieldRef": if r.TryDecodeAsNil() { - x.FieldRef = ObjectFieldSelector{} + if x.FieldRef != nil { + x.FieldRef = nil + } } else { - yyv5 := &x.FieldRef - yyv5.CodecDecodeSelf(d) + if x.FieldRef == nil { + x.FieldRef = new(ObjectFieldSelector) + } + x.FieldRef.CodecDecodeSelf(d) + } + case "resourceFieldRef": + if r.TryDecodeAsNil() { + if x.ResourceFieldRef != nil { + x.ResourceFieldRef = nil + } + } else { + if x.ResourceFieldRef == nil { + x.ResourceFieldRef = new(ResourceFieldSelector) + } + x.ResourceFieldRef.CodecDecodeSelf(d) } default: z.DecStructFieldNotFound(-1, yys3) @@ -13576,16 +13628,16 @@ func (x *DownwardAPIVolumeFile) codecDecodeSelfFromArray(l int, d *codec1978.Dec var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l + var yyj7 int + var yyb7 bool + var yyhl7 bool = l >= 0 + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb6 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb6 { + if yyb7 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -13595,35 +13647,60 @@ func (x *DownwardAPIVolumeFile) codecDecodeSelfFromArray(l int, d *codec1978.Dec } else { x.Path = string(r.DecodeString()) } - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb6 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb6 { + if yyb7 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } z.DecSendContainerState(codecSelfer_containerArrayElem1234) if r.TryDecodeAsNil() { - x.FieldRef = ObjectFieldSelector{} + if x.FieldRef != nil { + x.FieldRef = nil + } } else { - yyv8 := &x.FieldRef - yyv8.CodecDecodeSelf(d) + if x.FieldRef == nil { + x.FieldRef = new(ObjectFieldSelector) + } + x.FieldRef.CodecDecodeSelf(d) + } + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.ResourceFieldRef != nil { + x.ResourceFieldRef = nil + } + } else { + if x.ResourceFieldRef == nil { + x.ResourceFieldRef = new(ResourceFieldSelector) + } + x.ResourceFieldRef.CodecDecodeSelf(d) } for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb6 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb6 { + if yyb7 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj6-1, "") + z.DecStructFieldNotFound(yyj7-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -15445,15 +15522,16 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [3]bool + var yyq2 [4]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false yyq2[0] = x.FieldRef != nil - yyq2[1] = x.ConfigMapKeyRef != nil - yyq2[2] = x.SecretKeyRef != nil + yyq2[1] = x.ResourceFieldRef != nil + yyq2[2] = x.ConfigMapKeyRef != nil + yyq2[3] = x.SecretKeyRef != nil var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(3) + r.EncodeArrayStart(4) } else { yynn2 = 0 for _, b := range yyq2 { @@ -15490,6 +15568,29 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) if yyq2[1] { + if x.ResourceFieldRef == nil { + r.EncodeNil() + } else { + x.ResourceFieldRef.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("resourceFieldRef")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.ResourceFieldRef == nil { + r.EncodeNil() + } else { + x.ResourceFieldRef.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[2] { if x.ConfigMapKeyRef == nil { r.EncodeNil() } else { @@ -15499,7 +15600,7 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeNil() } } else { - if yyq2[1] { + if yyq2[2] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("configMapKeyRef")) z.EncSendContainerState(codecSelfer_containerMapValue1234) @@ -15512,7 +15613,7 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq2[2] { + if yyq2[3] { if x.SecretKeyRef == nil { r.EncodeNil() } else { @@ -15522,7 +15623,7 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeNil() } } else { - if yyq2[2] { + if yyq2[3] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("secretKeyRef")) z.EncSendContainerState(codecSelfer_containerMapValue1234) @@ -15605,6 +15706,17 @@ func (x *EnvVarSource) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { } x.FieldRef.CodecDecodeSelf(d) } + case "resourceFieldRef": + if r.TryDecodeAsNil() { + if x.ResourceFieldRef != nil { + x.ResourceFieldRef = nil + } + } else { + if x.ResourceFieldRef == nil { + x.ResourceFieldRef = new(ResourceFieldSelector) + } + x.ResourceFieldRef.CodecDecodeSelf(d) + } case "configMapKeyRef": if r.TryDecodeAsNil() { if x.ConfigMapKeyRef != nil { @@ -15638,16 +15750,16 @@ func (x *EnvVarSource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj7 int - var yyb7 bool - var yyhl7 bool = l >= 0 - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l } else { - yyb7 = r.CheckBreak() + yyb8 = r.CheckBreak() } - if yyb7 { + if yyb8 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -15662,13 +15774,34 @@ func (x *EnvVarSource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.FieldRef.CodecDecodeSelf(d) } - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l } else { - yyb7 = r.CheckBreak() + yyb8 = r.CheckBreak() } - if yyb7 { + if yyb8 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.ResourceFieldRef != nil { + x.ResourceFieldRef = nil + } + } else { + if x.ResourceFieldRef == nil { + x.ResourceFieldRef = new(ResourceFieldSelector) + } + x.ResourceFieldRef.CodecDecodeSelf(d) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -15683,13 +15816,13 @@ func (x *EnvVarSource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.ConfigMapKeyRef.CodecDecodeSelf(d) } - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l } else { - yyb7 = r.CheckBreak() + yyb8 = r.CheckBreak() } - if yyb7 { + if yyb8 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -15705,17 +15838,17 @@ func (x *EnvVarSource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { x.SecretKeyRef.CodecDecodeSelf(d) } for { - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l } else { - yyb7 = r.CheckBreak() + yyb8 = r.CheckBreak() } - if yyb7 { + if yyb8 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj7-1, "") + z.DecStructFieldNotFound(yyj8-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -15923,6 +16056,290 @@ func (x *ObjectFieldSelector) codecDecodeSelfFromArray(l int, d *codec1978.Decod z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } +func (x *ResourceFieldSelector) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + var yyq2 [3]bool + _, _, _ = yysep2, yyq2, yy2arr2 + const yyr2 bool = false + yyq2[0] = x.ContainerName != "" + yyq2[2] = true + var yynn2 int + if yyr2 || yy2arr2 { + r.EncodeArrayStart(3) + } else { + yynn2 = 1 + for _, b := range yyq2 { + if b { + yynn2++ + } + } + r.EncodeMapStart(yynn2) + yynn2 = 0 + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[0] { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.ContainerName)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("containerName")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.ContainerName)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Resource)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("resource")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Resource)) + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[2] { + yy10 := &x.Divisor + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(yy10) { + } else if !yym11 && z.IsJSONHandle() { + z.EncJSONMarshal(yy10) + } else { + z.EncFallback(yy10) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[2] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("divisor")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy12 := &x.Divisor + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(yy12) { + } else if !yym13 && z.IsJSONHandle() { + z.EncJSONMarshal(yy12) + } else { + z.EncFallback(yy12) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *ResourceFieldSelector) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap1234 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray1234 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *ResourceFieldSelector) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys3Slc = r.DecodeBytes(yys3Slc, true, true) + yys3 := string(yys3Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys3 { + case "containerName": + if r.TryDecodeAsNil() { + x.ContainerName = "" + } else { + x.ContainerName = string(r.DecodeString()) + } + case "resource": + if r.TryDecodeAsNil() { + x.Resource = "" + } else { + x.Resource = string(r.DecodeString()) + } + case "divisor": + if r.TryDecodeAsNil() { + x.Divisor = pkg3_resource.Quantity{} + } else { + yyv6 := &x.Divisor + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else if !yym7 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv6) + } else { + z.DecFallback(yyv6, false) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *ResourceFieldSelector) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.ContainerName = "" + } else { + x.ContainerName = string(r.DecodeString()) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Resource = "" + } else { + x.Resource = string(r.DecodeString()) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Divisor = pkg3_resource.Quantity{} + } else { + yyv11 := &x.Divisor + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else if !yym12 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv11) + } else { + z.DecFallback(yyv11, false) + } + } + for { + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj8-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + func (x *ConfigMapKeySelector) CodecEncodeSelf(e *codec1978.Encoder) { var h codecSelfer1234 z, r := codec1978.GenHelperEncoder(e) @@ -52961,7 +53378,7 @@ func (x codecSelfer1234) decSliceDownwardAPIVolumeFile(v *[]DownwardAPIVolumeFil yyrg1 := len(yyv1) > 0 yyv21 := yyv1 - yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 48) + yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 32) if yyrt1 { if yyrl1 <= cap(yyv1) { yyv1 = yyv1[:yyrl1] diff --git a/pkg/api/types.go b/pkg/api/types.go index a536c5b6686..96d187d9cfc 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -706,7 +706,10 @@ type DownwardAPIVolumeFile struct { // Required: Path is the relative path name of the file to be created. Must not be absolute or contain the '..' path. Must be utf-8 encoded. The first item of the relative path must not start with '..' Path string `json:"path"` // Required: Selects a field of the pod: only annotations, labels, name and namespace are supported. - FieldRef ObjectFieldSelector `json:"fieldRef"` + FieldRef *ObjectFieldSelector `json:"fieldRef,omitempty"` + // Selects a resource of the container: only resources limits and requests + // (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported. + ResourceFieldRef *ResourceFieldSelector `json:"resourceFieldRef,omitempty"` } // AzureFile represents an Azure File Service mount on the host and bind mount to the pod. @@ -811,6 +814,9 @@ type EnvVar struct { type EnvVarSource struct { // Selects a field of the pod; only name and namespace are supported. FieldRef *ObjectFieldSelector `json:"fieldRef,omitempty"` + // Selects a resource of the container: only resources limits and requests + // (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported. + ResourceFieldRef *ResourceFieldSelector `json:"resourceFieldRef,omitempty"` // Selects a key of a ConfigMap. ConfigMapKeyRef *ConfigMapKeySelector `json:"configMapKeyRef,omitempty"` // Selects a key of a secret in the pod's namespace. @@ -827,6 +833,16 @@ type ObjectFieldSelector struct { FieldPath string `json:"fieldPath"` } +// ResourceFieldSelector represents container resources (cpu, memory) and their output format +type ResourceFieldSelector struct { + // Container name: required for volumes, optional for env vars + ContainerName string `json:"containerName,omitempty"` + // Required: resource to select + Resource string `json:"resource"` + // Specifies the output format of the exposed resources, defaults to "1" + Divisor resource.Quantity `json:"divisor,omitempty"` +} + // Selects a key from a ConfigMap. type ConfigMapKeySelector struct { // The ConfigMap to select from. diff --git a/pkg/api/v1/conversion_generated.go b/pkg/api/v1/conversion_generated.go index 74e1fb4eb3c..d054c939c04 100644 --- a/pkg/api/v1/conversion_generated.go +++ b/pkg/api/v1/conversion_generated.go @@ -269,6 +269,8 @@ func init() { Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec, Convert_v1_ReplicationControllerStatus_To_api_ReplicationControllerStatus, Convert_api_ReplicationControllerStatus_To_v1_ReplicationControllerStatus, + Convert_v1_ResourceFieldSelector_To_api_ResourceFieldSelector, + Convert_api_ResourceFieldSelector_To_v1_ResourceFieldSelector, Convert_v1_ResourceQuota_To_api_ResourceQuota, Convert_api_ResourceQuota_To_v1_ResourceQuota, Convert_v1_ResourceQuotaList_To_api_ResourceQuotaList, @@ -1442,8 +1444,23 @@ func Convert_api_DeleteOptions_To_v1_DeleteOptions(in *api.DeleteOptions, out *D func autoConvert_v1_DownwardAPIVolumeFile_To_api_DownwardAPIVolumeFile(in *DownwardAPIVolumeFile, out *api.DownwardAPIVolumeFile, s conversion.Scope) error { out.Path = in.Path - if err := Convert_v1_ObjectFieldSelector_To_api_ObjectFieldSelector(&in.FieldRef, &out.FieldRef, s); err != nil { - return err + if in.FieldRef != nil { + in, out := &in.FieldRef, &out.FieldRef + *out = new(api.ObjectFieldSelector) + if err := Convert_v1_ObjectFieldSelector_To_api_ObjectFieldSelector(*in, *out, s); err != nil { + return err + } + } else { + out.FieldRef = nil + } + if in.ResourceFieldRef != nil { + in, out := &in.ResourceFieldRef, &out.ResourceFieldRef + *out = new(api.ResourceFieldSelector) + if err := Convert_v1_ResourceFieldSelector_To_api_ResourceFieldSelector(*in, *out, s); err != nil { + return err + } + } else { + out.ResourceFieldRef = nil } return nil } @@ -1454,8 +1471,23 @@ func Convert_v1_DownwardAPIVolumeFile_To_api_DownwardAPIVolumeFile(in *DownwardA func autoConvert_api_DownwardAPIVolumeFile_To_v1_DownwardAPIVolumeFile(in *api.DownwardAPIVolumeFile, out *DownwardAPIVolumeFile, s conversion.Scope) error { out.Path = in.Path - if err := Convert_api_ObjectFieldSelector_To_v1_ObjectFieldSelector(&in.FieldRef, &out.FieldRef, s); err != nil { - return err + if in.FieldRef != nil { + in, out := &in.FieldRef, &out.FieldRef + *out = new(ObjectFieldSelector) + if err := Convert_api_ObjectFieldSelector_To_v1_ObjectFieldSelector(*in, *out, s); err != nil { + return err + } + } else { + out.FieldRef = nil + } + if in.ResourceFieldRef != nil { + in, out := &in.ResourceFieldRef, &out.ResourceFieldRef + *out = new(ResourceFieldSelector) + if err := Convert_api_ResourceFieldSelector_To_v1_ResourceFieldSelector(*in, *out, s); err != nil { + return err + } + } else { + out.ResourceFieldRef = nil } return nil } @@ -1811,6 +1843,15 @@ func autoConvert_v1_EnvVarSource_To_api_EnvVarSource(in *EnvVarSource, out *api. } else { out.FieldRef = nil } + if in.ResourceFieldRef != nil { + in, out := &in.ResourceFieldRef, &out.ResourceFieldRef + *out = new(api.ResourceFieldSelector) + if err := Convert_v1_ResourceFieldSelector_To_api_ResourceFieldSelector(*in, *out, s); err != nil { + return err + } + } else { + out.ResourceFieldRef = nil + } if in.ConfigMapKeyRef != nil { in, out := &in.ConfigMapKeyRef, &out.ConfigMapKeyRef *out = new(api.ConfigMapKeySelector) @@ -1846,6 +1887,15 @@ func autoConvert_api_EnvVarSource_To_v1_EnvVarSource(in *api.EnvVarSource, out * } else { out.FieldRef = nil } + if in.ResourceFieldRef != nil { + in, out := &in.ResourceFieldRef, &out.ResourceFieldRef + *out = new(ResourceFieldSelector) + if err := Convert_api_ResourceFieldSelector_To_v1_ResourceFieldSelector(*in, *out, s); err != nil { + return err + } + } else { + out.ResourceFieldRef = nil + } if in.ConfigMapKeyRef != nil { in, out := &in.ConfigMapKeyRef, &out.ConfigMapKeyRef *out = new(ConfigMapKeySelector) @@ -5646,6 +5696,32 @@ func Convert_api_ReplicationControllerStatus_To_v1_ReplicationControllerStatus(i return autoConvert_api_ReplicationControllerStatus_To_v1_ReplicationControllerStatus(in, out, s) } +func autoConvert_v1_ResourceFieldSelector_To_api_ResourceFieldSelector(in *ResourceFieldSelector, out *api.ResourceFieldSelector, s conversion.Scope) error { + out.ContainerName = in.ContainerName + out.Resource = in.Resource + if err := api.Convert_resource_Quantity_To_resource_Quantity(&in.Divisor, &out.Divisor, s); err != nil { + return err + } + return nil +} + +func Convert_v1_ResourceFieldSelector_To_api_ResourceFieldSelector(in *ResourceFieldSelector, out *api.ResourceFieldSelector, s conversion.Scope) error { + return autoConvert_v1_ResourceFieldSelector_To_api_ResourceFieldSelector(in, out, s) +} + +func autoConvert_api_ResourceFieldSelector_To_v1_ResourceFieldSelector(in *api.ResourceFieldSelector, out *ResourceFieldSelector, s conversion.Scope) error { + out.ContainerName = in.ContainerName + out.Resource = in.Resource + if err := api.Convert_resource_Quantity_To_resource_Quantity(&in.Divisor, &out.Divisor, s); err != nil { + return err + } + return nil +} + +func Convert_api_ResourceFieldSelector_To_v1_ResourceFieldSelector(in *api.ResourceFieldSelector, out *ResourceFieldSelector, s conversion.Scope) error { + return autoConvert_api_ResourceFieldSelector_To_v1_ResourceFieldSelector(in, out, s) +} + func autoConvert_v1_ResourceQuota_To_api_ResourceQuota(in *ResourceQuota, out *api.ResourceQuota, s conversion.Scope) error { if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil { return err diff --git a/pkg/api/v1/deep_copy_generated.go b/pkg/api/v1/deep_copy_generated.go index 7a6e9c1454c..721ee4871c7 100644 --- a/pkg/api/v1/deep_copy_generated.go +++ b/pkg/api/v1/deep_copy_generated.go @@ -151,6 +151,7 @@ func init() { DeepCopy_v1_ReplicationControllerList, DeepCopy_v1_ReplicationControllerSpec, DeepCopy_v1_ReplicationControllerStatus, + DeepCopy_v1_ResourceFieldSelector, DeepCopy_v1_ResourceQuota, DeepCopy_v1_ResourceQuotaList, DeepCopy_v1_ResourceQuotaSpec, @@ -644,8 +645,23 @@ func DeepCopy_v1_DeleteOptions(in DeleteOptions, out *DeleteOptions, c *conversi func DeepCopy_v1_DownwardAPIVolumeFile(in DownwardAPIVolumeFile, out *DownwardAPIVolumeFile, c *conversion.Cloner) error { out.Path = in.Path - if err := DeepCopy_v1_ObjectFieldSelector(in.FieldRef, &out.FieldRef, c); err != nil { - return err + if in.FieldRef != nil { + in, out := in.FieldRef, &out.FieldRef + *out = new(ObjectFieldSelector) + if err := DeepCopy_v1_ObjectFieldSelector(*in, *out, c); err != nil { + return err + } + } else { + out.FieldRef = nil + } + if in.ResourceFieldRef != nil { + in, out := in.ResourceFieldRef, &out.ResourceFieldRef + *out = new(ResourceFieldSelector) + if err := DeepCopy_v1_ResourceFieldSelector(*in, *out, c); err != nil { + return err + } + } else { + out.ResourceFieldRef = nil } return nil } @@ -796,6 +812,15 @@ func DeepCopy_v1_EnvVarSource(in EnvVarSource, out *EnvVarSource, c *conversion. } else { out.FieldRef = nil } + if in.ResourceFieldRef != nil { + in, out := in.ResourceFieldRef, &out.ResourceFieldRef + *out = new(ResourceFieldSelector) + if err := DeepCopy_v1_ResourceFieldSelector(*in, *out, c); err != nil { + return err + } + } else { + out.ResourceFieldRef = nil + } if in.ConfigMapKeyRef != nil { in, out := in.ConfigMapKeyRef, &out.ConfigMapKeyRef *out = new(ConfigMapKeySelector) @@ -2526,6 +2551,15 @@ func DeepCopy_v1_ReplicationControllerStatus(in ReplicationControllerStatus, out return nil } +func DeepCopy_v1_ResourceFieldSelector(in ResourceFieldSelector, out *ResourceFieldSelector, c *conversion.Cloner) error { + out.ContainerName = in.ContainerName + out.Resource = in.Resource + if err := resource.DeepCopy_resource_Quantity(in.Divisor, &out.Divisor, c); err != nil { + return err + } + return nil +} + func DeepCopy_v1_ResourceQuota(in ResourceQuota, out *ResourceQuota, c *conversion.Cloner) error { if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { return err diff --git a/pkg/api/v1/generated.pb.go b/pkg/api/v1/generated.pb.go index 02ed1a87e82..cda472db18a 100644 --- a/pkg/api/v1/generated.pb.go +++ b/pkg/api/v1/generated.pb.go @@ -144,6 +144,7 @@ limitations under the License. ReplicationControllerList ReplicationControllerSpec ReplicationControllerStatus + ResourceFieldSelector ResourceQuota ResourceQuotaList ResourceQuotaSpec @@ -668,6 +669,10 @@ func (m *ReplicationControllerStatus) Reset() { *m = ReplicationControll func (m *ReplicationControllerStatus) String() string { return proto.CompactTextString(m) } func (*ReplicationControllerStatus) ProtoMessage() {} +func (m *ResourceFieldSelector) Reset() { *m = ResourceFieldSelector{} } +func (m *ResourceFieldSelector) String() string { return proto.CompactTextString(m) } +func (*ResourceFieldSelector) ProtoMessage() {} + func (m *ResourceQuota) Reset() { *m = ResourceQuota{} } func (m *ResourceQuota) String() string { return proto.CompactTextString(m) } func (*ResourceQuota) ProtoMessage() {} @@ -900,6 +905,7 @@ func init() { proto.RegisterType((*ReplicationControllerList)(nil), "k8s.io.kubernetes.pkg.api.v1.ReplicationControllerList") proto.RegisterType((*ReplicationControllerSpec)(nil), "k8s.io.kubernetes.pkg.api.v1.ReplicationControllerSpec") proto.RegisterType((*ReplicationControllerStatus)(nil), "k8s.io.kubernetes.pkg.api.v1.ReplicationControllerStatus") + proto.RegisterType((*ResourceFieldSelector)(nil), "k8s.io.kubernetes.pkg.api.v1.ResourceFieldSelector") proto.RegisterType((*ResourceQuota)(nil), "k8s.io.kubernetes.pkg.api.v1.ResourceQuota") proto.RegisterType((*ResourceQuotaList)(nil), "k8s.io.kubernetes.pkg.api.v1.ResourceQuotaList") proto.RegisterType((*ResourceQuotaSpec)(nil), "k8s.io.kubernetes.pkg.api.v1.ResourceQuotaSpec") @@ -2036,14 +2042,26 @@ func (m *DownwardAPIVolumeFile) MarshalTo(data []byte) (int, error) { i++ i = encodeVarintGenerated(data, i, uint64(len(m.Path))) i += copy(data[i:], m.Path) - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.FieldRef.Size())) - n27, err := m.FieldRef.MarshalTo(data[i:]) - if err != nil { - return 0, err + if m.FieldRef != nil { + data[i] = 0x12 + i++ + i = encodeVarintGenerated(data, i, uint64(m.FieldRef.Size())) + n27, err := m.FieldRef.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n27 + } + if m.ResourceFieldRef != nil { + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(m.ResourceFieldRef.Size())) + n28, err := m.ResourceFieldRef.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n28 } - i += n27 return i, nil } @@ -2122,11 +2140,11 @@ func (m *EndpointAddress) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.TargetRef.Size())) - n28, err := m.TargetRef.MarshalTo(data[i:]) + n29, err := m.TargetRef.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n28 + i += n29 } data[i] = 0x1a i++ @@ -2236,11 +2254,11 @@ func (m *Endpoints) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n29, err := m.ObjectMeta.MarshalTo(data[i:]) + n30, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n29 + i += n30 if len(m.Subsets) > 0 { for _, msg := range m.Subsets { data[i] = 0x12 @@ -2274,11 +2292,11 @@ func (m *EndpointsList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n30, err := m.ListMeta.MarshalTo(data[i:]) + n31, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n30 + i += n31 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -2321,11 +2339,11 @@ func (m *EnvVar) MarshalTo(data []byte) (int, error) { data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(m.ValueFrom.Size())) - n31, err := m.ValueFrom.MarshalTo(data[i:]) + n32, err := m.ValueFrom.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n31 + i += n32 } return i, nil } @@ -2349,32 +2367,42 @@ func (m *EnvVarSource) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.FieldRef.Size())) - n32, err := m.FieldRef.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n32 - } - if m.ConfigMapKeyRef != nil { - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.ConfigMapKeyRef.Size())) - n33, err := m.ConfigMapKeyRef.MarshalTo(data[i:]) + n33, err := m.FieldRef.MarshalTo(data[i:]) if err != nil { return 0, err } i += n33 } - if m.SecretKeyRef != nil { - data[i] = 0x1a + if m.ResourceFieldRef != nil { + data[i] = 0x12 i++ - i = encodeVarintGenerated(data, i, uint64(m.SecretKeyRef.Size())) - n34, err := m.SecretKeyRef.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.ResourceFieldRef.Size())) + n34, err := m.ResourceFieldRef.MarshalTo(data[i:]) if err != nil { return 0, err } i += n34 } + if m.ConfigMapKeyRef != nil { + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(m.ConfigMapKeyRef.Size())) + n35, err := m.ConfigMapKeyRef.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n35 + } + if m.SecretKeyRef != nil { + data[i] = 0x22 + i++ + i = encodeVarintGenerated(data, i, uint64(m.SecretKeyRef.Size())) + n36, err := m.SecretKeyRef.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n36 + } return i, nil } @@ -2396,19 +2424,19 @@ func (m *Event) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n35, err := m.ObjectMeta.MarshalTo(data[i:]) + n37, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n35 + i += n37 data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.InvolvedObject.Size())) - n36, err := m.InvolvedObject.MarshalTo(data[i:]) + n38, err := m.InvolvedObject.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n36 + i += n38 data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(len(m.Reason))) @@ -2420,27 +2448,27 @@ func (m *Event) MarshalTo(data []byte) (int, error) { data[i] = 0x2a i++ i = encodeVarintGenerated(data, i, uint64(m.Source.Size())) - n37, err := m.Source.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n37 - data[i] = 0x32 - i++ - i = encodeVarintGenerated(data, i, uint64(m.FirstTimestamp.Size())) - n38, err := m.FirstTimestamp.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n38 - data[i] = 0x3a - i++ - i = encodeVarintGenerated(data, i, uint64(m.LastTimestamp.Size())) - n39, err := m.LastTimestamp.MarshalTo(data[i:]) + n39, err := m.Source.MarshalTo(data[i:]) if err != nil { return 0, err } i += n39 + data[i] = 0x32 + i++ + i = encodeVarintGenerated(data, i, uint64(m.FirstTimestamp.Size())) + n40, err := m.FirstTimestamp.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n40 + data[i] = 0x3a + i++ + i = encodeVarintGenerated(data, i, uint64(m.LastTimestamp.Size())) + n41, err := m.LastTimestamp.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n41 data[i] = 0x40 i++ i = encodeVarintGenerated(data, i, uint64(m.Count)) @@ -2469,11 +2497,11 @@ func (m *EventList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n40, err := m.ListMeta.MarshalTo(data[i:]) + n42, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n40 + i += n42 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -2659,11 +2687,11 @@ func (m *FlexVolumeSource) MarshalTo(data []byte) (int, error) { data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(m.SecretRef.Size())) - n41, err := m.SecretRef.MarshalTo(data[i:]) + n43, err := m.SecretRef.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n41 + i += n43 } data[i] = 0x20 i++ @@ -2838,11 +2866,11 @@ func (m *HTTPGetAction) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.Port.Size())) - n42, err := m.Port.MarshalTo(data[i:]) + n44, err := m.Port.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n42 + i += n44 data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(len(m.Host))) @@ -2911,31 +2939,31 @@ func (m *Handler) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.Exec.Size())) - n43, err := m.Exec.MarshalTo(data[i:]) + n45, err := m.Exec.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n43 + i += n45 } if m.HTTPGet != nil { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.HTTPGet.Size())) - n44, err := m.HTTPGet.MarshalTo(data[i:]) + n46, err := m.HTTPGet.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n44 + i += n46 } if m.TCPSocket != nil { data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(m.TCPSocket.Size())) - n45, err := m.TCPSocket.MarshalTo(data[i:]) + n47, err := m.TCPSocket.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n45 + i += n47 } return i, nil } @@ -3052,21 +3080,21 @@ func (m *Lifecycle) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.PostStart.Size())) - n46, err := m.PostStart.MarshalTo(data[i:]) + n48, err := m.PostStart.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n46 + i += n48 } if m.PreStop != nil { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.PreStop.Size())) - n47, err := m.PreStop.MarshalTo(data[i:]) + n49, err := m.PreStop.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n47 + i += n49 } return i, nil } @@ -3089,19 +3117,19 @@ func (m *LimitRange) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n48, err := m.ObjectMeta.MarshalTo(data[i:]) + n50, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n48 + i += n50 data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n49, err := m.Spec.MarshalTo(data[i:]) + n51, err := m.Spec.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n49 + i += n51 return i, nil } @@ -3139,11 +3167,11 @@ func (m *LimitRangeItem) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n50, err := (&v).MarshalTo(data[i:]) + n52, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n50 + i += n52 } } if len(m.Min) > 0 { @@ -3161,11 +3189,11 @@ func (m *LimitRangeItem) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n51, err := (&v).MarshalTo(data[i:]) + n53, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n51 + i += n53 } } if len(m.Default) > 0 { @@ -3183,11 +3211,11 @@ func (m *LimitRangeItem) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n52, err := (&v).MarshalTo(data[i:]) + n54, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n52 + i += n54 } } if len(m.DefaultRequest) > 0 { @@ -3205,11 +3233,11 @@ func (m *LimitRangeItem) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n53, err := (&v).MarshalTo(data[i:]) + n55, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n53 + i += n55 } } if len(m.MaxLimitRequestRatio) > 0 { @@ -3227,11 +3255,11 @@ func (m *LimitRangeItem) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n54, err := (&v).MarshalTo(data[i:]) + n56, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n54 + i += n56 } } return i, nil @@ -3255,11 +3283,11 @@ func (m *LimitRangeList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n55, err := m.ListMeta.MarshalTo(data[i:]) + n57, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n55 + i += n57 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -3323,11 +3351,11 @@ func (m *List) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n56, err := m.ListMeta.MarshalTo(data[i:]) + n58, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n56 + i += n58 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -3516,27 +3544,27 @@ func (m *Namespace) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n57, err := m.ObjectMeta.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n57 - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n58, err := m.Spec.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n58 - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) - n59, err := m.Status.MarshalTo(data[i:]) + n59, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } i += n59 + data[i] = 0x12 + i++ + i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) + n60, err := m.Spec.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n60 + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) + n61, err := m.Status.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n61 return i, nil } @@ -3558,11 +3586,11 @@ func (m *NamespaceList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n60, err := m.ListMeta.MarshalTo(data[i:]) + n62, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n60 + i += n62 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -3651,27 +3679,27 @@ func (m *Node) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n61, err := m.ObjectMeta.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n61 - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n62, err := m.Spec.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n62 - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) - n63, err := m.Status.MarshalTo(data[i:]) + n63, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } i += n63 + data[i] = 0x12 + i++ + i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) + n64, err := m.Spec.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n64 + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) + n65, err := m.Status.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n65 return i, nil } @@ -3720,11 +3748,11 @@ func (m *NodeAffinity) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.RequiredDuringSchedulingIgnoredDuringExecution.Size())) - n64, err := m.RequiredDuringSchedulingIgnoredDuringExecution.MarshalTo(data[i:]) + n66, err := m.RequiredDuringSchedulingIgnoredDuringExecution.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n64 + i += n66 } if len(m.PreferredDuringSchedulingIgnoredDuringExecution) > 0 { for _, msg := range m.PreferredDuringSchedulingIgnoredDuringExecution { @@ -3767,19 +3795,19 @@ func (m *NodeCondition) MarshalTo(data []byte) (int, error) { data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(m.LastHeartbeatTime.Size())) - n65, err := m.LastHeartbeatTime.MarshalTo(data[i:]) + n67, err := m.LastHeartbeatTime.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n65 + i += n67 data[i] = 0x22 i++ i = encodeVarintGenerated(data, i, uint64(m.LastTransitionTime.Size())) - n66, err := m.LastTransitionTime.MarshalTo(data[i:]) + n68, err := m.LastTransitionTime.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n66 + i += n68 data[i] = 0x2a i++ i = encodeVarintGenerated(data, i, uint64(len(m.Reason))) @@ -3809,11 +3837,11 @@ func (m *NodeDaemonEndpoints) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.KubeletEndpoint.Size())) - n67, err := m.KubeletEndpoint.MarshalTo(data[i:]) + n69, err := m.KubeletEndpoint.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n67 + i += n69 return i, nil } @@ -3835,11 +3863,11 @@ func (m *NodeList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n68, err := m.ListMeta.MarshalTo(data[i:]) + n70, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n68 + i += n70 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -4046,11 +4074,11 @@ func (m *NodeStatus) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n69, err := (&v).MarshalTo(data[i:]) + n71, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n69 + i += n71 } } if len(m.Allocatable) > 0 { @@ -4068,11 +4096,11 @@ func (m *NodeStatus) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n70, err := (&v).MarshalTo(data[i:]) + n72, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n70 + i += n72 } } data[i] = 0x1a @@ -4106,19 +4134,19 @@ func (m *NodeStatus) MarshalTo(data []byte) (int, error) { data[i] = 0x32 i++ i = encodeVarintGenerated(data, i, uint64(m.DaemonEndpoints.Size())) - n71, err := m.DaemonEndpoints.MarshalTo(data[i:]) + n73, err := m.DaemonEndpoints.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n71 + i += n73 data[i] = 0x3a i++ i = encodeVarintGenerated(data, i, uint64(m.NodeInfo.Size())) - n72, err := m.NodeInfo.MarshalTo(data[i:]) + n74, err := m.NodeInfo.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n72 + i += n74 if len(m.Images) > 0 { for _, msg := range m.Images { data[i] = 0x42 @@ -4263,20 +4291,20 @@ func (m *ObjectMeta) MarshalTo(data []byte) (int, error) { data[i] = 0x42 i++ i = encodeVarintGenerated(data, i, uint64(m.CreationTimestamp.Size())) - n73, err := m.CreationTimestamp.MarshalTo(data[i:]) + n75, err := m.CreationTimestamp.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n73 + i += n75 if m.DeletionTimestamp != nil { data[i] = 0x4a i++ i = encodeVarintGenerated(data, i, uint64(m.DeletionTimestamp.Size())) - n74, err := m.DeletionTimestamp.MarshalTo(data[i:]) + n76, err := m.DeletionTimestamp.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n74 + i += n76 } if m.DeletionGracePeriodSeconds != nil { data[i] = 0x50 @@ -4445,27 +4473,27 @@ func (m *PersistentVolume) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n75, err := m.ObjectMeta.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n75 - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n76, err := m.Spec.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n76 - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) - n77, err := m.Status.MarshalTo(data[i:]) + n77, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } i += n77 + data[i] = 0x12 + i++ + i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) + n78, err := m.Spec.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n78 + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) + n79, err := m.Status.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n79 return i, nil } @@ -4487,27 +4515,27 @@ func (m *PersistentVolumeClaim) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n78, err := m.ObjectMeta.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n78 - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n79, err := m.Spec.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n79 - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) - n80, err := m.Status.MarshalTo(data[i:]) + n80, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } i += n80 + data[i] = 0x12 + i++ + i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) + n81, err := m.Spec.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n81 + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) + n82, err := m.Status.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n82 return i, nil } @@ -4529,11 +4557,11 @@ func (m *PersistentVolumeClaimList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n81, err := m.ListMeta.MarshalTo(data[i:]) + n83, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n81 + i += n83 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -4582,11 +4610,11 @@ func (m *PersistentVolumeClaimSpec) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.Resources.Size())) - n82, err := m.Resources.MarshalTo(data[i:]) + n84, err := m.Resources.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n82 + i += n84 data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(len(m.VolumeName))) @@ -4643,11 +4671,11 @@ func (m *PersistentVolumeClaimStatus) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n83, err := (&v).MarshalTo(data[i:]) + n85, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n83 + i += n85 } } return i, nil @@ -4701,11 +4729,11 @@ func (m *PersistentVolumeList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n84, err := m.ListMeta.MarshalTo(data[i:]) + n86, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n84 + i += n86 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -4740,142 +4768,142 @@ func (m *PersistentVolumeSource) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.GCEPersistentDisk.Size())) - n85, err := m.GCEPersistentDisk.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n85 - } - if m.AWSElasticBlockStore != nil { - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.AWSElasticBlockStore.Size())) - n86, err := m.AWSElasticBlockStore.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n86 - } - if m.HostPath != nil { - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(m.HostPath.Size())) - n87, err := m.HostPath.MarshalTo(data[i:]) + n87, err := m.GCEPersistentDisk.MarshalTo(data[i:]) if err != nil { return 0, err } i += n87 } - if m.Glusterfs != nil { - data[i] = 0x22 + if m.AWSElasticBlockStore != nil { + data[i] = 0x12 i++ - i = encodeVarintGenerated(data, i, uint64(m.Glusterfs.Size())) - n88, err := m.Glusterfs.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.AWSElasticBlockStore.Size())) + n88, err := m.AWSElasticBlockStore.MarshalTo(data[i:]) if err != nil { return 0, err } i += n88 } - if m.NFS != nil { - data[i] = 0x2a + if m.HostPath != nil { + data[i] = 0x1a i++ - i = encodeVarintGenerated(data, i, uint64(m.NFS.Size())) - n89, err := m.NFS.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.HostPath.Size())) + n89, err := m.HostPath.MarshalTo(data[i:]) if err != nil { return 0, err } i += n89 } - if m.RBD != nil { - data[i] = 0x32 + if m.Glusterfs != nil { + data[i] = 0x22 i++ - i = encodeVarintGenerated(data, i, uint64(m.RBD.Size())) - n90, err := m.RBD.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.Glusterfs.Size())) + n90, err := m.Glusterfs.MarshalTo(data[i:]) if err != nil { return 0, err } i += n90 } - if m.ISCSI != nil { - data[i] = 0x3a + if m.NFS != nil { + data[i] = 0x2a i++ - i = encodeVarintGenerated(data, i, uint64(m.ISCSI.Size())) - n91, err := m.ISCSI.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.NFS.Size())) + n91, err := m.NFS.MarshalTo(data[i:]) if err != nil { return 0, err } i += n91 } - if m.Cinder != nil { - data[i] = 0x42 + if m.RBD != nil { + data[i] = 0x32 i++ - i = encodeVarintGenerated(data, i, uint64(m.Cinder.Size())) - n92, err := m.Cinder.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.RBD.Size())) + n92, err := m.RBD.MarshalTo(data[i:]) if err != nil { return 0, err } i += n92 } - if m.CephFS != nil { - data[i] = 0x4a + if m.ISCSI != nil { + data[i] = 0x3a i++ - i = encodeVarintGenerated(data, i, uint64(m.CephFS.Size())) - n93, err := m.CephFS.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.ISCSI.Size())) + n93, err := m.ISCSI.MarshalTo(data[i:]) if err != nil { return 0, err } i += n93 } - if m.FC != nil { - data[i] = 0x52 + if m.Cinder != nil { + data[i] = 0x42 i++ - i = encodeVarintGenerated(data, i, uint64(m.FC.Size())) - n94, err := m.FC.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.Cinder.Size())) + n94, err := m.Cinder.MarshalTo(data[i:]) if err != nil { return 0, err } i += n94 } - if m.Flocker != nil { - data[i] = 0x5a + if m.CephFS != nil { + data[i] = 0x4a i++ - i = encodeVarintGenerated(data, i, uint64(m.Flocker.Size())) - n95, err := m.Flocker.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.CephFS.Size())) + n95, err := m.CephFS.MarshalTo(data[i:]) if err != nil { return 0, err } i += n95 } - if m.FlexVolume != nil { - data[i] = 0x62 + if m.FC != nil { + data[i] = 0x52 i++ - i = encodeVarintGenerated(data, i, uint64(m.FlexVolume.Size())) - n96, err := m.FlexVolume.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.FC.Size())) + n96, err := m.FC.MarshalTo(data[i:]) if err != nil { return 0, err } i += n96 } - if m.AzureFile != nil { - data[i] = 0x6a + if m.Flocker != nil { + data[i] = 0x5a i++ - i = encodeVarintGenerated(data, i, uint64(m.AzureFile.Size())) - n97, err := m.AzureFile.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.Flocker.Size())) + n97, err := m.Flocker.MarshalTo(data[i:]) if err != nil { return 0, err } i += n97 } - if m.VsphereVolume != nil { - data[i] = 0x72 + if m.FlexVolume != nil { + data[i] = 0x62 i++ - i = encodeVarintGenerated(data, i, uint64(m.VsphereVolume.Size())) - n98, err := m.VsphereVolume.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.FlexVolume.Size())) + n98, err := m.FlexVolume.MarshalTo(data[i:]) if err != nil { return 0, err } i += n98 } + if m.AzureFile != nil { + data[i] = 0x6a + i++ + i = encodeVarintGenerated(data, i, uint64(m.AzureFile.Size())) + n99, err := m.AzureFile.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n99 + } + if m.VsphereVolume != nil { + data[i] = 0x72 + i++ + i = encodeVarintGenerated(data, i, uint64(m.VsphereVolume.Size())) + n100, err := m.VsphereVolume.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n100 + } return i, nil } @@ -4909,21 +4937,21 @@ func (m *PersistentVolumeSpec) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n99, err := (&v).MarshalTo(data[i:]) + n101, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n99 + i += n101 } } data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.PersistentVolumeSource.Size())) - n100, err := m.PersistentVolumeSource.MarshalTo(data[i:]) + n102, err := m.PersistentVolumeSource.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n100 + i += n102 if len(m.AccessModes) > 0 { for _, s := range m.AccessModes { data[i] = 0x1a @@ -4943,11 +4971,11 @@ func (m *PersistentVolumeSpec) MarshalTo(data []byte) (int, error) { data[i] = 0x22 i++ i = encodeVarintGenerated(data, i, uint64(m.ClaimRef.Size())) - n101, err := m.ClaimRef.MarshalTo(data[i:]) + n103, err := m.ClaimRef.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n101 + i += n103 } data[i] = 0x2a i++ @@ -5004,27 +5032,27 @@ func (m *Pod) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n102, err := m.ObjectMeta.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n102 - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n103, err := m.Spec.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n103 - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) - n104, err := m.Status.MarshalTo(data[i:]) + n104, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } i += n104 + data[i] = 0x12 + i++ + i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) + n105, err := m.Spec.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n105 + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) + n106, err := m.Status.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n106 return i, nil } @@ -5089,11 +5117,11 @@ func (m *PodAffinityTerm) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.LabelSelector.Size())) - n105, err := m.LabelSelector.MarshalTo(data[i:]) + n107, err := m.LabelSelector.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n105 + i += n107 } if len(m.Namespaces) > 0 { for _, s := range m.Namespaces { @@ -5239,19 +5267,19 @@ func (m *PodCondition) MarshalTo(data []byte) (int, error) { data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(m.LastProbeTime.Size())) - n106, err := m.LastProbeTime.MarshalTo(data[i:]) + n108, err := m.LastProbeTime.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n106 + i += n108 data[i] = 0x22 i++ i = encodeVarintGenerated(data, i, uint64(m.LastTransitionTime.Size())) - n107, err := m.LastTransitionTime.MarshalTo(data[i:]) + n109, err := m.LastTransitionTime.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n107 + i += n109 data[i] = 0x2a i++ i = encodeVarintGenerated(data, i, uint64(len(m.Reason))) @@ -5350,11 +5378,11 @@ func (m *PodList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n108, err := m.ListMeta.MarshalTo(data[i:]) + n110, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n108 + i += n110 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -5414,11 +5442,11 @@ func (m *PodLogOptions) MarshalTo(data []byte) (int, error) { data[i] = 0x2a i++ i = encodeVarintGenerated(data, i, uint64(m.SinceTime.Size())) - n109, err := m.SinceTime.MarshalTo(data[i:]) + n111, err := m.SinceTime.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n109 + i += n111 } data[i] = 0x30 i++ @@ -5482,11 +5510,11 @@ func (m *PodSecurityContext) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.SELinuxOptions.Size())) - n110, err := m.SELinuxOptions.MarshalTo(data[i:]) + n112, err := m.SELinuxOptions.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n110 + i += n112 } if m.RunAsUser != nil { data[i] = 0x10 @@ -5632,11 +5660,11 @@ func (m *PodSpec) MarshalTo(data []byte) (int, error) { data[i] = 0x72 i++ i = encodeVarintGenerated(data, i, uint64(m.SecurityContext.Size())) - n111, err := m.SecurityContext.MarshalTo(data[i:]) + n113, err := m.SecurityContext.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n111 + i += n113 } if len(m.ImagePullSecrets) > 0 { for _, msg := range m.ImagePullSecrets { @@ -5716,11 +5744,11 @@ func (m *PodStatus) MarshalTo(data []byte) (int, error) { data[i] = 0x3a i++ i = encodeVarintGenerated(data, i, uint64(m.StartTime.Size())) - n112, err := m.StartTime.MarshalTo(data[i:]) + n114, err := m.StartTime.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n112 + i += n114 } if len(m.ContainerStatuses) > 0 { for _, msg := range m.ContainerStatuses { @@ -5755,19 +5783,19 @@ func (m *PodStatusResult) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n113, err := m.ObjectMeta.MarshalTo(data[i:]) + n115, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n113 + i += n115 data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) - n114, err := m.Status.MarshalTo(data[i:]) + n116, err := m.Status.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n114 + i += n116 return i, nil } @@ -5789,19 +5817,19 @@ func (m *PodTemplate) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n115, err := m.ObjectMeta.MarshalTo(data[i:]) + n117, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n115 + i += n117 data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.Template.Size())) - n116, err := m.Template.MarshalTo(data[i:]) + n118, err := m.Template.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n116 + i += n118 return i, nil } @@ -5823,11 +5851,11 @@ func (m *PodTemplateList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n117, err := m.ListMeta.MarshalTo(data[i:]) + n119, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n117 + i += n119 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -5861,19 +5889,19 @@ func (m *PodTemplateSpec) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n118, err := m.ObjectMeta.MarshalTo(data[i:]) + n120, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n118 + i += n120 data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n119, err := m.Spec.MarshalTo(data[i:]) + n121, err := m.Spec.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n119 + i += n121 return i, nil } @@ -5922,11 +5950,11 @@ func (m *PreferredSchedulingTerm) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.Preference.Size())) - n120, err := m.Preference.MarshalTo(data[i:]) + n122, err := m.Preference.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n120 + i += n122 return i, nil } @@ -5948,11 +5976,11 @@ func (m *Probe) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.Handler.Size())) - n121, err := m.Handler.MarshalTo(data[i:]) + n123, err := m.Handler.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n121 + i += n123 data[i] = 0x10 i++ i = encodeVarintGenerated(data, i, uint64(m.InitialDelaySeconds)) @@ -6025,11 +6053,11 @@ func (m *RBDVolumeSource) MarshalTo(data []byte) (int, error) { data[i] = 0x3a i++ i = encodeVarintGenerated(data, i, uint64(m.SecretRef.Size())) - n122, err := m.SecretRef.MarshalTo(data[i:]) + n124, err := m.SecretRef.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n122 + i += n124 } data[i] = 0x40 i++ @@ -6060,11 +6088,11 @@ func (m *RangeAllocation) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n123, err := m.ObjectMeta.MarshalTo(data[i:]) + n125, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n123 + i += n125 data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(len(m.Range))) @@ -6096,27 +6124,27 @@ func (m *ReplicationController) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n124, err := m.ObjectMeta.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n124 - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n125, err := m.Spec.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n125 - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) - n126, err := m.Status.MarshalTo(data[i:]) + n126, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } i += n126 + data[i] = 0x12 + i++ + i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) + n127, err := m.Spec.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n127 + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) + n128, err := m.Status.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n128 return i, nil } @@ -6138,11 +6166,11 @@ func (m *ReplicationControllerList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n127, err := m.ListMeta.MarshalTo(data[i:]) + n129, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n127 + i += n129 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -6199,11 +6227,11 @@ func (m *ReplicationControllerSpec) MarshalTo(data []byte) (int, error) { data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(m.Template.Size())) - n128, err := m.Template.MarshalTo(data[i:]) + n130, err := m.Template.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n128 + i += n130 } return i, nil } @@ -6235,6 +6263,40 @@ func (m *ReplicationControllerStatus) MarshalTo(data []byte) (int, error) { return i, nil } +func (m *ResourceFieldSelector) Marshal() (data []byte, err error) { + size := m.Size() + data = make([]byte, size) + n, err := m.MarshalTo(data) + if err != nil { + return nil, err + } + return data[:n], nil +} + +func (m *ResourceFieldSelector) MarshalTo(data []byte) (int, error) { + var i int + _ = i + var l int + _ = l + data[i] = 0xa + i++ + i = encodeVarintGenerated(data, i, uint64(len(m.ContainerName))) + i += copy(data[i:], m.ContainerName) + data[i] = 0x12 + i++ + i = encodeVarintGenerated(data, i, uint64(len(m.Resource))) + i += copy(data[i:], m.Resource) + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(m.Divisor.Size())) + n131, err := m.Divisor.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n131 + return i, nil +} + func (m *ResourceQuota) Marshal() (data []byte, err error) { size := m.Size() data = make([]byte, size) @@ -6253,27 +6315,27 @@ func (m *ResourceQuota) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n129, err := m.ObjectMeta.MarshalTo(data[i:]) + n132, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n129 + i += n132 data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n130, err := m.Spec.MarshalTo(data[i:]) + n133, err := m.Spec.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n130 + i += n133 data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) - n131, err := m.Status.MarshalTo(data[i:]) + n134, err := m.Status.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n131 + i += n134 return i, nil } @@ -6295,11 +6357,11 @@ func (m *ResourceQuotaList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n132, err := m.ListMeta.MarshalTo(data[i:]) + n135, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n132 + i += n135 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -6345,11 +6407,11 @@ func (m *ResourceQuotaSpec) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n133, err := (&v).MarshalTo(data[i:]) + n136, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n133 + i += n136 } } if len(m.Scopes) > 0 { @@ -6400,11 +6462,11 @@ func (m *ResourceQuotaStatus) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n134, err := (&v).MarshalTo(data[i:]) + n137, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n134 + i += n137 } } if len(m.Used) > 0 { @@ -6422,11 +6484,11 @@ func (m *ResourceQuotaStatus) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n135, err := (&v).MarshalTo(data[i:]) + n138, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n135 + i += n138 } } return i, nil @@ -6462,11 +6524,11 @@ func (m *ResourceRequirements) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n136, err := (&v).MarshalTo(data[i:]) + n139, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n136 + i += n139 } } if len(m.Requests) > 0 { @@ -6484,11 +6546,11 @@ func (m *ResourceRequirements) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64((&v).Size())) - n137, err := (&v).MarshalTo(data[i:]) + n140, err := (&v).MarshalTo(data[i:]) if err != nil { return 0, err } - i += n137 + i += n140 } } return i, nil @@ -6546,11 +6608,11 @@ func (m *Secret) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n138, err := m.ObjectMeta.MarshalTo(data[i:]) + n141, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n138 + i += n141 if len(m.Data) > 0 { for k := range m.Data { data[i] = 0x12 @@ -6593,11 +6655,11 @@ func (m *SecretKeySelector) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.LocalObjectReference.Size())) - n139, err := m.LocalObjectReference.MarshalTo(data[i:]) + n142, err := m.LocalObjectReference.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n139 + i += n142 data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(len(m.Key))) @@ -6623,11 +6685,11 @@ func (m *SecretList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n140, err := m.ListMeta.MarshalTo(data[i:]) + n143, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n140 + i += n143 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -6696,11 +6758,11 @@ func (m *SecurityContext) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.Capabilities.Size())) - n141, err := m.Capabilities.MarshalTo(data[i:]) + n144, err := m.Capabilities.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n141 + i += n144 } if m.Privileged != nil { data[i] = 0x10 @@ -6716,11 +6778,11 @@ func (m *SecurityContext) MarshalTo(data []byte) (int, error) { data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(m.SELinuxOptions.Size())) - n142, err := m.SELinuxOptions.MarshalTo(data[i:]) + n145, err := m.SELinuxOptions.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n142 + i += n145 } if m.RunAsUser != nil { data[i] = 0x20 @@ -6768,11 +6830,11 @@ func (m *SerializedReference) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.Reference.Size())) - n143, err := m.Reference.MarshalTo(data[i:]) + n146, err := m.Reference.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n143 + i += n146 return i, nil } @@ -6794,27 +6856,27 @@ func (m *Service) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n144, err := m.ObjectMeta.MarshalTo(data[i:]) + n147, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n144 + i += n147 data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.Spec.Size())) - n145, err := m.Spec.MarshalTo(data[i:]) + n148, err := m.Spec.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n145 + i += n148 data[i] = 0x1a i++ i = encodeVarintGenerated(data, i, uint64(m.Status.Size())) - n146, err := m.Status.MarshalTo(data[i:]) + n149, err := m.Status.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n146 + i += n149 return i, nil } @@ -6836,11 +6898,11 @@ func (m *ServiceAccount) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ObjectMeta.Size())) - n147, err := m.ObjectMeta.MarshalTo(data[i:]) + n150, err := m.ObjectMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n147 + i += n150 if len(m.Secrets) > 0 { for _, msg := range m.Secrets { data[i] = 0x12 @@ -6886,11 +6948,11 @@ func (m *ServiceAccountList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n148, err := m.ListMeta.MarshalTo(data[i:]) + n151, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n148 + i += n151 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -6924,11 +6986,11 @@ func (m *ServiceList) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.ListMeta.Size())) - n149, err := m.ListMeta.MarshalTo(data[i:]) + n152, err := m.ListMeta.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n149 + i += n152 if len(m.Items) > 0 { for _, msg := range m.Items { data[i] = 0x12 @@ -6973,11 +7035,11 @@ func (m *ServicePort) MarshalTo(data []byte) (int, error) { data[i] = 0x22 i++ i = encodeVarintGenerated(data, i, uint64(m.TargetPort.Size())) - n150, err := m.TargetPort.MarshalTo(data[i:]) + n153, err := m.TargetPort.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n150 + i += n153 data[i] = 0x28 i++ i = encodeVarintGenerated(data, i, uint64(m.NodePort)) @@ -7117,11 +7179,11 @@ func (m *ServiceStatus) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.LoadBalancer.Size())) - n151, err := m.LoadBalancer.MarshalTo(data[i:]) + n154, err := m.LoadBalancer.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n151 + i += n154 return i, nil } @@ -7143,11 +7205,11 @@ func (m *TCPSocketAction) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.Port.Size())) - n152, err := m.Port.MarshalTo(data[i:]) + n155, err := m.Port.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n152 + i += n155 return i, nil } @@ -7237,11 +7299,11 @@ func (m *Volume) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.VolumeSource.Size())) - n153, err := m.VolumeSource.MarshalTo(data[i:]) + n156, err := m.VolumeSource.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n153 + i += n156 return i, nil } @@ -7302,163 +7364,163 @@ func (m *VolumeSource) MarshalTo(data []byte) (int, error) { data[i] = 0xa i++ i = encodeVarintGenerated(data, i, uint64(m.HostPath.Size())) - n154, err := m.HostPath.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n154 - } - if m.EmptyDir != nil { - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.EmptyDir.Size())) - n155, err := m.EmptyDir.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n155 - } - if m.GCEPersistentDisk != nil { - data[i] = 0x1a - i++ - i = encodeVarintGenerated(data, i, uint64(m.GCEPersistentDisk.Size())) - n156, err := m.GCEPersistentDisk.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n156 - } - if m.AWSElasticBlockStore != nil { - data[i] = 0x22 - i++ - i = encodeVarintGenerated(data, i, uint64(m.AWSElasticBlockStore.Size())) - n157, err := m.AWSElasticBlockStore.MarshalTo(data[i:]) + n157, err := m.HostPath.MarshalTo(data[i:]) if err != nil { return 0, err } i += n157 } - if m.GitRepo != nil { - data[i] = 0x2a + if m.EmptyDir != nil { + data[i] = 0x12 i++ - i = encodeVarintGenerated(data, i, uint64(m.GitRepo.Size())) - n158, err := m.GitRepo.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.EmptyDir.Size())) + n158, err := m.EmptyDir.MarshalTo(data[i:]) if err != nil { return 0, err } i += n158 } - if m.Secret != nil { - data[i] = 0x32 + if m.GCEPersistentDisk != nil { + data[i] = 0x1a i++ - i = encodeVarintGenerated(data, i, uint64(m.Secret.Size())) - n159, err := m.Secret.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.GCEPersistentDisk.Size())) + n159, err := m.GCEPersistentDisk.MarshalTo(data[i:]) if err != nil { return 0, err } i += n159 } - if m.NFS != nil { - data[i] = 0x3a + if m.AWSElasticBlockStore != nil { + data[i] = 0x22 i++ - i = encodeVarintGenerated(data, i, uint64(m.NFS.Size())) - n160, err := m.NFS.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.AWSElasticBlockStore.Size())) + n160, err := m.AWSElasticBlockStore.MarshalTo(data[i:]) if err != nil { return 0, err } i += n160 } - if m.ISCSI != nil { - data[i] = 0x42 + if m.GitRepo != nil { + data[i] = 0x2a i++ - i = encodeVarintGenerated(data, i, uint64(m.ISCSI.Size())) - n161, err := m.ISCSI.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.GitRepo.Size())) + n161, err := m.GitRepo.MarshalTo(data[i:]) if err != nil { return 0, err } i += n161 } - if m.Glusterfs != nil { - data[i] = 0x4a + if m.Secret != nil { + data[i] = 0x32 i++ - i = encodeVarintGenerated(data, i, uint64(m.Glusterfs.Size())) - n162, err := m.Glusterfs.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.Secret.Size())) + n162, err := m.Secret.MarshalTo(data[i:]) if err != nil { return 0, err } i += n162 } - if m.PersistentVolumeClaim != nil { - data[i] = 0x52 + if m.NFS != nil { + data[i] = 0x3a i++ - i = encodeVarintGenerated(data, i, uint64(m.PersistentVolumeClaim.Size())) - n163, err := m.PersistentVolumeClaim.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.NFS.Size())) + n163, err := m.NFS.MarshalTo(data[i:]) if err != nil { return 0, err } i += n163 } - if m.RBD != nil { - data[i] = 0x5a + if m.ISCSI != nil { + data[i] = 0x42 i++ - i = encodeVarintGenerated(data, i, uint64(m.RBD.Size())) - n164, err := m.RBD.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.ISCSI.Size())) + n164, err := m.ISCSI.MarshalTo(data[i:]) if err != nil { return 0, err } i += n164 } - if m.FlexVolume != nil { - data[i] = 0x62 + if m.Glusterfs != nil { + data[i] = 0x4a i++ - i = encodeVarintGenerated(data, i, uint64(m.FlexVolume.Size())) - n165, err := m.FlexVolume.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.Glusterfs.Size())) + n165, err := m.Glusterfs.MarshalTo(data[i:]) if err != nil { return 0, err } i += n165 } - if m.Cinder != nil { - data[i] = 0x6a + if m.PersistentVolumeClaim != nil { + data[i] = 0x52 i++ - i = encodeVarintGenerated(data, i, uint64(m.Cinder.Size())) - n166, err := m.Cinder.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.PersistentVolumeClaim.Size())) + n166, err := m.PersistentVolumeClaim.MarshalTo(data[i:]) if err != nil { return 0, err } i += n166 } - if m.CephFS != nil { - data[i] = 0x72 + if m.RBD != nil { + data[i] = 0x5a i++ - i = encodeVarintGenerated(data, i, uint64(m.CephFS.Size())) - n167, err := m.CephFS.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.RBD.Size())) + n167, err := m.RBD.MarshalTo(data[i:]) if err != nil { return 0, err } i += n167 } - if m.Flocker != nil { - data[i] = 0x7a + if m.FlexVolume != nil { + data[i] = 0x62 i++ - i = encodeVarintGenerated(data, i, uint64(m.Flocker.Size())) - n168, err := m.Flocker.MarshalTo(data[i:]) + i = encodeVarintGenerated(data, i, uint64(m.FlexVolume.Size())) + n168, err := m.FlexVolume.MarshalTo(data[i:]) if err != nil { return 0, err } i += n168 } + if m.Cinder != nil { + data[i] = 0x6a + i++ + i = encodeVarintGenerated(data, i, uint64(m.Cinder.Size())) + n169, err := m.Cinder.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n169 + } + if m.CephFS != nil { + data[i] = 0x72 + i++ + i = encodeVarintGenerated(data, i, uint64(m.CephFS.Size())) + n170, err := m.CephFS.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n170 + } + if m.Flocker != nil { + data[i] = 0x7a + i++ + i = encodeVarintGenerated(data, i, uint64(m.Flocker.Size())) + n171, err := m.Flocker.MarshalTo(data[i:]) + if err != nil { + return 0, err + } + i += n171 + } if m.DownwardAPI != nil { data[i] = 0x82 i++ data[i] = 0x1 i++ i = encodeVarintGenerated(data, i, uint64(m.DownwardAPI.Size())) - n169, err := m.DownwardAPI.MarshalTo(data[i:]) + n172, err := m.DownwardAPI.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n169 + i += n172 } if m.FC != nil { data[i] = 0x8a @@ -7466,11 +7528,11 @@ func (m *VolumeSource) MarshalTo(data []byte) (int, error) { data[i] = 0x1 i++ i = encodeVarintGenerated(data, i, uint64(m.FC.Size())) - n170, err := m.FC.MarshalTo(data[i:]) + n173, err := m.FC.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n170 + i += n173 } if m.AzureFile != nil { data[i] = 0x92 @@ -7478,11 +7540,11 @@ func (m *VolumeSource) MarshalTo(data []byte) (int, error) { data[i] = 0x1 i++ i = encodeVarintGenerated(data, i, uint64(m.AzureFile.Size())) - n171, err := m.AzureFile.MarshalTo(data[i:]) + n174, err := m.AzureFile.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n171 + i += n174 } if m.ConfigMap != nil { data[i] = 0x9a @@ -7490,11 +7552,11 @@ func (m *VolumeSource) MarshalTo(data []byte) (int, error) { data[i] = 0x1 i++ i = encodeVarintGenerated(data, i, uint64(m.ConfigMap.Size())) - n172, err := m.ConfigMap.MarshalTo(data[i:]) + n175, err := m.ConfigMap.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n172 + i += n175 } if m.VsphereVolume != nil { data[i] = 0xa2 @@ -7502,11 +7564,11 @@ func (m *VolumeSource) MarshalTo(data []byte) (int, error) { data[i] = 0x1 i++ i = encodeVarintGenerated(data, i, uint64(m.VsphereVolume.Size())) - n173, err := m.VsphereVolume.MarshalTo(data[i:]) + n176, err := m.VsphereVolume.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n173 + i += n176 } return i, nil } @@ -7558,11 +7620,11 @@ func (m *WeightedPodAffinityTerm) MarshalTo(data []byte) (int, error) { data[i] = 0x12 i++ i = encodeVarintGenerated(data, i, uint64(m.PodAffinityTerm.Size())) - n174, err := m.PodAffinityTerm.MarshalTo(data[i:]) + n177, err := m.PodAffinityTerm.MarshalTo(data[i:]) if err != nil { return 0, err } - i += n174 + i += n177 return i, nil } @@ -7988,8 +8050,14 @@ func (m *DownwardAPIVolumeFile) Size() (n int) { _ = l l = len(m.Path) n += 1 + l + sovGenerated(uint64(l)) - l = m.FieldRef.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.FieldRef != nil { + l = m.FieldRef.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.ResourceFieldRef != nil { + l = m.ResourceFieldRef.Size() + n += 1 + l + sovGenerated(uint64(l)) + } return n } @@ -8111,6 +8179,10 @@ func (m *EnvVarSource) Size() (n int) { l = m.FieldRef.Size() n += 1 + l + sovGenerated(uint64(l)) } + if m.ResourceFieldRef != nil { + l = m.ResourceFieldRef.Size() + n += 1 + l + sovGenerated(uint64(l)) + } if m.ConfigMapKeyRef != nil { l = m.ConfigMapKeyRef.Size() n += 1 + l + sovGenerated(uint64(l)) @@ -9539,6 +9611,18 @@ func (m *ReplicationControllerStatus) Size() (n int) { return n } +func (m *ResourceFieldSelector) Size() (n int) { + var l int + _ = l + l = len(m.ContainerName) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.Resource) + n += 1 + l + sovGenerated(uint64(l)) + l = m.Divisor.Size() + n += 1 + l + sovGenerated(uint64(l)) + return n +} + func (m *ResourceQuota) Size() (n int) { var l int _ = l @@ -13897,10 +13981,46 @@ func (m *DownwardAPIVolumeFile) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + if m.FieldRef == nil { + m.FieldRef = &ObjectFieldSelector{} + } if err := m.FieldRef.Unmarshal(data[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceFieldRef", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ResourceFieldRef == nil { + m.ResourceFieldRef = &ResourceFieldSelector{} + } + if err := m.ResourceFieldRef.Unmarshal(data[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenerated(data[iNdEx:]) @@ -14919,6 +15039,39 @@ func (m *EnvVarSource) Unmarshal(data []byte) error { } iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceFieldRef", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ResourceFieldRef == nil { + m.ResourceFieldRef = &ResourceFieldSelector{} + } + if err := m.ResourceFieldRef.Unmarshal(data[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConfigMapKeyRef", wireType) } @@ -14951,7 +15104,7 @@ func (m *EnvVarSource) Unmarshal(data []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SecretKeyRef", wireType) } @@ -29107,6 +29260,144 @@ func (m *ReplicationControllerStatus) Unmarshal(data []byte) error { } return nil } +func (m *ResourceFieldSelector) Unmarshal(data []byte) error { + l := len(data) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceFieldSelector: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceFieldSelector: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContainerName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContainerName = string(data[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Resource = string(data[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Divisor", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Divisor.Unmarshal(data[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(data[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ResourceQuota) Unmarshal(data []byte) error { l := len(data) iNdEx := 0 diff --git a/pkg/api/v1/generated.proto b/pkg/api/v1/generated.proto index 936db15129c..c6e8dfcd627 100644 --- a/pkg/api/v1/generated.proto +++ b/pkg/api/v1/generated.proto @@ -504,6 +504,10 @@ message DownwardAPIVolumeFile { // Required: Selects a field of the pod: only annotations, labels, name and namespace are supported. optional ObjectFieldSelector fieldRef = 2; + + // Selects a resource of the container: only resources limits and requests + // (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported. + optional ResourceFieldSelector resourceFieldRef = 3; } // DownwardAPIVolumeSource represents a volume containing downward API info. @@ -641,11 +645,15 @@ message EnvVarSource { // Selects a field of the pod; only name and namespace are supported. optional ObjectFieldSelector fieldRef = 1; + // Selects a resource of the container: only resources limits and requests + // (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported. + optional ResourceFieldSelector resourceFieldRef = 2; + // Selects a key of a ConfigMap. - optional ConfigMapKeySelector configMapKeyRef = 2; + optional ConfigMapKeySelector configMapKeyRef = 3; // Selects a key of a secret in the pod's namespace - optional SecretKeySelector secretKeyRef = 3; + optional SecretKeySelector secretKeyRef = 4; } // Event is a report of an event somewhere in the cluster. @@ -2345,6 +2353,18 @@ message ReplicationControllerStatus { optional int64 observedGeneration = 3; } +// ResourceFieldSelector represents container resources (cpu, memory) and their output format +message ResourceFieldSelector { + // Container name: required for volumes, optional for env vars + optional string containerName = 1; + + // Required: resource to select + optional string resource = 2; + + // Specifies the output format of the exposed resources, defaults to "1" + optional k8s.io.kubernetes.pkg.api.resource.Quantity divisor = 3; +} + // ResourceQuota sets aggregate quota restrictions enforced per namespace message ResourceQuota { // Standard object's metadata. diff --git a/pkg/api/v1/types.generated.go b/pkg/api/v1/types.generated.go index dd945b1e00d..d590eeb10bd 100644 --- a/pkg/api/v1/types.generated.go +++ b/pkg/api/v1/types.generated.go @@ -15048,15 +15048,16 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [3]bool + var yyq2 [4]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false yyq2[0] = x.FieldRef != nil - yyq2[1] = x.ConfigMapKeyRef != nil - yyq2[2] = x.SecretKeyRef != nil + yyq2[1] = x.ResourceFieldRef != nil + yyq2[2] = x.ConfigMapKeyRef != nil + yyq2[3] = x.SecretKeyRef != nil var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(3) + r.EncodeArrayStart(4) } else { yynn2 = 0 for _, b := range yyq2 { @@ -15093,6 +15094,29 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) if yyq2[1] { + if x.ResourceFieldRef == nil { + r.EncodeNil() + } else { + x.ResourceFieldRef.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("resourceFieldRef")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.ResourceFieldRef == nil { + r.EncodeNil() + } else { + x.ResourceFieldRef.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[2] { if x.ConfigMapKeyRef == nil { r.EncodeNil() } else { @@ -15102,7 +15126,7 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeNil() } } else { - if yyq2[1] { + if yyq2[2] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("configMapKeyRef")) z.EncSendContainerState(codecSelfer_containerMapValue1234) @@ -15115,7 +15139,7 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq2[2] { + if yyq2[3] { if x.SecretKeyRef == nil { r.EncodeNil() } else { @@ -15125,7 +15149,7 @@ func (x *EnvVarSource) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeNil() } } else { - if yyq2[2] { + if yyq2[3] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("secretKeyRef")) z.EncSendContainerState(codecSelfer_containerMapValue1234) @@ -15208,6 +15232,17 @@ func (x *EnvVarSource) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { } x.FieldRef.CodecDecodeSelf(d) } + case "resourceFieldRef": + if r.TryDecodeAsNil() { + if x.ResourceFieldRef != nil { + x.ResourceFieldRef = nil + } + } else { + if x.ResourceFieldRef == nil { + x.ResourceFieldRef = new(ResourceFieldSelector) + } + x.ResourceFieldRef.CodecDecodeSelf(d) + } case "configMapKeyRef": if r.TryDecodeAsNil() { if x.ConfigMapKeyRef != nil { @@ -15241,16 +15276,16 @@ func (x *EnvVarSource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj7 int - var yyb7 bool - var yyhl7 bool = l >= 0 - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l } else { - yyb7 = r.CheckBreak() + yyb8 = r.CheckBreak() } - if yyb7 { + if yyb8 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -15265,13 +15300,34 @@ func (x *EnvVarSource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.FieldRef.CodecDecodeSelf(d) } - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l } else { - yyb7 = r.CheckBreak() + yyb8 = r.CheckBreak() } - if yyb7 { + if yyb8 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.ResourceFieldRef != nil { + x.ResourceFieldRef = nil + } + } else { + if x.ResourceFieldRef == nil { + x.ResourceFieldRef = new(ResourceFieldSelector) + } + x.ResourceFieldRef.CodecDecodeSelf(d) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -15286,13 +15342,13 @@ func (x *EnvVarSource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.ConfigMapKeyRef.CodecDecodeSelf(d) } - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l } else { - yyb7 = r.CheckBreak() + yyb8 = r.CheckBreak() } - if yyb7 { + if yyb8 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -15308,17 +15364,17 @@ func (x *EnvVarSource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { x.SecretKeyRef.CodecDecodeSelf(d) } for { - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l } else { - yyb7 = r.CheckBreak() + yyb8 = r.CheckBreak() } - if yyb7 { + if yyb8 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj7-1, "") + z.DecStructFieldNotFound(yyj8-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -15533,6 +15589,290 @@ func (x *ObjectFieldSelector) codecDecodeSelfFromArray(l int, d *codec1978.Decod z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } +func (x *ResourceFieldSelector) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + var yyq2 [3]bool + _, _, _ = yysep2, yyq2, yy2arr2 + const yyr2 bool = false + yyq2[0] = x.ContainerName != "" + yyq2[2] = true + var yynn2 int + if yyr2 || yy2arr2 { + r.EncodeArrayStart(3) + } else { + yynn2 = 1 + for _, b := range yyq2 { + if b { + yynn2++ + } + } + r.EncodeMapStart(yynn2) + yynn2 = 0 + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[0] { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.ContainerName)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("containerName")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.ContainerName)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Resource)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("resource")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Resource)) + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[2] { + yy10 := &x.Divisor + yym11 := z.EncBinary() + _ = yym11 + if false { + } else if z.HasExtensions() && z.EncExt(yy10) { + } else if !yym11 && z.IsJSONHandle() { + z.EncJSONMarshal(yy10) + } else { + z.EncFallback(yy10) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[2] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("divisor")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy12 := &x.Divisor + yym13 := z.EncBinary() + _ = yym13 + if false { + } else if z.HasExtensions() && z.EncExt(yy12) { + } else if !yym13 && z.IsJSONHandle() { + z.EncJSONMarshal(yy12) + } else { + z.EncFallback(yy12) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *ResourceFieldSelector) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct2 := r.ContainerType() + if yyct2 == codecSelferValueTypeMap1234 { + yyl2 := r.ReadMapStart() + if yyl2 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl2, d) + } + } else if yyct2 == codecSelferValueTypeArray1234 { + yyl2 := r.ReadArrayStart() + if yyl2 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl2, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *ResourceFieldSelector) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys3Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys3Slc + var yyhl3 bool = l >= 0 + for yyj3 := 0; ; yyj3++ { + if yyhl3 { + if yyj3 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys3Slc = r.DecodeBytes(yys3Slc, true, true) + yys3 := string(yys3Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys3 { + case "containerName": + if r.TryDecodeAsNil() { + x.ContainerName = "" + } else { + x.ContainerName = string(r.DecodeString()) + } + case "resource": + if r.TryDecodeAsNil() { + x.Resource = "" + } else { + x.Resource = string(r.DecodeString()) + } + case "divisor": + if r.TryDecodeAsNil() { + x.Divisor = pkg3_resource.Quantity{} + } else { + yyv6 := &x.Divisor + yym7 := z.DecBinary() + _ = yym7 + if false { + } else if z.HasExtensions() && z.DecExt(yyv6) { + } else if !yym7 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv6) + } else { + z.DecFallback(yyv6, false) + } + } + default: + z.DecStructFieldNotFound(-1, yys3) + } // end switch yys3 + } // end for yyj3 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *ResourceFieldSelector) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj8 int + var yyb8 bool + var yyhl8 bool = l >= 0 + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.ContainerName = "" + } else { + x.ContainerName = string(r.DecodeString()) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Resource = "" + } else { + x.Resource = string(r.DecodeString()) + } + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Divisor = pkg3_resource.Quantity{} + } else { + yyv11 := &x.Divisor + yym12 := z.DecBinary() + _ = yym12 + if false { + } else if z.HasExtensions() && z.DecExt(yyv11) { + } else if !yym12 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv11) + } else { + z.DecFallback(yyv11, false) + } + } + for { + yyj8++ + if yyhl8 { + yyb8 = yyj8 > l + } else { + yyb8 = r.CheckBreak() + } + if yyb8 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj8-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + func (x *ConfigMapKeySelector) CodecEncodeSelf(e *codec1978.Encoder) { var h codecSelfer1234 z, r := codec1978.GenHelperEncoder(e) @@ -51106,14 +51446,16 @@ func (x *DownwardAPIVolumeFile) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [2]bool + var yyq2 [3]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false + yyq2[1] = x.FieldRef != nil + yyq2[2] = x.ResourceFieldRef != nil var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(2) + r.EncodeArrayStart(3) } else { - yynn2 = 2 + yynn2 = 1 for _, b := range yyq2 { if b { yynn2++ @@ -51143,14 +51485,49 @@ func (x *DownwardAPIVolumeFile) CodecEncodeSelf(e *codec1978.Encoder) { } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy7 := &x.FieldRef - yy7.CodecEncodeSelf(e) + if yyq2[1] { + if x.FieldRef == nil { + r.EncodeNil() + } else { + x.FieldRef.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } } else { - z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("fieldRef")) - z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy9 := &x.FieldRef - yy9.CodecEncodeSelf(e) + if yyq2[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("fieldRef")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.FieldRef == nil { + r.EncodeNil() + } else { + x.FieldRef.CodecEncodeSelf(e) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[2] { + if x.ResourceFieldRef == nil { + r.EncodeNil() + } else { + x.ResourceFieldRef.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } + } else { + if yyq2[2] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("resourceFieldRef")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.ResourceFieldRef == nil { + r.EncodeNil() + } else { + x.ResourceFieldRef.CodecEncodeSelf(e) + } + } } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) @@ -51221,10 +51598,25 @@ func (x *DownwardAPIVolumeFile) codecDecodeSelfFromMap(l int, d *codec1978.Decod } case "fieldRef": if r.TryDecodeAsNil() { - x.FieldRef = ObjectFieldSelector{} + if x.FieldRef != nil { + x.FieldRef = nil + } } else { - yyv5 := &x.FieldRef - yyv5.CodecDecodeSelf(d) + if x.FieldRef == nil { + x.FieldRef = new(ObjectFieldSelector) + } + x.FieldRef.CodecDecodeSelf(d) + } + case "resourceFieldRef": + if r.TryDecodeAsNil() { + if x.ResourceFieldRef != nil { + x.ResourceFieldRef = nil + } + } else { + if x.ResourceFieldRef == nil { + x.ResourceFieldRef = new(ResourceFieldSelector) + } + x.ResourceFieldRef.CodecDecodeSelf(d) } default: z.DecStructFieldNotFound(-1, yys3) @@ -51237,16 +51629,16 @@ func (x *DownwardAPIVolumeFile) codecDecodeSelfFromArray(l int, d *codec1978.Dec var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l + var yyj7 int + var yyb7 bool + var yyhl7 bool = l >= 0 + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb6 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb6 { + if yyb7 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -51256,35 +51648,60 @@ func (x *DownwardAPIVolumeFile) codecDecodeSelfFromArray(l int, d *codec1978.Dec } else { x.Path = string(r.DecodeString()) } - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb6 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb6 { + if yyb7 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } z.DecSendContainerState(codecSelfer_containerArrayElem1234) if r.TryDecodeAsNil() { - x.FieldRef = ObjectFieldSelector{} + if x.FieldRef != nil { + x.FieldRef = nil + } } else { - yyv8 := &x.FieldRef - yyv8.CodecDecodeSelf(d) + if x.FieldRef == nil { + x.FieldRef = new(ObjectFieldSelector) + } + x.FieldRef.CodecDecodeSelf(d) + } + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l + } else { + yyb7 = r.CheckBreak() + } + if yyb7 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.ResourceFieldRef != nil { + x.ResourceFieldRef = nil + } + } else { + if x.ResourceFieldRef == nil { + x.ResourceFieldRef = new(ResourceFieldSelector) + } + x.ResourceFieldRef.CodecDecodeSelf(d) } for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb6 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb6 { + if yyb7 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj6-1, "") + z.DecStructFieldNotFound(yyj7-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -58597,7 +59014,7 @@ func (x codecSelfer1234) decSliceDownwardAPIVolumeFile(v *[]DownwardAPIVolumeFil yyrg1 := len(yyv1) > 0 yyv21 := yyv1 - yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 48) + yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 32) if yyrt1 { if yyrl1 <= cap(yyv1) { yyv1 = yyv1[:yyrl1] diff --git a/pkg/api/v1/types.go b/pkg/api/v1/types.go index 5c129192530..b45b56b9a69 100644 --- a/pkg/api/v1/types.go +++ b/pkg/api/v1/types.go @@ -938,10 +938,13 @@ type EnvVar struct { type EnvVarSource struct { // Selects a field of the pod; only name and namespace are supported. FieldRef *ObjectFieldSelector `json:"fieldRef,omitempty" protobuf:"bytes,1,opt,name=fieldRef"` + // Selects a resource of the container: only resources limits and requests + // (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported. + ResourceFieldRef *ResourceFieldSelector `json:"resourceFieldRef,omitempty" protobuf:"bytes,2,opt,name=resourceFieldRef"` // Selects a key of a ConfigMap. - ConfigMapKeyRef *ConfigMapKeySelector `json:"configMapKeyRef,omitempty" protobuf:"bytes,2,opt,name=configMapKeyRef"` + ConfigMapKeyRef *ConfigMapKeySelector `json:"configMapKeyRef,omitempty" protobuf:"bytes,3,opt,name=configMapKeyRef"` // Selects a key of a secret in the pod's namespace - SecretKeyRef *SecretKeySelector `json:"secretKeyRef,omitempty" protobuf:"bytes,3,opt,name=secretKeyRef"` + SecretKeyRef *SecretKeySelector `json:"secretKeyRef,omitempty" protobuf:"bytes,4,opt,name=secretKeyRef"` } // ObjectFieldSelector selects an APIVersioned field of an object. @@ -952,6 +955,16 @@ type ObjectFieldSelector struct { FieldPath string `json:"fieldPath" protobuf:"bytes,2,opt,name=fieldPath"` } +// ResourceFieldSelector represents container resources (cpu, memory) and their output format +type ResourceFieldSelector struct { + // Container name: required for volumes, optional for env vars + ContainerName string `json:"containerName,omitempty" protobuf:"bytes,1,opt,name=containerName"` + // Required: resource to select + Resource string `json:"resource" protobuf:"bytes,2,opt,name=resource"` + // Specifies the output format of the exposed resources, defaults to "1" + Divisor resource.Quantity `json:"divisor,omitempty" protobuf:"bytes,3,opt,name=divisor"` +} + // Selects a key from a ConfigMap. type ConfigMapKeySelector struct { // The ConfigMap to select from. @@ -3202,7 +3215,10 @@ type DownwardAPIVolumeFile struct { // Required: Path is the relative path name of the file to be created. Must not be absolute or contain the '..' path. Must be utf-8 encoded. The first item of the relative path must not start with '..' Path string `json:"path" protobuf:"bytes,1,opt,name=path"` // Required: Selects a field of the pod: only annotations, labels, name and namespace are supported. - FieldRef ObjectFieldSelector `json:"fieldRef" protobuf:"bytes,2,opt,name=fieldRef"` + FieldRef *ObjectFieldSelector `json:"fieldRef,omitempty" protobuf:"bytes,2,opt,name=fieldRef"` + // Selects a resource of the container: only resources limits and requests + // (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported. + ResourceFieldRef *ResourceFieldSelector `json:"resourceFieldRef,omitempty" protobuf:"bytes,3,opt,name=resourceFieldRef"` } // SecurityContext holds security configuration that will be applied to a container. diff --git a/pkg/api/v1/types_swagger_doc_generated.go b/pkg/api/v1/types_swagger_doc_generated.go index 398924e6df8..d638c0936ce 100644 --- a/pkg/api/v1/types_swagger_doc_generated.go +++ b/pkg/api/v1/types_swagger_doc_generated.go @@ -307,9 +307,10 @@ func (DeleteOptions) SwaggerDoc() map[string]string { } var map_DownwardAPIVolumeFile = map[string]string{ - "": "DownwardAPIVolumeFile represents information to create the file containing the pod field", - "path": "Required: Path is the relative path name of the file to be created. Must not be absolute or contain the '..' path. Must be utf-8 encoded. The first item of the relative path must not start with '..'", - "fieldRef": "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.", + "": "DownwardAPIVolumeFile represents information to create the file containing the pod field", + "path": "Required: Path is the relative path name of the file to be created. Must not be absolute or contain the '..' path. Must be utf-8 encoded. The first item of the relative path must not start with '..'", + "fieldRef": "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.", + "resourceFieldRef": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.", } func (DownwardAPIVolumeFile) SwaggerDoc() map[string]string { @@ -399,10 +400,11 @@ func (EnvVar) SwaggerDoc() map[string]string { } var map_EnvVarSource = map[string]string{ - "": "EnvVarSource represents a source for the value of an EnvVar.", - "fieldRef": "Selects a field of the pod; only name and namespace are supported.", - "configMapKeyRef": "Selects a key of a ConfigMap.", - "secretKeyRef": "Selects a key of a secret in the pod's namespace", + "": "EnvVarSource represents a source for the value of an EnvVar.", + "fieldRef": "Selects a field of the pod; only name and namespace are supported.", + "resourceFieldRef": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.", + "configMapKeyRef": "Selects a key of a ConfigMap.", + "secretKeyRef": "Selects a key of a secret in the pod's namespace", } func (EnvVarSource) SwaggerDoc() map[string]string { @@ -1394,6 +1396,17 @@ func (ReplicationControllerStatus) SwaggerDoc() map[string]string { return map_ReplicationControllerStatus } +var map_ResourceFieldSelector = map[string]string{ + "": "ResourceFieldSelector represents container resources (cpu, memory) and their output format", + "containerName": "Container name: required for volumes, optional for env vars", + "resource": "Required: resource to select", + "divisor": "Specifies the output format of the exposed resources, defaults to \"1\"", +} + +func (ResourceFieldSelector) SwaggerDoc() map[string]string { + return map_ResourceFieldSelector +} + var map_ResourceQuota = map[string]string{ "": "ResourceQuota sets aggregate quota restrictions enforced per namespace", "metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata", diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index 484c0b6e469..d494f4ec1fb 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -702,7 +702,16 @@ func validateDownwardAPIVolumeSource(downwardAPIVolume *api.DownwardAPIVolumeSou allErrs = append(allErrs, field.Required(fldPath.Child("path"), "")) } allErrs = append(allErrs, validateVolumeSourcePath(downwardAPIVolumeFile.Path, fldPath.Child("path"))...) - allErrs = append(allErrs, validateObjectFieldSelector(&downwardAPIVolumeFile.FieldRef, &validDownwardAPIFieldPathExpressions, fldPath.Child("fieldRef"))...) + if downwardAPIVolumeFile.FieldRef != nil { + allErrs = append(allErrs, validateObjectFieldSelector(downwardAPIVolumeFile.FieldRef, &validDownwardAPIFieldPathExpressions, fldPath.Child("fieldRef"))...) + if downwardAPIVolumeFile.ResourceFieldRef != nil { + allErrs = append(allErrs, field.Invalid(fldPath, "resource", "fieldRef and resourceFieldRef can not be specified simultaneously")) + } + } else if downwardAPIVolumeFile.ResourceFieldRef != nil { + allErrs = append(allErrs, validateContainerResourceFieldSelector(downwardAPIVolumeFile.ResourceFieldRef, &validContainerResourceFieldPathExpressions, fldPath.Child("resourceFieldRef"), true)...) + } else { + allErrs = append(allErrs, field.Required(fldPath, "one of fieldRef and resourceFieldRef is required")) + } } return allErrs } @@ -1048,6 +1057,7 @@ func validateEnv(vars []api.EnvVar, fldPath *field.Path) field.ErrorList { } var validFieldPathExpressionsEnv = sets.NewString("metadata.name", "metadata.namespace", "status.podIP") +var validContainerResourceFieldPathExpressions = sets.NewString("limits.cpu", "limits.memory", "requests.cpu", "requests.memory") func validateEnvVarValueFrom(ev api.EnvVar, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} @@ -1062,6 +1072,10 @@ func validateEnvVarValueFrom(ev api.EnvVar, fldPath *field.Path) field.ErrorList numSources++ allErrs = append(allErrs, validateObjectFieldSelector(ev.ValueFrom.FieldRef, &validFieldPathExpressionsEnv, fldPath.Child("fieldRef"))...) } + if ev.ValueFrom.ResourceFieldRef != nil { + numSources++ + allErrs = append(allErrs, validateContainerResourceFieldSelector(ev.ValueFrom.ResourceFieldRef, &validContainerResourceFieldPathExpressions, fldPath.Child("resourceFieldRef"), false)...) + } if ev.ValueFrom.ConfigMapKeyRef != nil { numSources++ allErrs = append(allErrs, validateConfigMapKeySelector(ev.ValueFrom.ConfigMapKeyRef, fldPath.Child("configMapKeyRef"))...) @@ -1101,6 +1115,42 @@ func validateObjectFieldSelector(fs *api.ObjectFieldSelector, expressions *sets. return allErrs } +func validateContainerResourceFieldSelector(fs *api.ResourceFieldSelector, expressions *sets.String, fldPath *field.Path, volume bool) field.ErrorList { + allErrs := field.ErrorList{} + + if volume && len(fs.ContainerName) == 0 { + allErrs = append(allErrs, field.Required(fldPath.Child("containerName"), "")) + } else if len(fs.Resource) == 0 { + allErrs = append(allErrs, field.Required(fldPath.Child("resource"), "")) + } else if !expressions.Has(fs.Resource) { + allErrs = append(allErrs, field.NotSupported(fldPath.Child("resource"), fs.Resource, expressions.List())) + } + allErrs = append(allErrs, validateContainerResourceDivisor(fs.Resource, fs.Divisor, fldPath)...) + return allErrs +} + +var validContainerResourceDivisorForCPU = sets.NewString("1m", "1") +var validContainerResourceDivisorForMemory = sets.NewString("1m", "1", "1k", "1M", "1G", "1T", "1P", "1E", "1Ki", "1Mi", "1Gi", "1Ti", "1Pi", "1Ei") + +func validateContainerResourceDivisor(rName string, divisor resource.Quantity, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + unsetDivisor := resource.Quantity{} + if unsetDivisor.Cmp(divisor) == 0 { + return allErrs + } + switch rName { + case "limits.cpu", "requests.cpu": + if !validContainerResourceDivisorForCPU.Has(divisor.String()) { + allErrs = append(allErrs, field.Invalid(fldPath.Child("divisor"), rName, fmt.Sprintf("only divisor's values 1m and 1 are supported with the cpu resource"))) + } + case "limits.memory", "requests.memory": + if !validContainerResourceDivisorForMemory.Has(divisor.String()) { + allErrs = append(allErrs, field.Invalid(fldPath.Child("divisor"), rName, fmt.Sprintf("only divisor's values 1m, 1, 1k, 1M, 1G, 1T, 1P, 1E, 1Ki, 1Mi, 1Gi, 1Ti, 1Pi, 1Ei are supported with the memory resource"))) + } + } + return allErrs +} + func validateConfigMapKeySelector(s *api.ConfigMapKeySelector, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 4451364e8f6..2da1d313277 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -656,30 +656,42 @@ func TestValidateVolumes(t *testing.T) { {Name: "cinder", VolumeSource: api.VolumeSource{Cinder: &api.CinderVolumeSource{VolumeID: "29ea5088-4f60-4757-962e-dba678767887", FSType: "ext4", ReadOnly: false}}}, {Name: "cephfs", VolumeSource: api.VolumeSource{CephFS: &api.CephFSVolumeSource{Monitors: []string{"foo"}}}}, {Name: "downwardapi", VolumeSource: api.VolumeSource{DownwardAPI: &api.DownwardAPIVolumeSource{Items: []api.DownwardAPIVolumeFile{ - {Path: "labels", FieldRef: api.ObjectFieldSelector{ + {Path: "labels", FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}, - {Path: "annotations", FieldRef: api.ObjectFieldSelector{ + {Path: "annotations", FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.annotations"}}, - {Path: "namespace", FieldRef: api.ObjectFieldSelector{ + {Path: "namespace", FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.namespace"}}, - {Path: "name", FieldRef: api.ObjectFieldSelector{ + {Path: "name", FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.name"}}, - {Path: "path/withslash/andslash", FieldRef: api.ObjectFieldSelector{ + {Path: "path/withslash/andslash", FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}, - {Path: "path/./withdot", FieldRef: api.ObjectFieldSelector{ + {Path: "path/./withdot", FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}, - {Path: "path/with..dot", FieldRef: api.ObjectFieldSelector{ + {Path: "path/with..dot", FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}, - {Path: "second-level-dirent-can-have/..dot", FieldRef: api.ObjectFieldSelector{ + {Path: "second-level-dirent-can-have/..dot", FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}, + {Path: "cpu_limit", ResourceFieldRef: &api.ResourceFieldSelector{ + ContainerName: "test-container", + Resource: "limits.cpu"}}, + {Path: "cpu_request", ResourceFieldRef: &api.ResourceFieldSelector{ + ContainerName: "test-container", + Resource: "requests.cpu"}}, + {Path: "memory_limit", ResourceFieldRef: &api.ResourceFieldSelector{ + ContainerName: "test-container", + Resource: "limits.memory"}}, + {Path: "memory_request", ResourceFieldRef: &api.ResourceFieldSelector{ + ContainerName: "test-container", + Resource: "requests.memory"}}, }}}}, {Name: "fc", VolumeSource: api.VolumeSource{FC: &api.FCVolumeSource{TargetWWNs: []string{"some_wwn"}, Lun: &lun, FSType: "ext4", ReadOnly: false}}}, {Name: "flexvolume", VolumeSource: api.VolumeSource{FlexVolume: &api.FlexVolumeSource{Driver: "kubernetes.io/blue", FSType: "ext4"}}}, @@ -705,30 +717,38 @@ func TestValidateVolumes(t *testing.T) { containsDots := api.VolumeSource{GitRepo: &api.GitRepoVolumeSource{Repository: "foo", Directory: "dots/../bar"}} absPath := api.VolumeSource{GitRepo: &api.GitRepoVolumeSource{Repository: "foo", Directory: "/abstarget"}} emptyPathName := api.VolumeSource{DownwardAPI: &api.DownwardAPIVolumeSource{Items: []api.DownwardAPIVolumeFile{{Path: "", - FieldRef: api.ObjectFieldSelector{ + FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}}, }} absolutePathName := api.VolumeSource{DownwardAPI: &api.DownwardAPIVolumeSource{Items: []api.DownwardAPIVolumeFile{{Path: "/absolutepath", - FieldRef: api.ObjectFieldSelector{ + FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}}, }} dotDotInPath := api.VolumeSource{DownwardAPI: &api.DownwardAPIVolumeSource{Items: []api.DownwardAPIVolumeFile{{Path: "../../passwd", - FieldRef: api.ObjectFieldSelector{ + FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}}, }} dotDotPathName := api.VolumeSource{DownwardAPI: &api.DownwardAPIVolumeSource{Items: []api.DownwardAPIVolumeFile{{Path: "..badFileName", - FieldRef: api.ObjectFieldSelector{ + FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}}, }} dotDotFirstLevelDirent := api.VolumeSource{DownwardAPI: &api.DownwardAPIVolumeSource{Items: []api.DownwardAPIVolumeFile{{Path: "..badDirName/goodFileName", - FieldRef: api.ObjectFieldSelector{ + FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels"}}}, }} + fieldRefandResourceFieldRef := api.VolumeSource{DownwardAPI: &api.DownwardAPIVolumeSource{Items: []api.DownwardAPIVolumeFile{{Path: "test", + FieldRef: &api.ObjectFieldSelector{ + APIVersion: "v1", + FieldPath: "metadata.labels"}, + ResourceFieldRef: &api.ResourceFieldSelector{ + ContainerName: "test-container", + Resource: "requests.memory"}}}, + }} zeroWWN := api.VolumeSource{FC: &api.FCVolumeSource{TargetWWNs: []string{}, Lun: &lun, FSType: "ext4", ReadOnly: false}} emptyLun := api.VolumeSource{FC: &api.FCVolumeSource{TargetWWNs: []string{"wwn"}, Lun: nil, FSType: "ext4", ReadOnly: false}} slashInName := api.VolumeSource{Flocker: &api.FlockerVolumeSource{DatasetName: "foo/bar"}} @@ -865,6 +885,11 @@ func TestValidateVolumes(t *testing.T) { field.ErrorTypeRequired, "azureFile.shareName", "", }, + "fieldRef and ResourceFieldRef together": { + []api.Volume{{Name: "testvolume", VolumeSource: fieldRefandResourceFieldRef}}, + field.ErrorTypeInvalid, + "downwardAPI", "fieldRef and resourceFieldRef can not be specified simultaneously", + }, } for k, v := range errorCases { _, errs := validateVolumes(v.V, field.NewPath("field")) diff --git a/pkg/fieldpath/fieldpath.go b/pkg/fieldpath/fieldpath.go index 88c8a3131c4..30da2266476 100644 --- a/pkg/fieldpath/fieldpath.go +++ b/pkg/fieldpath/fieldpath.go @@ -18,8 +18,12 @@ package fieldpath import ( "fmt" + "math" + "strconv" + "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/meta" + "k8s.io/kubernetes/pkg/api/resource" ) // formatMap formats map[string]string to a string. @@ -58,3 +62,61 @@ func ExtractFieldPathAsString(obj interface{}, fieldPath string) (string, error) return "", fmt.Errorf("Unsupported fieldPath: %v", fieldPath) } + +// ExtractResourceValueByContainerName extracts the value of a resource +// by providing container name +func ExtractResourceValueByContainerName(fs *api.ResourceFieldSelector, pod *api.Pod, containerName string) (string, error) { + container, err := findContainerInPod(pod, containerName) + if err != nil { + return "", err + } + return ExtractContainerResourceValue(fs, container) +} + +// ExtractContainerResourceValue extracts the value of a resource +// in an already known container +func ExtractContainerResourceValue(fs *api.ResourceFieldSelector, container *api.Container) (string, error) { + divisor := resource.Quantity{} + if divisor.Cmp(fs.Divisor) == 0 { + divisor = resource.MustParse("1") + } else { + divisor = fs.Divisor + } + + switch fs.Resource { + case "limits.cpu": + return convertResourceCPUToString(container.Resources.Limits.Cpu(), divisor) + case "limits.memory": + return convertResourceMemoryToString(container.Resources.Limits.Memory(), divisor) + case "requests.cpu": + return convertResourceCPUToString(container.Resources.Requests.Cpu(), divisor) + case "requests.memory": + return convertResourceMemoryToString(container.Resources.Requests.Memory(), divisor) + } + + return "", fmt.Errorf("Unsupported container resource : %v", fs.Resource) +} + +// findContainerInPod finds a container by its name in the provided pod +func findContainerInPod(pod *api.Pod, containerName string) (*api.Container, error) { + for _, container := range pod.Spec.Containers { + if container.Name == containerName { + return &container, nil + } + } + return nil, fmt.Errorf("container %s not found", containerName) +} + +// convertResourceCPUTOString converts cpu value to the format of divisor and returns +// ceiling of the value. +func convertResourceCPUToString(cpu *resource.Quantity, divisor resource.Quantity) (string, error) { + c := int64(math.Ceil(float64(cpu.MilliValue()) / float64(divisor.MilliValue()))) + return strconv.FormatInt(c, 10), nil +} + +// convertResourceMemoryToString converts memory value to the format of divisor and returns +// ceiling of the value. +func convertResourceMemoryToString(memory *resource.Quantity, divisor resource.Quantity) (string, error) { + m := int64(math.Ceil(float64(memory.Value()) / float64(divisor.Value()))) + return strconv.FormatInt(m, 10), nil +} diff --git a/pkg/kubectl/describe.go b/pkg/kubectl/describe.go index d0201a197b5..e9b22108038 100644 --- a/pkg/kubectl/describe.go +++ b/pkg/kubectl/describe.go @@ -700,7 +700,12 @@ func printRBDVolumeSource(rbd *api.RBDVolumeSource, out io.Writer) { func printDownwardAPIVolumeSource(d *api.DownwardAPIVolumeSource, out io.Writer) { fmt.Fprintf(out, " Type:\tDownwardAPI (a volume populated by information about the pod)\n Items:\n") for _, mapping := range d.Items { - fmt.Fprintf(out, " %v -> %v\n", mapping.FieldRef.FieldPath, mapping.Path) + if mapping.FieldRef != nil { + fmt.Fprintf(out, " %v -> %v\n", mapping.FieldRef.FieldPath, mapping.Path) + } + if mapping.ResourceFieldRef != nil { + fmt.Fprintf(out, " %v -> %v\n", mapping.ResourceFieldRef.Resource, mapping.Path) + } } } @@ -895,6 +900,12 @@ func describeContainers(label string, containers []api.Container, containerStatu valueFrom = resolverFn(e) } fmt.Fprintf(out, " %s:\t%s (%s:%s)\n", e.Name, valueFrom, e.ValueFrom.FieldRef.APIVersion, e.ValueFrom.FieldRef.FieldPath) + case e.ValueFrom.ResourceFieldRef != nil: + valueFrom, err := fieldpath.ExtractContainerResourceValue(e.ValueFrom.ResourceFieldRef, &container) + if err != nil { + valueFrom = "" + } + fmt.Fprintf(out, " %s:\t%s (%s)\n", e.Name, valueFrom, e.ValueFrom.ResourceFieldRef.Resource) case e.ValueFrom.SecretKeyRef != nil: fmt.Fprintf(out, " %s:\t\n", e.Name, e.ValueFrom.SecretKeyRef.Key, e.ValueFrom.SecretKeyRef.Name) case e.ValueFrom.ConfigMapKeyRef != nil: diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index d09ace61b67..32f799adbb9 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -1506,6 +1506,11 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *api.Pod, container *api.Contain if err != nil { return result, err } + case envVar.ValueFrom.ResourceFieldRef != nil: + runtimeVal, err = containerResourceRuntimeValue(envVar.ValueFrom.ResourceFieldRef, pod, container) + if err != nil { + return result, err + } case envVar.ValueFrom.ConfigMapKeyRef != nil: name := envVar.ValueFrom.ConfigMapKeyRef.Name key := envVar.ValueFrom.ConfigMapKeyRef.Key @@ -1563,6 +1568,16 @@ func (kl *Kubelet) podFieldSelectorRuntimeValue(fs *api.ObjectFieldSelector, pod return fieldpath.ExtractFieldPathAsString(pod, internalFieldPath) } +// containerResourceRuntimeValue returns the value of the provided container resource +func containerResourceRuntimeValue(fs *api.ResourceFieldSelector, pod *api.Pod, container *api.Container) (string, error) { + containerName := fs.ContainerName + if len(containerName) == 0 { + return fieldpath.ExtractContainerResourceValue(fs, container) + } else { + return fieldpath.ExtractResourceValueByContainerName(fs, pod, containerName) + } +} + // GetClusterDNS returns a list of the DNS servers and a list of the DNS search // domains of the cluster. func (kl *Kubelet) GetClusterDNS(pod *api.Pod) ([]string, []string, error) { diff --git a/pkg/volume/downwardapi/downwardapi.go b/pkg/volume/downwardapi/downwardapi.go index 571172aba04..61ab64d12f0 100644 --- a/pkg/volume/downwardapi/downwardapi.go +++ b/pkg/volume/downwardapi/downwardapi.go @@ -69,14 +69,11 @@ func (plugin *downwardAPIPlugin) CanSupport(spec *volume.Spec) bool { func (plugin *downwardAPIPlugin) NewMounter(spec *volume.Spec, pod *api.Pod, opts volume.VolumeOptions) (volume.Mounter, error) { v := &downwardAPIVolume{ volName: spec.Name(), + items: spec.Volume.DownwardAPI.Items, pod: pod, podUID: pod.UID, plugin: plugin, } - v.fieldReferenceFileNames = make(map[string]string) - for _, fileInfo := range spec.Volume.DownwardAPI.Items { - v.fieldReferenceFileNames[fileInfo.FieldRef.FieldPath] = path.Clean(fileInfo.Path) - } return &downwardAPIVolumeMounter{ downwardAPIVolume: v, opts: &opts, @@ -95,11 +92,11 @@ func (plugin *downwardAPIPlugin) NewUnmounter(volName string, podUID types.UID) // downwardAPIVolume retrieves downward API data and placing them into the volume on the host. type downwardAPIVolume struct { - volName string - fieldReferenceFileNames map[string]string - pod *api.Pod - podUID types.UID // TODO: remove this redundancy as soon NewUnmounter func will have *api.POD and not only types.UID - plugin *downwardAPIPlugin + volName string + items []api.DownwardAPIVolumeFile + pod *api.Pod + podUID types.UID // TODO: remove this redundancy as soon NewUnmounter func will have *api.POD and not only types.UID + plugin *downwardAPIPlugin volume.MetricsNil } @@ -173,12 +170,22 @@ func (b *downwardAPIVolumeMounter) SetUpAt(dir string, fsGroup *int64) error { func (d *downwardAPIVolume) collectData() (map[string][]byte, error) { errlist := []error{} data := make(map[string][]byte) - for fieldReference, fileName := range d.fieldReferenceFileNames { - if values, err := fieldpath.ExtractFieldPathAsString(d.pod, fieldReference); err != nil { - glog.Errorf("Unable to extract field %s: %s", fieldReference, err.Error()) - errlist = append(errlist, err) - } else { - data[fileName] = []byte(sortLines(values)) + for _, fileInfo := range d.items { + if fileInfo.FieldRef != nil { + if values, err := fieldpath.ExtractFieldPathAsString(d.pod, fileInfo.FieldRef.FieldPath); err != nil { + glog.Errorf("Unable to extract field %s: %s", fileInfo.FieldRef.FieldPath, err.Error()) + errlist = append(errlist, err) + } else { + data[path.Clean(fileInfo.Path)] = []byte(sortLines(values)) + } + } else if fileInfo.ResourceFieldRef != nil { + containerName := fileInfo.ResourceFieldRef.ContainerName + if values, err := fieldpath.ExtractResourceValueByContainerName(fileInfo.ResourceFieldRef, d.pod, containerName); err != nil { + glog.Errorf("Unable to extract field %s: %s", fileInfo.ResourceFieldRef.Resource, err.Error()) + errlist = append(errlist, err) + } else { + data[path.Clean(fileInfo.Path)] = []byte(sortLines(values)) + } } } return data, utilerrors.NewAggregate(errlist) diff --git a/pkg/volume/downwardapi/downwardapi_test.go b/pkg/volume/downwardapi/downwardapi_test.go index b47f3ea9560..b3767ae35ac 100644 --- a/pkg/volume/downwardapi/downwardapi_test.go +++ b/pkg/volume/downwardapi/downwardapi_test.go @@ -115,7 +115,7 @@ func TestLabels(t *testing.T) { VolumeSource: api.VolumeSource{ DownwardAPI: &api.DownwardAPIVolumeSource{ Items: []api.DownwardAPIVolumeFile{ - {Path: "labels", FieldRef: api.ObjectFieldSelector{ + {Path: "labels", FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.labels"}}}}, }, } @@ -179,7 +179,7 @@ func TestAnnotations(t *testing.T) { VolumeSource: api.VolumeSource{ DownwardAPI: &api.DownwardAPIVolumeSource{ Items: []api.DownwardAPIVolumeFile{ - {Path: "annotations", FieldRef: api.ObjectFieldSelector{ + {Path: "annotations", FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.annotations"}}}}, }, } @@ -242,7 +242,7 @@ func TestName(t *testing.T) { VolumeSource: api.VolumeSource{ DownwardAPI: &api.DownwardAPIVolumeSource{ Items: []api.DownwardAPIVolumeFile{ - {Path: "name_file_name", FieldRef: api.ObjectFieldSelector{ + {Path: "name_file_name", FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.name"}}}}, }, } @@ -305,7 +305,7 @@ func TestNamespace(t *testing.T) { VolumeSource: api.VolumeSource{ DownwardAPI: &api.DownwardAPIVolumeSource{ Items: []api.DownwardAPIVolumeFile{ - {Path: "namespace_file_name", FieldRef: api.ObjectFieldSelector{ + {Path: "namespace_file_name", FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.namespace"}}}}, }, } @@ -383,7 +383,7 @@ func TestWriteTwiceNoUpdate(t *testing.T) { VolumeSource: api.VolumeSource{ DownwardAPI: &api.DownwardAPIVolumeSource{ Items: []api.DownwardAPIVolumeFile{ - {Path: "labels", FieldRef: api.ObjectFieldSelector{ + {Path: "labels", FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.labels"}}}}, }, } @@ -469,7 +469,7 @@ func TestWriteTwiceWithUpdate(t *testing.T) { VolumeSource: api.VolumeSource{ DownwardAPI: &api.DownwardAPIVolumeSource{ Items: []api.DownwardAPIVolumeFile{ - {Path: "labels", FieldRef: api.ObjectFieldSelector{ + {Path: "labels", FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.labels"}}}}, }, } @@ -575,9 +575,9 @@ func TestWriteWithUnixPath(t *testing.T) { VolumeSource: api.VolumeSource{ DownwardAPI: &api.DownwardAPIVolumeSource{ Items: []api.DownwardAPIVolumeFile{ - {Path: "this/is/mine/labels", FieldRef: api.ObjectFieldSelector{ + {Path: "this/is/mine/labels", FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.labels"}}, - {Path: "this/is/yours/annotations", FieldRef: api.ObjectFieldSelector{ + {Path: "this/is/yours/annotations", FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.annotations"}}, }}}, } @@ -657,7 +657,7 @@ func TestWriteWithUnixPathBadPath(t *testing.T) { Items: []api.DownwardAPIVolumeFile{ { Path: "this//labels", - FieldRef: api.ObjectFieldSelector{ + FieldRef: &api.ObjectFieldSelector{ FieldPath: "metadata.labels", }, }, diff --git a/test/e2e/downward_api.go b/test/e2e/downward_api.go index 1014d8ee371..6a2fdca1931 100644 --- a/test/e2e/downward_api.go +++ b/test/e2e/downward_api.go @@ -20,6 +20,7 @@ import ( "fmt" "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/test/e2e/framework" @@ -80,6 +81,53 @@ var _ = framework.KubeDescribe("Downward API", func() { testDownwardAPI(f, podName, env, expectations) }) + + It("should provide container's limits.cpu/memory and requests.cpu/memory as env vars", func() { + podName := "downward-api-" + string(util.NewUUID()) + env := []api.EnvVar{ + { + Name: "CPU_LIMIT", + ValueFrom: &api.EnvVarSource{ + ResourceFieldRef: &api.ResourceFieldSelector{ + Resource: "limits.cpu", + }, + }, + }, + { + Name: "MEMORY_LIMIT", + ValueFrom: &api.EnvVarSource{ + ResourceFieldRef: &api.ResourceFieldSelector{ + Resource: "limits.memory", + }, + }, + }, + { + Name: "CPU_REQUEST", + ValueFrom: &api.EnvVarSource{ + ResourceFieldRef: &api.ResourceFieldSelector{ + Resource: "requests.cpu", + }, + }, + }, + { + Name: "MEMORY_REQUEST", + ValueFrom: &api.EnvVarSource{ + ResourceFieldRef: &api.ResourceFieldSelector{ + Resource: "requests.memory", + }, + }, + }, + } + expectations := []string{ + fmt.Sprintf("CPU_LIMIT=2"), + fmt.Sprintf("MEMORY_LIMIT=67108864"), + fmt.Sprintf("CPU_REQUEST=1"), + fmt.Sprintf("MEMORY_REQUEST=33554432"), + } + + testDownwardAPI(f, podName, env, expectations) + }) + }) func testDownwardAPI(f *framework.Framework, podName string, env []api.EnvVar, expectations []string) { @@ -94,7 +142,17 @@ func testDownwardAPI(f *framework.Framework, podName string, env []api.EnvVar, e Name: "dapi-container", Image: "gcr.io/google_containers/busybox:1.24", Command: []string{"sh", "-c", "env"}, - Env: env, + Resources: api.ResourceRequirements{ + Requests: api.ResourceList{ + api.ResourceCPU: resource.MustParse("250m"), + api.ResourceMemory: resource.MustParse("32Mi"), + }, + Limits: api.ResourceList{ + api.ResourceCPU: resource.MustParse("1250m"), + api.ResourceMemory: resource.MustParse("64Mi"), + }, + }, + Env: env, }, }, RestartPolicy: api.RestartPolicyNever, diff --git a/test/e2e/downwardapi_volume.go b/test/e2e/downwardapi_volume.go index 5b7232bf722..be7a75b1f48 100644 --- a/test/e2e/downwardapi_volume.go +++ b/test/e2e/downwardapi_volume.go @@ -21,6 +21,7 @@ import ( "time" "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/test/e2e/framework" @@ -131,6 +132,43 @@ var _ = framework.KubeDescribe("Downward API volume", func() { podLogTimeout, framework.Poll).Should(ContainSubstring("builder=\"foo\"\n")) }) + + It("should provide container's cpu limit", func() { + podName := "downwardapi-volume-" + string(util.NewUUID()) + pod := downwardAPIVolumeForContainerResources(podName, "/etc/cpu_limit") + + framework.TestContainerOutput("downward API volume plugin", f.Client, pod, 0, []string{ + fmt.Sprintf("2\n"), + }, f.Namespace.Name) + }) + + It("should provide container's memory limit", func() { + podName := "downwardapi-volume-" + string(util.NewUUID()) + pod := downwardAPIVolumeForContainerResources(podName, "/etc/memory_limit") + + framework.TestContainerOutput("downward API volume plugin", f.Client, pod, 0, []string{ + fmt.Sprintf("67108864\n"), + }, f.Namespace.Name) + }) + + It("should provide container's cpu request", func() { + podName := "downwardapi-volume-" + string(util.NewUUID()) + pod := downwardAPIVolumeForContainerResources(podName, "/etc/cpu_request") + + framework.TestContainerOutput("downward API volume plugin", f.Client, pod, 0, []string{ + fmt.Sprintf("1\n"), + }, f.Namespace.Name) + }) + + It("should provide container's memory request", func() { + podName := "downwardapi-volume-" + string(util.NewUUID()) + pod := downwardAPIVolumeForContainerResources(podName, "/etc/memory_request") + + framework.TestContainerOutput("downward API volume plugin", f.Client, pod, 0, []string{ + fmt.Sprintf("33554432\n"), + }, f.Namespace.Name) + }) + }) func downwardAPIVolumePodForSimpleTest(name string, filePath string) *api.Pod { @@ -154,6 +192,40 @@ func downwardAPIVolumePodForSimpleTest(name string, filePath string) *api.Pod { return pod } +func downwardAPIVolumeForContainerResources(name string, filePath string) *api.Pod { + pod := downwardAPIVolumeBasePod(name, nil, nil) + pod.Spec.Containers = downwardAPIVolumeBaseContainers("client-container", filePath) + return pod +} + +func downwardAPIVolumeBaseContainers(name, filePath string) []api.Container { + return []api.Container{ + { + Name: name, + Image: "gcr.io/google_containers/mounttest:0.6", + Command: []string{"/mt", "--file_content=" + filePath}, + Resources: api.ResourceRequirements{ + Requests: api.ResourceList{ + api.ResourceCPU: resource.MustParse("250m"), + api.ResourceMemory: resource.MustParse("32Mi"), + }, + Limits: api.ResourceList{ + api.ResourceCPU: resource.MustParse("1250m"), + api.ResourceMemory: resource.MustParse("64Mi"), + }, + }, + VolumeMounts: []api.VolumeMount{ + { + Name: "podinfo", + MountPath: "/etc", + ReadOnly: false, + }, + }, + }, + } + +} + func downwardAPIVolumePodForUpdateTest(name string, labels, annotations map[string]string, filePath string) *api.Pod { pod := downwardAPIVolumeBasePod(name, labels, annotations) @@ -192,11 +264,39 @@ func downwardAPIVolumeBasePod(name string, labels, annotations map[string]string Items: []api.DownwardAPIVolumeFile{ { Path: "podname", - FieldRef: api.ObjectFieldSelector{ + FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.name", }, }, + { + Path: "cpu_limit", + ResourceFieldRef: &api.ResourceFieldSelector{ + ContainerName: "client-container", + Resource: "limits.cpu", + }, + }, + { + Path: "cpu_request", + ResourceFieldRef: &api.ResourceFieldSelector{ + ContainerName: "client-container", + Resource: "requests.cpu", + }, + }, + { + Path: "memory_limit", + ResourceFieldRef: &api.ResourceFieldSelector{ + ContainerName: "client-container", + Resource: "limits.memory", + }, + }, + { + Path: "memory_request", + ResourceFieldRef: &api.ResourceFieldSelector{ + ContainerName: "client-container", + Resource: "requests.memory", + }, + }, }, }, }, @@ -213,7 +313,7 @@ func applyLabelsAndAnnotationsToDownwardAPIPod(labels, annotations map[string]st if len(labels) > 0 { pod.Spec.Volumes[0].DownwardAPI.Items = append(pod.Spec.Volumes[0].DownwardAPI.Items, api.DownwardAPIVolumeFile{ Path: "labels", - FieldRef: api.ObjectFieldSelector{ + FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.labels", }, @@ -223,7 +323,7 @@ func applyLabelsAndAnnotationsToDownwardAPIPod(labels, annotations map[string]st if len(annotations) > 0 { pod.Spec.Volumes[0].DownwardAPI.Items = append(pod.Spec.Volumes[0].DownwardAPI.Items, api.DownwardAPIVolumeFile{ Path: "annotations", - FieldRef: api.ObjectFieldSelector{ + FieldRef: &api.ObjectFieldSelector{ APIVersion: "v1", FieldPath: "metadata.annotations", },