forked from Azure/terraform-azurerm-avm-ptn-azure-ipam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
avm
executable file
·33 lines (27 loc) · 975 Bytes
/
avm
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
#!/usr/bin/env sh
usage () {
echo "Usage: avm <make target>"
}
CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-docker}
if [ ! "$(command -v "$CONTAINER_RUNTIME")" ]; then
echo "Error: $CONTAINER_RUNTIME is not installed. Please install $CONTAINER_RUNTIME first."
exit 1
fi
if [ -z "$1" ]; then
echo "Error: Please provide a make target. See https://github.com/Azure/tfmod-scaffold/blob/main/avmmakefile for available targets."
echo
usage
exit 1
fi
# Mount .azure directory if it exists
AZURE_VOLUME=""
if [ -d "$HOME/.azure" ]; then
AZURE_VOLUME="-v $HOME/.azure:/home/runtimeuser/.azure"
fi
# Check if we are running in a container
# If we are then just run make directly
if [ -z "$AVM_IN_CONTAINER" ]; then
$CONTAINER_RUNTIME run --pull always --user "$(id -u):$(id -g)" --rm $AZURE_VOLUME -v "$(pwd)":/src -w /src -e GITHUB_REPOSITORY -e ARM_SUBSCRIPTION_ID -e GITHUB_REPOSITORY_OWNER mcr.microsoft.com/azterraform make "$1"
else
make "$1"
fi