From fac27e61a8235cdd4381159106248cab2e7c43d5 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Sun, 5 May 2024 23:04:59 -0700 Subject: [PATCH] Workaround malformed generated CRD Signed-off-by: Nic Cope --- Makefile | 10 +++++++++- ...kg.crossplane.io_deploymentruntimeconfigs.yaml | 15 +++++++++++++++ ...kg.crossplane.io_deploymentruntimeconfigs.yaml | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 cluster/crd-patches/pkg.crossplane.io_deploymentruntimeconfigs.yaml diff --git a/Makefile b/Makefile index f852c8a929b..7cd211e654e 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,14 @@ manifests: @$(WARN) Deprecated. Please run make generate instead. CRD_DIR = cluster/crds +CRD_PATCH_DIR = cluster/crd-patches + +# See patch files for details. +crds.patch: $(KUBECTL) + @$(INFO) patching generated CRDs + @$(KUBECTL) patch --local --type=json -f $(CRD_DIR)/pkg.crossplane.io_deploymentruntimeconfigs.yaml --patch-file $(CRD_PATCH_DIR)/pkg.crossplane.io_deploymentruntimeconfigs.yaml -o yaml > /tmp/pkg.crossplane.io_deploymentruntimeconfigs.yaml + @mv /tmp/pkg.crossplane.io_deploymentruntimeconfigs.yaml $(CRD_DIR)/pkg.crossplane.io_deploymentruntimeconfigs.yaml + @$(OK) patched generated CRDs crds.clean: @$(INFO) cleaning generated CRDs @@ -97,7 +105,7 @@ generate.run: gen-kustomize-crds gen-chart-license gen-chart-license: @cp -f LICENSE cluster/charts/crossplane/LICENSE -generate.done: crds.clean +generate.done: crds.clean crds.patch gen-kustomize-crds: @$(INFO) Adding all CRDs to Kustomize file for local development diff --git a/cluster/crd-patches/pkg.crossplane.io_deploymentruntimeconfigs.yaml b/cluster/crd-patches/pkg.crossplane.io_deploymentruntimeconfigs.yaml new file mode 100644 index 00000000000..57e3dd1e18e --- /dev/null +++ b/cluster/crd-patches/pkg.crossplane.io_deploymentruntimeconfigs.yaml @@ -0,0 +1,15 @@ +# For reasons that aren't immediately obvious, updating k8s.io/code-generator +# from v0.29.x to v0.30 triggers a variant of the below issue. As far as I can +# tell, this is the only way to work around it. The below fields are list map +# keys, but aren't required in the generated CRD. +# https://github.com/kubernetes-sigs/controller-tools/issues/444 + +- op: add + path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/deploymentTemplate/properties/spec/properties/template/properties/spec/properties/hostAliases/items/required + value: + - ip + +- op: add + path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/deploymentTemplate/properties/spec/properties/template/properties/spec/properties/imagePullSecrets/items/required + value: + - name \ No newline at end of file diff --git a/cluster/crds/pkg.crossplane.io_deploymentruntimeconfigs.yaml b/cluster/crds/pkg.crossplane.io_deploymentruntimeconfigs.yaml index f876d0e55d9..35a599ab79a 100644 --- a/cluster/crds/pkg.crossplane.io_deploymentruntimeconfigs.yaml +++ b/cluster/crds/pkg.crossplane.io_deploymentruntimeconfigs.yaml @@ -4211,6 +4211,8 @@ spec: ip: description: IP address of the host file entry. type: string + required: + - ip type: object type: array x-kubernetes-list-map-keys: @@ -4265,6 +4267,8 @@ spec: More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid? type: string + required: + - name type: object x-kubernetes-map-type: atomic type: array