From 3ba8e9e80ee3123d5936fdfb95095418008a8756 Mon Sep 17 00:00:00 2001 From: Lan Liang Date: Thu, 16 May 2024 08:36:27 +0000 Subject: [PATCH] make PodIP.IP and HostIP.IP required. Fields used as map keys must be required or defaulted when used in a CRD schema. see https://github.com/kubernetes/kubernetes/issues/124540 Signed-off-by: Lan Liang --- api/openapi-spec/swagger.json | 6 ++++++ api/openapi-spec/v3/api__v1_openapi.json | 8 ++++++++ pkg/generated/openapi/zz_generated.openapi.go | 4 ++++ staging/src/k8s.io/api/core/v1/generated.proto | 2 ++ staging/src/k8s.io/api/core/v1/types.go | 6 ++++-- .../client-go/applyconfigurations/internal/internal.go | 2 ++ 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index ba625f8113f..87eb78e1f6b 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -7500,6 +7500,9 @@ "type": "string" } }, + "required": [ + "ip" + ], "type": "object" }, "io.k8s.api.core.v1.HostPathVolumeSource": { @@ -9282,6 +9285,9 @@ "type": "string" } }, + "required": [ + "ip" + ], "type": "object" }, "io.k8s.api.core.v1.PodList": { diff --git a/api/openapi-spec/v3/api__v1_openapi.json b/api/openapi-spec/v3/api__v1_openapi.json index f0c1ddfb169..e55b15b33a9 100644 --- a/api/openapi-spec/v3/api__v1_openapi.json +++ b/api/openapi-spec/v3/api__v1_openapi.json @@ -2802,10 +2802,14 @@ "description": "HostIP represents a single IP address allocated to the host.", "properties": { "ip": { + "default": "", "description": "IP is the IP address assigned to the host", "type": "string" } }, + "required": [ + "ip" + ], "type": "object" }, "io.k8s.api.core.v1.HostPathVolumeSource": { @@ -5119,10 +5123,14 @@ "description": "PodIP represents a single IP address allocated to the pod.", "properties": { "ip": { + "default": "", "description": "IP is the IP address assigned to the pod", "type": "string" } }, + "required": [ + "ip" + ], "type": "object" }, "io.k8s.api.core.v1.PodList": { diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index d946c42c3a9..05a6bc83e3b 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -23016,11 +23016,13 @@ func schema_k8sio_api_core_v1_HostIP(ref common.ReferenceCallback) common.OpenAP "ip": { SchemaProps: spec.SchemaProps{ Description: "IP is the IP address assigned to the host", + Default: "", Type: []string{"string"}, Format: "", }, }, }, + Required: []string{"ip"}, }, }, } @@ -26684,11 +26686,13 @@ func schema_k8sio_api_core_v1_PodIP(ref common.ReferenceCallback) common.OpenAPI "ip": { SchemaProps: spec.SchemaProps{ Description: "IP is the IP address assigned to the pod", + Default: "", Type: []string{"string"}, Format: "", }, }, }, + Required: []string{"ip"}, }, }, } diff --git a/staging/src/k8s.io/api/core/v1/generated.proto b/staging/src/k8s.io/api/core/v1/generated.proto index f3b47c722d1..9ebc9b91bc5 100644 --- a/staging/src/k8s.io/api/core/v1/generated.proto +++ b/staging/src/k8s.io/api/core/v1/generated.proto @@ -1997,6 +1997,7 @@ message HostAlias { // HostIP represents a single IP address allocated to the host. message HostIP { // IP is the IP address assigned to the host + // +required optional string ip = 1; } @@ -3693,6 +3694,7 @@ message PodExecOptions { // PodIP represents a single IP address allocated to the pod. message PodIP { // IP is the IP address assigned to the pod + // +required optional string ip = 1; } diff --git a/staging/src/k8s.io/api/core/v1/types.go b/staging/src/k8s.io/api/core/v1/types.go index 328df9a7b7d..d5eca377592 100644 --- a/staging/src/k8s.io/api/core/v1/types.go +++ b/staging/src/k8s.io/api/core/v1/types.go @@ -4340,13 +4340,15 @@ type PodDNSConfigOption struct { // PodIP represents a single IP address allocated to the pod. type PodIP struct { // IP is the IP address assigned to the pod - IP string `json:"ip,omitempty" protobuf:"bytes,1,opt,name=ip"` + // +required + IP string `json:"ip" protobuf:"bytes,1,opt,name=ip"` } // HostIP represents a single IP address allocated to the host. type HostIP struct { // IP is the IP address assigned to the host - IP string `json:"ip,omitempty" protobuf:"bytes,1,opt,name=ip"` + // +required + IP string `json:"ip" protobuf:"bytes,1,opt,name=ip"` } // EphemeralContainerCommon is a copy of all fields in Container to be inlined in diff --git a/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go b/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go index 47bfb44e0c3..5cc22c97000 100644 --- a/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go +++ b/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go @@ -5661,6 +5661,7 @@ var schemaYAML = typed.YAMLObject(`types: - name: ip type: scalar: string + default: "" - name: io.k8s.api.core.v1.HostPathVolumeSource map: fields: @@ -6747,6 +6748,7 @@ var schemaYAML = typed.YAMLObject(`types: - name: ip type: scalar: string + default: "" - name: io.k8s.api.core.v1.PodOS map: fields: