hack/verify-codegen.sh: updates to be run in CI

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
Andrew Keesler 2020-08-10 16:24:05 -04:00
parent 7152ffd730
commit ce3de2b516
No known key found for this signature in database
GPG Key ID: 27CE0444346F9413
2 changed files with 17 additions and 4 deletions

View File

@ -11,7 +11,22 @@ CODEGEN_IMAGE=${CODEGEN_IMAGE:-gcr.io/tanzu-user-authentication/k8s-code-generat
function codegen() {
PKG="$1"
shift 1
docker run --rm -v "$ROOT:/go/src/$BASE_PKG" -w "/go/src/$BASE_PKG/$PKG" "${CODEGEN_IMAGE}" "$@" 2>&1 | sed "s|^|$1 ($PKG) > |"
if [[ ${IN_DOCKER:-0} -eq 1 ]]; then
# Already in a container ($CODEGEN_IMAGE).
mkdir -p "$(dirname /go/src/$BASE_PKG/$PKG)"
ln -sf "$ROOT" "/go/src/$BASE_PKG/$PKG"
cd "/go/src/$BASE_PKG/$PKG"
/codegen/entrypoint.sh "$@" 2>&1 | sed "s|^|$1 ($PKG) > |"
else
# Local workstation.
docker run \
--rm \
--volume "$ROOT:/go/src/$BASE_PKG" \
--workdir "/go/src/$BASE_PKG/$PKG" \
"${CODEGEN_IMAGE}" \
/codegen/entrypoint.sh "$@" 2>&1 \
| sed "s|^|$1 ($PKG) > |"
fi
}
codegen kubernetes/1.19/api generate-groups deepcopy,defaulter \

View File

@ -6,6 +6,4 @@ set -euo pipefail
ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")"
"$ROOT/hack/module.sh" lint
# TODO: re-enable once we figure out how to run docker in CI
#"$ROOT/hack/verify-codegen.sh"
"$ROOT/hack/verify-codegen.sh"