diff --git a/hack/update-generated-crd-code.sh b/hack/update-generated-crd-code.sh index 99ca31dd62..56edb59308 100755 --- a/hack/update-generated-crd-code.sh +++ b/hack/update-generated-crd-code.sh @@ -41,11 +41,6 @@ ${GOPATH}/src/k8s.io/code-generator/generate-groups.sh \ --go-header-file ${GOPATH}/src/github.com/heptio/velero/hack/boilerplate.go.txt \ $@ -if [[ "$@" == "--verify-only" ]]; then - # skip generating CRD manifests - exit -fi - go run ${GOPATH}/src/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \ crd \ output:dir=pkg/generated/crds/manifests \ diff --git a/hack/verify-generated-crd-code.sh b/hack/verify-generated-crd-code.sh index 0e61d70b5b..698f8d11b6 100755 --- a/hack/verify-generated-crd-code.sh +++ b/hack/verify-generated-crd-code.sh @@ -17,3 +17,13 @@ HACK_DIR=$(dirname "${BASH_SOURCE}") ${HACK_DIR}/update-generated-crd-code.sh --verify-only + +# ensure no changes to generated CRDs +if ! git diff --exit-code pkg/generated/crds/crds.go >/dev/null; then + # revert changes to state before running CRD generation to stay consistent + # with code-generator `--verify-only` option which discards generated changes + git checkout pkg/generated/crds + + echo "CRD verification - failed! Generated CRDs are out-of-date, please run 'make update'." + exit 1 +fi