Archived
Require Terraform across dev scripts
This commit is contained in:
+6
-5
@@ -26,11 +26,12 @@ go vet ./...
|
||||
echo "[check] running go test"
|
||||
go test ./...
|
||||
|
||||
if command -v terraform >/dev/null 2>&1; then
|
||||
echo "[check] running terraform fmt check for examples/"
|
||||
terraform fmt -check -recursive examples
|
||||
else
|
||||
echo "[check][warn] terraform not found; skipping examples/ checks" >&2
|
||||
if ! command -v terraform >/dev/null 2>&1; then
|
||||
echo "[check][error] terraform not found in PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[check] running terraform fmt check for examples/"
|
||||
terraform fmt -check -recursive examples
|
||||
|
||||
echo "[check] complete"
|
||||
|
||||
+6
-5
@@ -18,11 +18,12 @@ fi
|
||||
echo "[fix] running go mod tidy"
|
||||
go mod tidy
|
||||
|
||||
if command -v terraform >/dev/null 2>&1; then
|
||||
echo "[fix] running terraform fmt for examples/"
|
||||
terraform fmt -recursive examples
|
||||
else
|
||||
echo "[fix][warn] terraform not found; skipping examples/ formatting" >&2
|
||||
if ! command -v terraform >/dev/null 2>&1; then
|
||||
echo "[fix][error] terraform not found in PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[fix] running terraform fmt for examples/"
|
||||
terraform fmt -recursive examples
|
||||
|
||||
echo "[fix] complete"
|
||||
|
||||
@@ -5,7 +5,7 @@ MIN_GO_VERSION="1.23.0"
|
||||
MIN_TERRAFORM_VERSION="1.5.0"
|
||||
|
||||
FIX_MODE=0
|
||||
STRICT_MODE=0
|
||||
STRICT_MODE=1
|
||||
|
||||
log() {
|
||||
echo "[setup-dev] $*"
|
||||
@@ -21,11 +21,11 @@ error() {
|
||||
|
||||
usage() {
|
||||
cat <<USAGE
|
||||
Usage: ./scripts/setup-dev.sh [--fix] [--strict] [--help]
|
||||
Usage: ./scripts/setup-dev.sh [--fix] [--no-strict] [--help]
|
||||
|
||||
Modes:
|
||||
--fix Validate and attempt safe remediation via already-installed version managers.
|
||||
--strict Treat missing Terraform as an error.
|
||||
--no-strict Allow missing Terraform (not recommended; legacy compatibility mode).
|
||||
--help Show this help text.
|
||||
USAGE
|
||||
}
|
||||
@@ -35,8 +35,8 @@ while [[ $# -gt 0 ]]; do
|
||||
--fix)
|
||||
FIX_MODE=1
|
||||
;;
|
||||
--strict)
|
||||
STRICT_MODE=1
|
||||
--no-strict)
|
||||
STRICT_MODE=0
|
||||
;;
|
||||
--help|-h)
|
||||
usage
|
||||
@@ -273,10 +273,10 @@ validate_terraform() {
|
||||
if [[ -z "$TERRAFORM_PATH" ]]; then
|
||||
if (( STRICT_MODE == 1 )); then
|
||||
error "terraform not found in PATH (required in --strict mode)"
|
||||
bad=1
|
||||
else
|
||||
warn "terraform not found in PATH (required for validate/acceptance workflows)"
|
||||
warn "terraform not found in PATH (allowed only because --no-strict was set)"
|
||||
fi
|
||||
bad=1
|
||||
return "$bad"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user