From 15001b51518ecbc90751dfb36b40ee58cd160cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Sat, 4 May 2024 00:21:14 +0200 Subject: [PATCH] fix(api): make LocalObjectReference.Name and HostAlias.IP required (#124553) * fix(api): LocalObjectReference Name a "" default and make HostAlias.IP required * chore(api): add LocalObjectReference comment * chore(api): add omitempty to LocalObjectReference's Name * chore(api): add kubebuilder:default annotation * chore(api): ./hack/update-codegen.sh Kubernetes-commit: 37e7cbdd3a6e9dd1044408b157226c53c76fdf71 --- core/v1/generated.proto | 9 ++++++++- core/v1/types.go | 11 +++++++++-- core/v1/types_swagger_doc_generated.go | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/v1/generated.proto b/core/v1/generated.proto index 021e45e89..c064cc2e6 100644 --- a/core/v1/generated.proto +++ b/core/v1/generated.proto @@ -1986,6 +1986,7 @@ message HTTPHeader { // pod's hosts file. message HostAlias { // IP address of the host file entry. + // +required optional string ip = 1; // Hostnames for the above IP address. @@ -2308,9 +2309,15 @@ message LoadBalancerStatus { // +structType=atomic message LocalObjectReference { // Name of the referent. - // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + // This field is effectively required, but due to backwards compatibility is + // allowed to be empty. Instances of this type with an empty value here are + // almost certainly wrong. // TODO: Add other useful fields. apiVersion, kind, uid? + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names // +optional + // +default="" + // +kubebuilder:default="" + // TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. optional string name = 1; } diff --git a/core/v1/types.go b/core/v1/types.go index 803679c48..0841675d6 100644 --- a/core/v1/types.go +++ b/core/v1/types.go @@ -4113,7 +4113,8 @@ const ( // pod's hosts file. type HostAlias struct { // IP address of the host file entry. - IP string `json:"ip,omitempty" protobuf:"bytes,1,opt,name=ip"` + // +required + IP string `json:"ip" protobuf:"bytes,1,opt,name=ip"` // Hostnames for the above IP address. // +listType=atomic Hostnames []string `json:"hostnames,omitempty" protobuf:"bytes,2,rep,name=hostnames"` @@ -6553,9 +6554,15 @@ type ObjectReference struct { // +structType=atomic type LocalObjectReference struct { // Name of the referent. - // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + // This field is effectively required, but due to backwards compatibility is + // allowed to be empty. Instances of this type with an empty value here are + // almost certainly wrong. // TODO: Add other useful fields. apiVersion, kind, uid? + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names // +optional + // +default="" + // +kubebuilder:default="" + // TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` } diff --git a/core/v1/types_swagger_doc_generated.go b/core/v1/types_swagger_doc_generated.go index 5470aebc5..cb2dabc0d 100644 --- a/core/v1/types_swagger_doc_generated.go +++ b/core/v1/types_swagger_doc_generated.go @@ -1032,7 +1032,7 @@ func (LoadBalancerStatus) SwaggerDoc() map[string]string { var map_LocalObjectReference = map[string]string{ "": "LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.", - "name": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "name": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", } func (LocalObjectReference) SwaggerDoc() map[string]string {