Skip to content

Mildwonkey/tests#24548

Merged
mildwonkey merged 5 commits intof-init-new-installerfrom
mildwonkey/tests
Apr 3, 2020
Merged

Mildwonkey/tests#24548
mildwonkey merged 5 commits intof-init-new-installerfrom
mildwonkey/tests

Conversation

@mildwonkey
Copy link
Copy Markdown
Contributor

The last commit is the interesting one:

  • adds an extra wrapper around terraform.ShimLegacyState that sets provider FQNs (always assumed to be NewDefaultProviders) in the new state. This is not how things work in terraform proper, which expects that the provider FQN exists in state or was added by 0.13upgrade, but for these tests which round-trip between states it was necessary and a sufficient default behavior.
  • adds a variation on addrs.Provider.LegacyString() which will work with non-legacy providers (also necessary only for the round-trip shimming)

Some of the tests in helper/resource have to shim between legacy and
modern states. Terraform expects modern states to have the Provider set
for each resource (and not be a legacy provider). This PR adds a wrapper
around terraform.ShimLegacyState which iterates through the resources
in the state (after the shim) and adds the provider FQN.
@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
Copy Markdown
Contributor

@apparentlymart apparentlymart left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

Just want to note here for future reference that we made an intentional decision to duplicate a bit of functionality in the helper/resource package here, rather than modifying the main behavior to support it, because helper/resource is a legacy system in this codebase and so we think it's desirable to make it as self-contained as possible so that it can keep working as we evolve the rest of the codebase, and so that we can evolve the rest of the codebase without being forever held back by these legacy constraints. We hope to plan a real future for helper/resource in a later project, but it's out of scope for now.

Copy link
Copy Markdown
Contributor

@alisdair alisdair left a comment

Choose a reason for hiding this comment

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

Looks good! 👍 I have one question inline.

if state.HasResources() {
for _, module := range state.Modules {
for name, resource := range module.Resources {
module.Resources[name].ProviderConfig.Provider = addrs.NewDefaultProvider(resource.Addr.Resource.ImpliedProvider())
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.

Should this line use addrs.ImpliedProviderForUnqualifiedType? I imagine it's unlikely that we'll have test states with a builtin provider, so it's not really necessary, but it might be safer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Excellent point, thank you! Better have in there and not need it than have a test blow up unnecessarily.

@mildwonkey mildwonkey merged commit 92cca7f into f-init-new-installer Apr 3, 2020
@mildwonkey mildwonkey deleted the mildwonkey/tests branch April 3, 2020 18:20
apparentlymart pushed a commit that referenced this pull request Apr 6, 2020
* helper/resource: remove provider resolver test
* repl tests passing
* helper/resource: add some extra shimming to ShimLegacyState

Some of the tests in helper/resource have to shim between legacy and
modern states. Terraform expects modern states to have the Provider set
for each resource (and not be a legacy provider). This PR adds a wrapper
around terraform.ShimLegacyState which iterates through the resources
in the state (after the shim) and adds the provider FQN.
pselle pushed a commit that referenced this pull request Apr 6, 2020
* helper/resource: remove provider resolver test
* repl tests passing
* helper/resource: add some extra shimming to ShimLegacyState

Some of the tests in helper/resource have to shim between legacy and
modern states. Terraform expects modern states to have the Provider set
for each resource (and not be a legacy provider). This PR adds a wrapper
around terraform.ShimLegacyState which iterates through the resources
in the state (after the shim) and adds the provider FQN.
@ghost
Copy link
Copy Markdown

ghost commented May 4, 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 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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.

3 participants