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

tfprovider.Provider adds a new method ImportManagedResourceState #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

magodo
Copy link

@magodo magodo commented Mar 4, 2023

Add a new method ImportManagedResourceState to tfprovider.Provider and implement it for both protocol5.Provider and protocol6.Provider.

Meanwhile, this commit fixes two bugs in existing code:

  • protocol5.Provider and protocol6.Provider doesn't initialize the configureMu in their NewProvider method
  • decodeDynamicValue in protocol5 and protocol6 packages incorrectly unmarshal the json payload when it actually should unmarshal msgpack

Test

I've locally used a demo code (just like the example code in this repo) to config the provider, import the resource and read it, it works at least for azurerm provider (plugin5):

💤  go run main.go ~/go/bin/terraform-provider-azurerm
cty.ObjectVal(map[string]cty.Value{"id":cty.StringVal("/subscriptions/xxxx/resourceGroups/zhwen-domain"), "location":cty.StringVal("westus"), "name":cty.StringVal("zhwen-domain"), "tags":cty.MapValEmpty(cty.String), "timeouts":cty.ObjectVal(map[string]cty.Value{"create":cty.NullVal(cty.String), "delete":cty.NullVal(cty.String), "read":cty.NullVal(cty.String), "update":cty.NullVal(cty.String)})})

Add a new method `ImportManagedResourceState` to `tfprovider.Provider` and implement it for both `protocol5.Provider` and `protocol6.Provider`.

Meanwhile, this commit fixes two bugs in existing code:
- `protocol5.Provider` and `protocol6.Provider` doesn't initialize the `configureMu` in their `NewProvider` method
- `decodeDynamicValue` in `protocol5` and `protocol6` packages incorrectly unmarshal the json payload when it actually should unmarshal msgpack
@magodo
Copy link
Author

magodo commented Mar 9, 2023

@apparentlymart Would you mind take a look at this PR! Much appreaciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant