Skip to content

feat(detect): add --no-fallback option#539

Merged
kvendingoldo merged 2 commits intotofuutils:mainfrom
railgun-0402:feat/no-fallback-detect
Feb 11, 2026
Merged

feat(detect): add --no-fallback option#539
kvendingoldo merged 2 commits intotofuutils:mainfrom
railgun-0402:feat/no-fallback-detect

Conversation

@railgun-0402
Copy link
Copy Markdown
Contributor

Summary

  • Add --no-fallback flag to tenv tofu detect and tenv tf detect commands
  • When set, return exit code 1 if no version files are found instead of falling back to default strategy

Motivation

Closes #502

Users need to distinguish whether a folder is configured for OpenTofu or Terraform. Currently, tenv tofu detect and tenv tf detect return exit code 0 even when no version files are found, because
a fallback mechanism triggers to select a default version.

Changes

  • versionmanager/manager.go: Add ErrNoVersionFilesFound error and ResolveStrict() method
  • cmd/tenv/subcmd.go: Add --no-fallback flag to detect command
  • versionmanager/proxy/proxy.go: Update Detect() call signature
  • versionmanager/tenvlib/lib.go: Update Detect() call signature

Test plan

# In a directory without version files                                                                                                                                                                  
cd /tmp/test-dir                                                                                                                                                                                        
tenv tofu detect --no-fallback                                                                                                                                                                          
echo $?  # Returns 1                                                                                                                                                                                    
                                                                                                                                                                                                        
# With version file                                                                                                                                                                                     
echo "1.6.0" > .opentofu-version                                                                                                                                                                        
tenv tofu detect --no-fallback                                                                                                                                                                          
echo $?  # Returns 0                      

Signed-off-by: railgun-0402 <april-life.f-441-2011@docomo.ne.jp>
@kvendingoldo
Copy link
Copy Markdown
Collaborator

Hi! Thank you for PR!
Me or @dvaumoron will check it soon

Signed-off-by: railgun-0402 <april-life.f-441-2011@docomo.ne.jp>
@railgun-0402 railgun-0402 force-pushed the feat/no-fallback-detect branch from 3b42a84 to 88228d6 Compare February 3, 2026 08:41
@kvendingoldo kvendingoldo merged commit c35ca9b into tofuutils:main Feb 11, 2026
4 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 15, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [tofuutils/tenv](https://github.com/tofuutils/tenv) | patch | `v4.9.1` → `v4.9.3` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>tofuutils/tenv (tofuutils/tenv)</summary>

### [`v4.9.3`](https://github.com/tofuutils/tenv/releases/tag/v4.9.3)

[Compare Source](tofuutils/tenv@v4.9.2...v4.9.3)

#### Changelog

- [`c35ca9b`](tofuutils/tenv@c35ca9b) Merge pull request [#&#8203;539](tofuutils/tenv#539) from railgun-0402/feat/no-fallback-detect
- [`88228d6`](tofuutils/tenv@88228d6) chore: trigger CI
- [`8f6d842`](tofuutils/tenv@8f6d842) feat(detect): add --no-fallback option

### [`v4.9.2`](https://github.com/tofuutils/tenv/releases/tag/v4.9.2)

[Compare Source](tofuutils/tenv@v4.9.1...v4.9.2)

#### Changelog

- [`5af2b17`](tofuutils/tenv@5af2b17) Merge pull request [#&#8203;542](tofuutils/tenv#542) from pcjedi/patch-2
- [`0098502`](tofuutils/tenv@0098502) chore: bump alpine from 3.20 to 3.23
- [`439d860`](tofuutils/tenv@439d860) Merge pull request [#&#8203;538](tofuutils/tenv#538) from tofuutils/dependabot/github\_actions/docker/login-action-3.7.0
- [`9006535`](tofuutils/tenv@9006535) gh-actions: bump docker/login-action from 3.6.0 to 3.7.0
- [`e76e7a8`](tofuutils/tenv@e76e7a8) Merge pull request [#&#8203;533](tofuutils/tenv#533) from tofuutils/dependabot/github\_actions/actions/setup-go-6.2.0
- [`cf3b354`](tofuutils/tenv@cf3b354) gh-actions: bump actions/setup-go from 6.1.0 to 6.2.0
- [`4f0da9d`](tofuutils/tenv@4f0da9d) Merge pull request [#&#8203;531](tofuutils/tenv#531) from tofuutils/dependabot/go\_modules/github.com/BurntSushi/toml-1.6.0
- [`4c3488a`](tofuutils/tenv@4c3488a) Merge pull request [#&#8203;535](tofuutils/tenv#535) from tofuutils/dependabot/github\_actions/actions/checkout-6.0.2
- [`33e5088`](tofuutils/tenv@33e5088) fix: readme bundle
- [`c21950b`](tofuutils/tenv@c21950b) gh-actions: bump actions/checkout from 6.0.1 to 6.0.2
- [`2fc928f`](tofuutils/tenv@2fc928f) go: bump github.com/BurntSushi/toml from 1.5.0 to 1.6.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMC4zIiwidXBkYXRlZEluVmVyIjoiNDMuMTAuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow disabling fallback for detect commands

2 participants