-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check required_version as early as possible #29665
Conversation
We must ensure that the terraform required_version is checked as early as possible, so that new configuration constructs don't cause init to fail without indicating the version is incompatible. The loadConfig call before the earlyconfig parsing seems to be unneeded, and we can delay that to de-tangle it from installing the modules which may have their own constraints. TODO: it seems that loadConfig should be able to handle returning the version constraints in the same manner as loadSingleModule.
LoadConfig should return any parsed configuration in order for the caller to verify `required_version`.
37a3297
to
5532f4c
Compare
We don't need to load the configuration twice, since configload can return the module for us.
5532f4c
to
ab0322e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Our current check of
required_version
happens after parsing the configuration, which may not be possible if new configuration constructs have been added to the language since the declaredrequired_version
. This can cause terraform to print rather unhelpful error messages about unknown identifiers in various modules, when the only pertinent information is that the CLI version is not compatible.Restructure the init command to ensure that we check the core version constraints before handling any parsing diagnostics. We can remove the extra loading of the configuration, which is redundant when the config loader can return the same value along with its diagnostics.
Closes #29109