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

all: Update to protocol version 5.4 and 6.4 #186

Merged
merged 4 commits into from
Sep 6, 2023

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Aug 25, 2023

Closes #185

@bflad bflad added the enhancement New feature or request label Aug 25, 2023
@bflad bflad added this to the v0.12.0 milestone Aug 25, 2023
@bflad bflad force-pushed the bflad/getproviderschema-optional branch 3 times, most recently from 1e941b2 to 2940589 Compare August 29, 2023 18:47
Reference: #185

This implements protocol versions 5.4 and 6.4 in all provider server implementations, including enabling the `GetProviderSchemaOptional` server capability.
@bflad bflad force-pushed the bflad/getproviderschema-optional branch from 2940589 to 29beaf7 Compare August 29, 2023 20:48
@bflad bflad changed the title all: Initial support for protocol version 5.4 and 6.4 all: Update to protocol version 5.4 and 6.4 Aug 30, 2023
go.mod Outdated Show resolved Hide resolved
Comment on lines +23 to +25
resp := &tfprotov5.PrepareProviderConfigResponse{
PreparedConfig: req.Config, // ignored by Terraform anyways
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might be the most awkward change to the mux server implementations in this change set -- previously PrepareProviderConfig/ValidateProviderConfig would check if each underlying provider returned an equal PreparedConfig response. This response field was for legacy Terraform usage (e.g. pre-0.12) where a provider could slightly change what core saw as the configuration data for a provider, such as injecting an environment variable value for a "required" provider configuration even though a value was not present in the real configuration. The only higher level provider SDK that enabled that behavior was terraform-plugin-sdk. This response field is ignored by any supported Terraform version that implements protocol versions 5 and 6 short of validating (at least currently) that it is either nil or that data value conforms to the provider schema. Therefore, while it may be safe to wholly omit the value (nil), we can instead use the framework's trick of just roundtripping the request configuration data which is guaranteed to be correct.

@bflad bflad marked this pull request as ready for review August 30, 2023 20:09
@bflad bflad requested a review from a team as a code owner August 30, 2023 20:09
Copy link
Contributor

@bendbennett bendbennett left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

lgtm 🚀

bflad added a commit to hashicorp/terraform-plugin-go that referenced this pull request Sep 6, 2023
…data RPC and GetProviderSchemaOptional server capability (#311)

Reference: #310

Protocol upgrades that impose new RPCs will either require:

- The `tfprotov5.ProviderServer`/`tfprotov6.ProviderServer` interface to require a new method
- Or, new "optional" interfaces be implemented (let's make up `ProviderServerWithGetMetadata` in this case)

terraform-plugin-go is a low level abstraction which is designed to _directly implement_ the protocol rather than introduce its own abstractions. Most provider developers will directly interface with higher level Go modules, such as terraform-plugin-sdk and terraform-plugin-framework. Except for advanced provider development using this Go module directly, this type of low level "breaking" change will be hidden by also upgrading those Go modules at the same time:

- hashicorp/terraform-plugin-sdk#1235
- hashicorp/terraform-plugin-framework#829
- hashicorp/terraform-plugin-mux#186

Therefore the change is implemented on the existing interface.
@bflad bflad merged commit fe8079b into main Sep 6, 2023
@bflad bflad deleted the bflad/getproviderschema-optional branch September 6, 2023 17:08
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

all: Updates for Protocol Version 5.4 and 6.4
3 participants