tfsdk: Support protocol version 5 and verify valid resource type in UpgradeResourceState RPC #263
+404
−8
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.
Reference: #42
Closes #262
Reference: hashicorp/terraform-provider-corner#44
Terraform CLI version 0.12 through 0.14 support protocol version 5 and require the
UpgradeResourceStateResponse
typeUpgradedState
typeMsgpack
field. To support downgraded framework providers via terraform-plugin-muxtf6to5server
, theRawState
typeJSON
field cannot simply be passed through like the previous implementation. This change will parse theRawState
and output it via thetfprotov6.NewDynamicValue()
function, which will always set theMsgpack
field.Similar logic would have already been required as part of the larger effort to support resource versioning and upgrading resource state over time.
Passthrough of the same state of an invalid resource type should not have been previously allowed, since the provider did not implement the resource type. Regardless, Terraform CLI should not have reached this point since
GetProviderSchema
would not have returned the resource type anyways for other resource operations.Verified via integration testing of terraform-plugin-mux
tf6to5server
, which previously returned a non-descriptEOF
error.