Skip to content

Commit

Permalink
Workaround malformed generated CRD
Browse files Browse the repository at this point in the history
Signed-off-by: Nic Cope <nicc@rk0n.org>
  • Loading branch information
negz committed May 7, 2024
1 parent 7164255 commit 2a92521
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions cluster/crds/pkg.crossplane.io_deploymentruntimeconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2a92521

Please sign in to comment.