Remove terraform.ResourceProvider, use providercache.Installer instead#24508
Merged
apparentlymart merged 3 commits intof-init-new-installerfrom Mar 30, 2020
Merged
Remove terraform.ResourceProvider, use providercache.Installer instead#24508apparentlymart merged 3 commits intof-init-new-installerfrom
apparentlymart merged 3 commits intof-init-new-installerfrom
Conversation
The introduction of a heirarchical addressing scheme for providers gives us an opportunity to make more explicit the special case of "built-in" providers. Thus far we've just had a special case in the "command" package that the provider named "terraform" is handled differently than all others, though there's nothing especially obvious about that in the UI. Moving forward we'll put such "built-in" providers under the special namespace terraform.io/builtin/terraform, which will be visible in the UI as being different than the other providers and we can use the namespace itself (rather than a particular name) as the trigger for our special-case behaviors around built-in plugins. We have no plans to introduce any built-in providers other than "terraform" in the foreseeable future, so any others will produce an error. This commit just establishes the addressing convention, without making use of it anywhere yet. Subsequent commits will make the provider installer and resolver codepaths aware of it, replacing existing checks for the provider just being called "terraform".
Back when we first introduced provider versioning in Terraform 0.10, we did the provider version resolution in terraform.NewContext because we weren't sure yet how exactly our versioning model was going to play out (whether different versions could be selected per provider configuration, for example) and because we were building around the limitations of our existing filesystem-based plugin discovery model. However, the new installer codepath is new able to do all of the selections up front during installation, so we don't need such a heavy inversion of control abstraction to get this done: the command package can select the exact provider versions and pass their factories directly to terraform.NewContext as a simple static map. The result of this commit is that CLI commands other than "init" are now able to consume the local cache directory and selections produced by the installation process in "terraform init", passing all of the selected providers down to the terraform.NewContext function for use in implementing the main operations. This commit is just enough to get the providers passing into the terraform.Context. There's still plenty more to do here, including to repair all of the tests this change has additionally broken.
These are cases where we were using the legacy string only to produce a message to the user or to write to the log. It's enough to make some basic Terraform commands like "terraform validate" not panic and get far enough along to see that provider startup is working.
mildwonkey
approved these changes
Mar 30, 2020
Contributor
mildwonkey
left a comment
There was a problem hiding this comment.
looks great, thanks for tackling the builtin providers here too!
| Provisioners map[string]ProvisionerFactory | ||
| Hooks []Hook | ||
| Parallelism int | ||
| Providers map[addrs.Provider]providers.Factory |
|
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. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Back when we first introduced provider versioning in Terraform 0.10, we did the provider version resolution in
terraform.NewContextbecause we weren't sure yet how exactly our versioning model was going to play out (whether different versions could be selected per provider configuration, for example) and because we were building around the limitations of our existing filesystem-based plugin discovery model.However, the new installer codepath is new able to do all of the selections up front during installation, so we don't need such a heavy inversion of control abstraction to get this done: the command package can determine the exact provider versions previously selected during installation and pass their factories directly to
terraform.NewContextas a simple static map.The result of this set of chanegs is that CLI commands other than
initare now able to consume the local cache directory and selections produced by the installation process interraform init, passing all of the selected providers down to theterraform.NewContextfunction for use in implementing the main operations.This is just enough to get the providers passing into the
terraform.Context. There's still plenty more to do here, including to repair all of the tests this change has additionally broken.(This PR is targeting our shared integration branch -- represented here as #24477 -- rather than the
masterbranch. This is so we can address the test failures and other fixups we need to do before finally merging intomaster.)There are a couple other small commits piggy-backing here that I needed to be able to verify this was working in manual testing. The other two commits are relatively small, but it might still help to look at this on a commit-by-commit basis to focus on the main event commit, which is the second one.