Skip to content

Commit fc44903

Browse files
authored
Add maintainer note about temporary interfaces for new RPCs (#520)
* docs * link
1 parent 6f948ed commit fc44903

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,32 @@ Select the branch to cut the release from (default is main).
329329

330330
Input the `Release version number` which is the Semantic Release number including
331331
the `v` prefix (i.e. `v1.4.0`) and click `Run workflow` to kickoff the release.
332+
333+
334+
### Temporary Interfaces for New RPCs
335+
336+
As the `terraform-plugin-go` Go module represents the protocol for Terraform providers communicating with [Terraform core](https://github.com/hashicorp/terraform),
337+
this module is the first to receive updates whenever a new RPC is added. This module defines what RPCs must be implemented by downstream provider servers,
338+
such as `terraform-plugin-framework` and `terraform-plugin-sdk/v2`, which is represented by the [`tfprotov5/6.ProviderServer` interface](https://github.com/hashicorp/terraform-plugin-go/blob/3fd901baa420da6d63c8bb999304291117ff09df/tfprotov6/provider.go#L10-L12).
339+
340+
Whenever we add new RPCs to this interface, we typically introduce a temporary interface in the first module release, to allow downstream provider servers time
341+
to implement said RPCs. For example:
342+
- https://github.com/hashicorp/terraform-plugin-go/blob/3cebe39d453f6a37b9e6fe94d53a8f6e6f8f42ee/tfprotov5/provider.go#L59-L76
343+
344+
This allows downstream provider servers a chance to implement the RPCs, while not immediately breaking the CI of actual providers that may be upgrading their `terraform-plugin-go` implementations
345+
which are not using the new RPCs yet. Once the downstream provider servers have been updated and released, we can remove the temporary interface in the next release without making any changes to
346+
`terraform-plugin-framework` or `terraform-plugin-sdk/v2`.
347+
- https://github.com/hashicorp/terraform-plugin-go/pull/465
348+
349+
#### When to consider avoiding this approach
350+
351+
Temporary interfaces work great for RPCs that are optional to implement for a provider server AND are not in the main path of Terraform core. For example, all the ephemeral resource
352+
RPCs are only called when an ephemeral resource is supported in the provider. However, this approach can introduce bugs if used in an RPC that is always called by Terraform Core, regardless
353+
of whether the downstream provider servers implement them fully, like the `GetResourceIdentitySchemas` RPC:
354+
- https://github.com/hashicorp/terraform-plugin-framework/issues/1148
355+
356+
Using a temporary interface for RPCs like this, enables provider servers to not fully implement the RPC, but indicates to core that they are implemented:
357+
- https://github.com/hashicorp/terraform/blob/10f3524bc525733584c4cad6eda6038518a8f1e0/internal/plugin6/grpc_provider.go#L134-L139
358+
359+
For "global" RPCs like this, it's better to either ensure our temporary interface checks allow the downstream provider servers to not implement said RPC (i.e. [don't return a diagnostic](https://github.com/hashicorp/terraform-plugin-go/blob/2030c6ca744896f2e8d5a5c60ed87989a57ef0ce/tfprotov6/tf6server/server.go#L579-L595)),
360+
or, just require that the downstream provider servers implement the new RPC methods in the `ProviderServer` interface and accept the CI errors that will result.

0 commit comments

Comments
 (0)