Repository navigation
Expand file tree
/
Copy pathgkvm
More file actions
executable file
·47 lines (40 loc) · 1.8 KB
/
Copy pathgkvm
File metadata and controls
executable file
·47 lines (40 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env sh
# gkvm: run a gkvm-tools make target against the current module repository.
#
# ./gkvm pre-commit ./gkvm pr-check ./gkvm tflint ...
#
# Runs the pinned gkvm-tools container image. Inside the devcontainer (or any
# shell where GKVM_IN_CONTAINER is set) it calls make directly.
#
# Environment:
# GKVM_IMAGE image to run (default ghcr.io/glueckkanja/gkvm-tools:v0)
<
53B8
div>
# CONTAINER_RUNTIME docker (default) or podman
# GKVM_BINARY tofu (default) or terraform
# GKVM_PROFILE base | azure | github (default: auto-detect)
# ARM_* / GITHUB_* passed through for example runs and integration tests
set -eu
if [ "$#" -eq 0 ]; then
echo "Usage: gkvm <target> (try: gkvm help)" >&2
exit 1
fi
if [ -n "${GKVM_IN_CONTAINER:-}" ]; then
exec make --no-print-directory -f "${GKVM_HOME:-/opt/gkvm}/Makefile" "$@"
fi
CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-docker}"
GKVM_IMAGE="${GKVM_IMAGE:-ghcr.io/glueckkanja/gkvm-tools:v0}"
AZURE_CONFIG_DIR="${AZURE_CONFIG_DIR:-$HOME/.azure}"
if ! command -v "$CONTAINER_RUNTIME" >/dev/null 2>&1; then
echo "Error: $CONTAINER_RUNTIME is not installed." >&2
exit 1
fi
mkdir -p "$AZURE_CONFIG_DIR"
# -e NAME (no value) forwards the variable only when it is set on the host.
exec "$CONTAINER_RUNTIME" run --rm -it \
--user "$(id -u):$(id -g)" \
-v "$(pwd)":/src -w /src \
-v "$AZURE_CONFIG_DIR":/azureconfig -e AZURE_CONFIG_DIR=/azureconfig \
-e GKVM_BINARY -e GKVM_PROFILE -e GKVM_E2E -e GKVM_EXAMPLE -e GKVM_ZIZMOR_PERSONA \
-e ARM_CLIENT_ID -e ARM_CLIENT_SECRET -e ARM_TENANT_ID -e ARM_SUBSCRIPTION_ID -e ARM_USE_OIDC -e ARM_USE_AZUREAD \
-e GITHUB_TOKEN -e GH_TOKEN -e GITHUB_OWNER -e GITHUB_REPOSITORY \
-e GITHUB_APP_ID -e GITHUB_APP_INSTALLATION_ID -e GITHUB_APP_PEM_FILE -e GITHUB_BASE_URL \
"$GKVM_IMAGE" gkvm "$@"