Skip to content

Commit ca93823

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

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

openshift/Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,49 @@ $(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+
MANIFEST_FILE := manifests/0000_30_cluster-api_04_cm.infrastructure-aws.yaml
23+
.PHONY: verify-ocp-manifests
24+
verify-ocp-manifests:
25+
@echo "Extracting provider version from existing manifest..."
26+
$(eval PROVIDER_VERSION := $(shell ${YQ} eval '.metadata.labels."provider.cluster.x-k8s.io/version"' $(MANIFEST_FILE)))
27+
@if [ -z "$(PROVIDER_VERSION)" ]; then \
28+
echo "Error: Could not extract provider version from $(MANIFEST_FILE)"; \
29+
exit 1; \
30+
fi
31+
@echo "Using PROVIDER_VERSION=$(PROVIDER_VERSION) for verification"
32+
@$(MAKE) ocp-manifests PROVIDER_VERSION=$(PROVIDER_VERSION) || { \
33+
echo "Error: Failed to generate manifests"; \
34+
exit 1; \
35+
}
36+
@if ./verify-diff.sh; then \
37+
echo ""; \
38+
echo "Verification successful! Manifests are in sync."; \
39+
else \
40+
git restore $(MANIFEST_FILE); \
41+
echo ""; \
42+
echo "Verification failed! Manifests are out of sync."; \
43+
echo "Please run:"; \
44+
echo " PROVIDER_VERSION=<release-version> make ocp-manifests"; \
45+
echo ""; \
46+
echo "Where <release-version> is the desired upstream release version tag (e.g., v2.9.2)"; \
47+
echo "that matches the upstream version the OpenShift fork is based on."; \
48+
exit 1; \
49+
fi
50+
1551
.PHONY: update-manifests-gen
1652
update-manifests-gen:
1753
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)