Commit d768615b authored by John Jarvis's avatar John Jarvis

Merge branch 'jarv/per-env-version-checks' into 'master'

Add per env version checks.

See merge request !215
parents 37ffecfa 3aff3591
#!/bin/bash
installed_version=$(terraform -version | cut -d v -f 2 | head -1)
env_tf_version_file="${dir:-.}/../environments/${environment:-.}/.terraform_version"
repo_tf_version_file="${dir:-.}/../.terraform_version"
if [[ ! -r "$repo_tf_version_file" ]]; then
echo -e "${_BRED}Repository is missing $repo_tf_version_file ${_NORM}"
exit 1
fi
if [[ -n $TF_VERSION ]]; then
required_version="$TF_VERSION"
elif [[ -r "$env_tf_version_file" ]]; then
required_version=$(cat "$env_tf_version_file")
else
required_version=$(cat "${dir:-.}/../.terraform_version")
required_version=$(cat "$repo_tf_version_file")
fi
if [[ "$installed_version" != "$required_version" ]]; then
echo -e "${_BRED}!!! WARNING !!!${_NORM}"
echo "You are using the wrong version ($installed_version) of Terraform."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment