From 1e8acc4f390df5f89c23cfd33e020e134453cbee Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 4 Oct 2024 13:44:20 +0200 Subject: [PATCH 1/3] fix: add json tags to match field annotation tag +patchStrategy Signed-off-by: Marc Nuri --- apis/metal3.io/v1alpha1/hostfirmwaresettings_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/metal3.io/v1alpha1/hostfirmwaresettings_types.go b/apis/metal3.io/v1alpha1/hostfirmwaresettings_types.go index ab0b823c69..16f14857c7 100644 --- a/apis/metal3.io/v1alpha1/hostfirmwaresettings_types.go +++ b/apis/metal3.io/v1alpha1/hostfirmwaresettings_types.go @@ -48,7 +48,7 @@ type HostFirmwareSettingsSpec struct { // Settings are the desired firmware settings stored as name/value pairs. // +patchStrategy=merge - Settings DesiredSettingsMap `json:"settings" required:"true"` + Settings DesiredSettingsMap `json:"settings" patchStrategy:"merge" required:"true"` } // HostFirmwareSettingsStatus defines the observed state of HostFirmwareSettings. From 6b123cc23349ae80690062c23345a3f985a05bf1 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 4 Oct 2024 14:06:42 +0200 Subject: [PATCH 2/3] fix: add missing doc.go for proper groupName inference Most go code generators such as kube-openapi rely on gengo [1] to infer the annotated tags. When dealing with package annotations, gengo extracts them from the doc.go file [2]. The types defined in apis/metal3.io/v1alpha1 do have a package annotated with +groupName. However, the annotation is in the groupversion_info.go file instead. You can see comments that refer to this issue [3] [4] [1] https://github.com/kubernetes/gengo/ [2] https://github.com/kubernetes/gengo/blob/2b36238f13e9b8aebe4c286c2ffb2fc71f4be3c5/types/types.go#L121-L126 [3] https://github.com/kubernetes/code-generator/issues/150#issuecomment-1773718101 [4] https://github.com/kubernetes/code-generator/issues/135 Signed-off-by: Marc Nuri --- apis/metal3.io/v1alpha1/doc.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 apis/metal3.io/v1alpha1/doc.go diff --git a/apis/metal3.io/v1alpha1/doc.go b/apis/metal3.io/v1alpha1/doc.go new file mode 100644 index 0000000000..041e89c96d --- /dev/null +++ b/apis/metal3.io/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1alpha1 contains API Schema definitions for the metal3.io v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=metal3.io +package v1alpha1 From 741dffcd5cdd8cccfdca4c6a66aa01b66a527dfd Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 10 Oct 2024 10:14:02 +0200 Subject: [PATCH 3/3] chore: added openapi-gen comment tags for v1alpha1 Co-authored-by: Kashif Khan Signed-off-by: Marc Nuri --- apis/metal3.io/v1alpha1/doc.go | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/metal3.io/v1alpha1/doc.go b/apis/metal3.io/v1alpha1/doc.go index 041e89c96d..b5c2caa04e 100644 --- a/apis/metal3.io/v1alpha1/doc.go +++ b/apis/metal3.io/v1alpha1/doc.go @@ -15,5 +15,6 @@ limitations under the License. // Package v1alpha1 contains API Schema definitions for the metal3.io v1alpha1 API group // +kubebuilder:object:generate=true +// +k8s:openapi-gen=true // +groupName=metal3.io package v1alpha1