From 1b652f8176cbe87767dcb35fd761170aa95c95dc Mon Sep 17 00:00:00 2001 From: subhamkrai Date: Wed, 6 Sep 2023 19:37:25 +0530 Subject: [PATCH] build: add check to validate crd in csv In the past we had few cases where the new crd was missed adding in metadata-common.yaml file. So, now we'll check if crds.yaml and metadata-common.yaml crd name are matching. Signed-off-by: subhamkrai --- Makefile | 5 +++-- build/crds/validate-csv-crd-list.sh | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 build/crds/validate-csv-crd-list.sh diff --git a/Makefile b/Makefile index b3f284c1b..d62deaac4 100644 --- a/Makefile +++ b/Makefile @@ -197,6 +197,7 @@ crds: $(CONTROLLER_GEN) $(YQ) @echo Updating CRD manifests @build/crds/build-crds.sh $(CONTROLLER_GEN) $(YQ) @GOBIN=$(GOBIN) build/crds/generate-crd-docs.sh + @build/crds/validate-csv-crd-list.sh gen-rbac: $(HELM) $(YQ) ## Generate RBAC from Helm charts @# output only stdout to the file; stderr for debugging should keep going to stderr @@ -219,13 +220,13 @@ check-helm-docs: @git diff --exit-code || { \ echo "Please run 'make helm-docs' locally, commit the updated docs, and push the change. See https://rook.io/docs/rook/latest/Contributing/documentation/#making-docs" ; \ exit 2 ; \ - }; + }; check-docs: @$(MAKE) docs @git diff --exit-code || { \ echo "Please run 'make docs' locally, commit the updated docs, and push the change." ; \ exit 2 ; \ - }; + }; docs-preview: ## Preview the documentation through mkdocs diff --git a/build/crds/validate-csv-crd-list.sh b/build/crds/validate-csv-crd-list.sh new file mode 100755 index 000000000..145c3c089 --- /dev/null +++ b/build/crds/validate-csv-crd-list.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +script_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P) + +list_of_crd_in_crd_yaml=$(grep -oE '[^ ]*\.ceph\.rook\.io' "${script_root}/deploy/examples/crds.yaml" | sort) +list_of_csv_in_csv_yaml=$(grep -oE '[^ ]*\.ceph\.rook\.io' "${script_root}/deploy/olm/assemble/metadata-common.yaml" | sort) + +if [ "$list_of_crd_in_crd_yaml" != "$list_of_csv_in_csv_yaml" ]; then + echo "CRD list in crds.yaml file and metadata-common.yaml is different. Make sure to add crd in metadata-common.yaml." + echo -e "crd file list in crd.yaml:\n$list_of_crd_in_crd_yaml" + echo -e "crd file list in csv.yaml:\n$list_of_csv_in_csv_yaml" +fi