#!/bin/bash
set -e

cd "$(dirname "$0")"

case "${1:-plan}" in
  init|validate|plan|apply|destroy)
    docker compose run --rm terraform "$1" "${@:2}"
    ;;
  shell)
    docker compose run --rm terraform /bin/sh
    ;;
  *)
    echo "Usage: $0 [init|validate|plan|apply|destroy|shell]"
    echo ""
    echo "Runtime overrides via -var flags:"
    echo "  $0 apply -auto-approve \\"
    echo "    -var=\"node=mk34\" \\"
    echo "    -var=\"vmid_base=3035\""
    exit 1
    ;;
esac
