@@ -52,6 +52,24 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and
5252generate-crd-docs : crd-ref-docs # # Generate CRD documentation to docs/crd.md
5353 $(CRD_REF_DOCS ) --source-path=./apis/flinkcluster/v1beta1 --config=docs/config.yaml --renderer=markdown --output-path=docs/crd.md
5454
55+ .PHONY : verify-helm-crd-schema
56+ verify-helm-crd-schema : kustomize # # Verify the Helm CRD schema matches the generated CRD.
57+ @set -euo pipefail; \
58+ tmp_dir=$$(mktemp -d ) ; \
59+ trap ' rm -rf "$$tmp_dir"' EXIT; \
60+ $(KUSTOMIZE ) build config/default | \
61+ yq -o=json -I=2 ' select(.kind == "CustomResourceDefinition" and .metadata.name == "flinkclusters.flinkoperator.k8s.io") | .spec.versions[] | select(.name == "v1beta1") | .schema.openAPIV3Schema | sort_keys(..)' - > " $$ tmp_dir/generated.json" ; \
62+ sed -E ' s/\{\{[^}]+\}\}/helm-value/g' helm-chart/flink-operator/templates/flink-cluster-crd.yaml | \
63+ yq -o=json -I=2 ' .spec.versions[] | select(.name == "v1beta1") | .schema.openAPIV3Schema | sort_keys(..)' - > " $$ tmp_dir/helm.json" ; \
64+ grep -q ' ^{' " $$ tmp_dir/generated.json" && grep -q ' ^{' " $$ tmp_dir/helm.json" || { \
65+ echo " Failed to extract the v1beta1 OpenAPI schema for comparison." >&2 ; \
66+ exit 1; \
67+ }; \
68+ diff -u " $$ tmp_dir/generated.json" " $$ tmp_dir/helm.json" || { \
69+ echo " Helm CRD schema is out of sync. Run 'cd helm-chart/flink-operator && ./update_template.sh' and commit the refreshed CRD template." >&2 ; \
70+ exit 1; \
71+ }
72+
5573tidy : # # Run go mod tidy
5674 go mod tidy
5775
@@ -63,6 +81,7 @@ vet: ## Run go vet against code.
6381
6482.PHONY : test
6583test : manifests generate fmt vet tidy kustomize envtest # # Run tests.
84+ $(MAKE ) verify-helm-crd-schema
6685 rm -rf config/test && mkdir -p config/test/crd
6786 $(KUSTOMIZE ) build config/crd > config/test/crd/flinkoperator.k8s.io_flinkclusters.yaml
6887 KUBEBUILDER_ASSETS=$(shell $(ENVTEST ) use $(ENVTEST_K8S_VERSION ) --bin-dir $(LOCALBIN ) -p path) go test ./... -coverprofile cover.out
0 commit comments