Skip to content

Commit f5950c3

Browse files
committed
UPSTREAM: <carry>: Add manifests verify target
1 parent 287f4e2 commit f5950c3

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

openshift/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,28 @@ $(RELEASE_DIR):
55
mkdir -p $(RELEASE_DIR)/
66

77
MANIFESTS_GEN := go run ./vendor/github.com/openshift/cluster-capi-operator/manifests-gen/
8+
YQ := go run github.com/mikefarah/yq/v4@v4.48.1
89

910
.PHONY: check-env
1011
check-env:
1112
ifndef PROVIDER_VERSION
1213
$(error PROVIDER_VERSION is undefined)
1314
endif
1415

16+
.PHONY: verify
17+
verify: verify-ocp-manifests
18+
19+
# NOTE: This target extracts the provider version from the existing generated manifest
20+
# and uses it for regeneration. This means the version label itself is NOT verified,
21+
# only that the rest of the manifest structure is correct.
22+
.PHONY: verify-ocp-manifests
23+
verify-ocp-manifests:
24+
@echo "Extracting provider version from existing manifest..."
25+
$(eval PROVIDER_VERSION := $(shell ${YQ} eval '.metadata.labels."provider.cluster.x-k8s.io/version"' manifests/0000_30_cluster-api_04_cm.infrastructure-aws.yaml))
26+
@echo "Using PROVIDER_VERSION=$(PROVIDER_VERSION) for verification"
27+
@$(MAKE) ocp-manifests PROVIDER_VERSION=$(PROVIDER_VERSION)
28+
@./verify-diff.sh && (git restore manifests/0000_30_cluster-api_04_cm.infrastructure-aws.yaml; echo -e "\nVerification successful! Manifests are in sync.") || (git restore manifests/0000_30_cluster-api_04_cm.infrastructure-aws.yaml; echo -e "\nVerification failed! Manifests are out of sync.\nPlease run:\n PROVIDER_VERSION=<release-version> make ocp-manifests\n\nWhere <release-version> is the desired upstream release version tag (e.g., v2.9.2) that matches the upstream version the OpenShift fork is based on.\n"; exit 1)
29+
1530
.PHONY: update-manifests-gen
1631
update-manifests-gen:
1732
cd tools && go get github.com/openshift/cluster-capi-operator/manifests-gen && go mod tidy && go mod vendor

openshift/verify-diff.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
FILE_DIFF=$(git ls-files -o --exclude-standard)
4+
5+
if [ "$FILE_DIFF" != "" ]; then
6+
echo "Found untracked files:"
7+
echo "$FILE_DIFF"
8+
exit 1
9+
fi
10+
11+
git diff --exit-code

0 commit comments

Comments
 (0)