forked from zenika-open-source/terraform-azure-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.sh
executable file
·37 lines (29 loc) · 1.76 KB
/
dev.sh
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
#!/usr/bin/env bash
set -eo pipefail
# FIXME: use getopts function to parse aguments
# FIXME: if provided, both TF and AZ CLI semvers should be regex-validated
# Set AZ and TF CLI to latest supported versions if not specified
[[ -n $1 ]] && AZ_VERSION=$1 || AZ_VERSION=$(jq -r '.azcli_version | sort | .[-1]' supported_versions.json)
[[ -n $2 ]] && TF_VERSION=$2 || TF_VERSION=$(jq -r '.tf_version | sort | .[-1]' supported_versions.json)
# Set image name and tag (dev if not specified)
IMAGE_NAME="zenika/terraform-azure-cli"
[[ -n $3 ]] && IMAGE_TAG=$3 || IMAGE_TAG="dev"
# Lint Dockerfile
#echo "Linting Dockerfile..."
#docker run --rm --interactive --volume "${PWD}":/data --workdir /data hadolint/hadolint:2.5.0-alpine /bin/hadolint --config hadolint.yaml Dockerfile
#echo "Dockerfile successfully linted!"
# Build image
echo "Building images with AZURE_CLI_VERSION=${AZ_VERSION} and TERRAFORM_VERSION=${TF_VERSION}..."
docker image build --build-arg AZURE_CLI_VERSION="$AZ_VERSION" --build-arg TERRAFORM_VERSION="$TF_VERSION" -t $IMAGE_NAME:$IMAGE_TAG .
echo "Image successfully builded!"
# YOLO
exit 0
# Test image
echo "Generating test config with AZURE_CLI_VERSION=${AZ_VERSION} and TERRAFORM_VERSION=${TF_VERSION}..."
export AZ_VERSION=${AZ_VERSION} && export TF_VERSION=${TF_VERSION}
envsubst '${AZ_VERSION},${TF_VERSION}' < tests/container-structure-tests.yml.template > tests/container-structure-tests.yml
echo "Test config successfully generated!"
echo "Executing container structure test..."
docker container run --rm -it -v "${PWD}"/tests/container-structure-tests.yml:/tests.yml:ro -v /var/run/docker.sock:/var/run/docker.sock:ro gcr.io/gcp-runtimes/container-structure-test:v1.10.0 test --image $IMAGE_NAME:$IMAGE_TAG --config /tests.yml
unset AZ_VERSION
unset TF_VERSION