-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[make][pre-commit]Check CRD schema to avoid update issues
The new crd-schema-check make target compares the CRD schema of the patch with the schema on the tip of main and report errors on non backward compatible changes. This make target now also run in pre-commit both locally and in CI. This make target uses https://github.com/openshift/crd-schema-checker to do the actual checking.
- Loading branch information
1 parent
1c476cf
commit 5ee3bf9
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
if [ -f "$INSTALL_DIR/crd-schema-checker" ]; then | ||
exit 0 | ||
fi | ||
|
||
mkdir -p "$INSTALL_DIR/git-tmp" | ||
git clone https://github.com/openshift/crd-schema-checker.git \ | ||
-b "$CRD_SCHEMA_CHECKER_VERSION" "$INSTALL_DIR/git-tmp" | ||
pushd "$INSTALL_DIR/git-tmp" | ||
GOWORK=off make | ||
cp crd-schema-checker "$INSTALL_DIR/" | ||
popd | ||
rm -rf "$INSTALL_DIR/git-tmp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
CHECKER=$INSTALL_DIR/crd-schema-checker | ||
|
||
TMP_DIR=$(mktemp -d) | ||
|
||
function cleanup { | ||
rm -rf "$TMP_DIR" | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
|
||
for crd in config/crd/bases/*.yaml; do | ||
mkdir -p "$(dirname "$TMP_DIR/$crd")" | ||
git show "$BASE_REF:$crd" > "$TMP_DIR/$crd" | ||
$CHECKER check-manifests \ | ||
--existing-crd-filename="$TMP_DIR/$crd" \ | ||
--new-crd-filename="$crd" | ||
done |