fix(export): let the consumer own versions.tf - #177
Merged
Merged
Conversation
`ct export tf` owned versions.tf unconditionally — written every run, and pruned when unwritten. That made the file impossible to own, which matters because it is the one generated file a consumer has a real reason to own: - A provider VERSION CONSTRAINT lives inside required_providers and has nowhere else to go, so pinning was impossible. provider.ts already said pinning belongs in the consumer's repo; the code contradicted it. - A consumer who also keeps a backend block there loses it SILENTLY on the next export, and `tofu init` then falls back to local state while the real state sits in the configured backend. Reproduced against ct-structure's stack. `--no-versions` opts out. The file is then neither written nor pruned — dropping it from the owned set matters, because pruning would delete the consumer's file outright, which is worse than overwriting it: nothing would hint at why it vanished. Default is unchanged, so a first-time migration still gets a runnable root module.
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.
ct export tfownedversions.tfunconditionally — written every run, pruned when unwritten. That made the file impossible to own.It is the one generated file a consumer has a real reason to own:
required_providersand has nowhere else to go, so pinning was impossible.src/export/provider.tsalready said "pinning belongs in the user's repo" — the code contradicted it.tofu initfalls back to local state while the real state sits in the configured backend. Reproduced against ct-structure's tier-0 stack.Fix
--no-versionsopts out. The file is then neither written nor pruned — dropping it from the owned set is the important half, because pruning would delete the consumer's file, which is worse than overwriting it: nothing would hint at why it vanished.Default behaviour is unchanged, so a first-time migration still gets a runnable root module.
Verification
Reproduced and fixed end to end against real prod state:
export tf(default)export tf --no-versionstofu validatepasses on the result. 4 new tests; full suite 1131 passing.