Skip to content
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

command/init: Restore the unconstrained provider warnings #24559

Merged
merged 2 commits into from
Apr 6, 2020

Conversation

apparentlymart
Copy link
Contributor

When a provider dependency is implicit rather than explicit, or otherwise when version constraints are lacking, we produce a warning recommending the addition of explicit version constraints in the configuration.

This restores the warning functionality from previous Terraform versions, adapting it slightly to account for the new provider FQN syntax and to recommend using a required_providers block rather than version constraints in provider blocks, because the latter is no longer recommended in the documentation.

Due to the constraints of how we're presenting this information the warning message might imply to a user new to Terraform that it's recommending putting a required_providers block at the toplevel of configuration, and so to help guide towards the right answer I also added here a specialized error message in the configs package for that case. I'm expecting that this won't be the only place (either in our own prose or in third-party prose) where a configuration snippet without sufficient context might give the false impression that required_providers is a top-level block type.


This commit also removes two other TODO comments while appearing not to do anything about them. That's because both of those are now addressed in a slightly different way by the underlying provider installer object:

  • The selections are captured into a file automatically by the installer, though it's a different file with a different internal structure than was generated by the commented-out code that I removed here.

  • We're no longer actively "pruning" unused packages from the cache here, because the main reason we did that before was to work around the fact that our discovery package considered the files in the directory as the source of record for which versions were selected and so having other versions there would cause misbehavior.

    The new selections file format includes exact version information, so we no longer need to prune. We might choose to re-instate automatic cache management later for general disk space management reasons, but the focus on this commit was on the mandatory behavior required to get the tests passing again.


As with my last few PRs, this one is targeting our integration branch represented as #24477. However, this is hopefully the last changeset before that will land, because this should green the final remaining test failure: an existing e2etest specifically testing the unconstrained provider warnings.

When a provider dependency is implicit rather than explicit, or otherwise
when version constraints are lacking, we produce a warning recommending
the addition of explicit version constraints in the configuration.

This restores the warning functionality from previous Terraform versions,
adapting it slightly to account for the new provider FQN syntax and to
recommend using a required_providers block rather than version constraints
in "provider" blocks, because the latter is no longer recommended in the
documentation.
With provider dependencies now appearing inside a nested block, it seems
likely that configuration examples showing dependencies out of context
will sometimes mislead users into thinking that required_providers is
toplevel.

To give better feedback in that situation, we'll produce a specialized
error in that case hinting the correct structure to the user.
@apparentlymart apparentlymart requested a review from a team April 3, 2020 22:10
@apparentlymart apparentlymart self-assigned this Apr 3, 2020
@ghost ghost added the sdkv1 [PRs only] Marks changes that may potentially need to be ported to the plugi nSDK label Apr 3, 2020
Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Martin!

@apparentlymart apparentlymart merged commit 3a8c4f4 into f-init-new-installer Apr 6, 2020
@apparentlymart apparentlymart deleted the f-init-warn-unconstrained branch April 6, 2020 16:21
@ghost
Copy link

ghost commented May 7, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli enhancement sdkv1 [PRs only] Marks changes that may potentially need to be ported to the plugi nSDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants