Feature/opentofu support#199
Merged
patrickchugh merged 3 commits intoJun 6, 2026
Merged
Conversation
Terraform and OpenTofu share an identical CLI for the subcommands Terravision relies on (init, workspace, plan, show -json, graph), so the only difference is the executable name. Centralise binary resolution in helpers.set_tf_binary()/get_tf_binary(): 'auto' prefers terraform on PATH and falls back to tofu, or the engine can be forced. Replace the nine hardcoded "terraform" invocations across tfwrapper.py and tgwrapper.py with the resolved binary, generalise check_terraform_version()/check_dependencies(), and expose --engine [auto|terraform|tofu] on the draw, visualise and graphdata commands. The flag also reads the TERRAVISION_ENGINE environment variable, which lets CI and OpenTofu-only hosts select the engine without a terraform binary.
Add BDD scenarios for set_tf_binary()/get_tf_binary(): explicit terraform/tofu selection, case-insensitive engine names, and auto detection preferring terraform, falling back to tofu, and defaulting to terraform when neither is on PATH. PATH is mocked at the shutil.which boundary.
Add the --engine option to the draw, visualise and graphdata option tables and an OpenTofu section covering autodetection, forcing an engine, the TERRAVISION_ENGINE environment variable, the v1.x requirement, and the Terragrunt TG_TF_PATH caveat.
Owner
|
Very grateful for your PR @dhararon - I also made another set of cosmetic changes after merging your PR where errors messages mention terraform, and now they fetch the binary name and say tofu or terraform as appropriate. |
pull Bot
pushed a commit
to TheTechOddBug/terravision
that referenced
this pull request
Jun 6, 2026
Status banners and error messages in tfwrapper, tgwrapper, and validators still hardcoded "terraform" after the --engine flag was added in patrickchugh#199. Now they use helpers.get_tf_binary() so OpenTofu users see the correct binary name in all output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(engine): add OpenTofu support via
--engineflagType of Change
Summary
Adds first-class OpenTofu support as a drop-in alternative to
Terraform. Terraform and OpenTofu share an identical CLI for every subcommand TerraVision
relies on (
init,workspace,plan,show -json,graph,-v), so the only realdifference is the executable name.
What changed
helpers.py(set_tf_binary()/get_tf_binary()):autoprefersterraformonPATHand falls back totofu, or the engine can be forced."terraform"invocations acrosstfwrapper.pyandtgwrapper.pywith the resolved binary.check_terraform_version()/check_dependencies()to report the activeengine (both Terraform and OpenTofu are
v1.x, so the existing major-version check holds).--engine [auto|terraform|tofu]on thedraw,visualiseandgraphdatacommands.Why
Many teams have migrated from Terraform to OpenTofu after the licence change. Previously the
binary name was hardcoded, so TerraVision could not run against an OpenTofu-only toolchain.
This is a low-risk change because the two CLIs are command-compatible.
Manual verification
Ran
drawend-to-end with--engine tofu(OpenTofu v1.12.1) against a credential-free AWSfixture —
tofu init/plan/show -json/graphall executed correctly and a valid architecturediagram was rendered.
Checklist
All Submissions:
update/change?
AI Assistance Declaration
Checklist for Changes to Core Features:
defaults to
auto, so existing Terraform behaviour is unchanged.)at once?
BDD scenarios in
tests/helpers_unit_test.py, 15/15 pass.)(470 passed. The 34 failures are pre-existing and environment-specific — my local
terraformis a tenv wrapper with no version installed, soterraform -vexits 42 andthe integration/visualise tests that shell out to the CLI fail at preflight. Verified the
identical failures on upstream
main(b06b9c1) without my changes, so they are not aregression. The new resolver tests pass 15/15 and
black --check modulesis clean.)