Skip to content

Instantly share code, notes, and snippets.

@philpennock philpennock/tflint
Created Jan 16, 2020

Embed
What would you like to do?
Bash wrapper to invoke tflint docker container
#!/bin/bash -eu
DOCKER_IMAGE_NAME='tflint'
KeepEnvVars=( AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION )
DockerArgs=()
CmdArgs=()
PwdMountFlags='ro'
while [[ "${1:-}" != "--" ]]; do
case "${1:-.}" in
--entrypoint)
: "${2:?need an entrypoint}"
DockerArgs+=("$1" "$2")
shift 2
;;
--entrypoint=*)
DockerArgs+=("$1")
shift
;;
--)
shift
break
;;
tflint:*)
DOCKER_IMAGE_NAME="$1"
shift
;;
*)
break
;;
esac
done
DockerArgs+=(-v "$PWD:/data${PwdMountFlags:+:}${PwdMountFlags}")
if [[ -f "$HOME/.tflint.hcl" ]]; then
DockerArgs+=(-v "$HOME/.tflint.hcl:/root/.tflint.hcl:ro")
fi
for propagate in "${KeepEnvVars[@]}"; do
if [[ -n "${!propagate:-}" ]]; then
DockerArgs+=(--env "$propagate")
fi
done
[[ -z "${TFLINT_SEE_DOCKER_CMDLINE:-}" ]] || set -x
exec docker run -it --rm "${DockerArgs[@]}" "$DOCKER_IMAGE_NAME" "${CmdArgs[@]}" "$@"
# vim: set sw=2 et :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.