migrate to OpenTofu with Terraform fallback

Add binary lookup in both terraform.go and destroy.go:
tofu preferred, terraform fallback. Update all docs to
reflect the OpenTofu-first approach.
This commit is contained in:
MermaidMan 2026-06-04 17:46:40 +00:00
parent 79d08fb63c
commit ab1de96168
5 changed files with 48 additions and 26 deletions

View file

@ -53,7 +53,7 @@ obm/
│ │ │ └── hetzner_test.go
│ │ └── provider_test.go
│ ├── terraform/
│ │ └── terraform.go # Runner: Init, Plan, Apply, Destroy wrappers
│ │ └── terraform.go # Runner: Init, Plan, Apply, Destroy (OpenTofu/Terraform)
│ └── validation/
│ ├── validation.go # Check interface, Runner, CheckResult, Status enum
│ └── validation_test.go
@ -82,7 +82,7 @@ obm/
| `obm deploy` | `--config <path>` | Interactive walkthrough (default) or non-interactive from YAML |
| `obm validate` | `--env-file <path>` | Load `.env`, check required vars, validate API keys |
| `obm status` | — | Show deployment state (not yet implemented) |
| `obm destroy` | — | Confirmation prompt → `terraform destroy` → state cleanup |
| `obm destroy` | — | Confirmation prompt → `tofu destroy` → state cleanup |
| `obm version` | — | Print version with commit hash and build time |
| `obm help` | — | Print usage |
@ -111,7 +111,7 @@ The `obm deploy` interactive flow runs 8 steps in sequence:
7. **Tailscale** — Optional VPN setup. Auth key and tailnet domain.
8. **Discord** — Optional bot integration. Bot token, server ID, user IDs.
Final step: summary display with cost estimate → confirm → write `.env` → optionally run `terraform init && terraform apply`.
Final step: summary display with cost estimate → confirm → write `.env` → optionally run `tofu init && tofu apply` (or `terraform` if installed).
### Framework-specific defaults
@ -355,15 +355,15 @@ DigitalOcean prices:
---
## Terraform Integration
## Terraform / OpenTofu Integration
`obm` generates the `.env` file that Terraform expects. The actual Terraform configs live in the separate [openboatmobile-ai](https://github.com/openboatmobile/openboatmobile-ai) repo.
`obm` generates the `.env` file that OpenTofu (or Terraform) expects. The actual infrastructure configs live in the separate [openboatmobile-ai](https://github.com/openboatmobile/openboatmobile-ai) repo.
The `internal/terraform/terraform.go` wrapper provides:
- `Runner.Init()``terraform init -input=false`
- `Runner.Plan(destroy bool)``terraform plan` (with optional `-destroy` flag)
- `Runner.Apply()``terraform apply -auto-approve`
- `Runner.Destroy()``terraform destroy -auto-approve`
The `internal/terraform/terraform.go` wrapper provides (auto-detects OpenTofu first, Terraform fallback):
- `Runner.Init()``tofu init -input=false`
- `Runner.Plan(destroy bool)``tofu plan` (with optional `-destroy` flag)
- `Runner.Apply()``tofu apply -auto-approve`
- `Runner.Destroy()``tofu destroy -auto-approve`
All commands run in the `WorkDir` and capture combined output.
@ -391,7 +391,7 @@ User sets `TF_VAR_*` env vars → sourced from `.env` → Terraform reads them
## Destroy Flow
`obm destroy` reads `terraform.tfstate` to list resources, shows them, asks for confirmation, runs `terraform destroy`, then cleans up state files unless `--keep-state` is set.
`obm destroy` reads `terraform.tfstate` to list resources, shows them, asks for confirmation, runs `tofu destroy`, then cleans up state files unless `--keep-state` is set.
---