Skip to content

Remove terraform.ResourceProvider, use providercache.Installer instead#24508

Merged
apparentlymart merged 3 commits intof-init-new-installerfrom
f-86-provider-resolver
Mar 30, 2020
Merged

Remove terraform.ResourceProvider, use providercache.Installer instead#24508
apparentlymart merged 3 commits intof-init-new-installerfrom
f-86-provider-resolver

Conversation

@apparentlymart
Copy link
Copy Markdown
Contributor

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 determine the exact provider versions previously selected during installation and pass their factories directly to terraform.NewContext as a simple static map.

The result of this set of chanegs 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 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 master branch. This is so we can address the test failures and other fixups we need to do before finally merging into master.)


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.

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.
@apparentlymart apparentlymart requested a review from a team March 30, 2020 22:39
@apparentlymart apparentlymart self-assigned this Mar 30, 2020
@ghost ghost added the sdkv1 [PRs only] Marks changes that may potentially need to be ported to the plugi nSDK label Mar 30, 2020
Copy link
Copy Markdown
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.

looks great, thanks for tackling the builtin providers here too!

Provisioners map[string]ProvisionerFactory
Hooks []Hook
Parallelism int
Providers map[addrs.Provider]providers.Factory
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉Yay!

@apparentlymart apparentlymart merged commit 8776f81 into f-init-new-installer Mar 30, 2020
@apparentlymart apparentlymart deleted the f-86-provider-resolver branch March 30, 2020 23:06
@ghost
Copy link
Copy Markdown

ghost commented Apr 30, 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 Apr 30, 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