Skip to content

Commit 68ac8c5

Browse files
authored
all: Remove temporary ProviderServerWithResourceIdentity interface (#516)
* remove temporary interfaces * add changelogs * Update .changes/unreleased/BREAKING CHANGES-20250521-145326.yaml * Update .changes/unreleased/NOTES-20250521-145307.yaml * Update tfprotov5/provider.go * extra apos
1 parent 0c51a41 commit 68ac8c5

File tree

9 files changed

+42
-146
lines changed

9 files changed

+42
-146
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: BREAKING CHANGES
2+
body: 'tfprotov5+tfprotov6: Removed temporary `ProviderServerWithResourceIdentity` interface type. Use `ProviderServer` instead.'
3+
time: 2025-05-21T14:52:43.175919-04:00
4+
custom:
5+
Issue: "516"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
kind: BREAKING CHANGES
2+
body: 'tfprotov5+tfprotov6: `GetResourceIdentitySchemas` and `UpgradeResourceIdentity` RPC calls are now required in
3+
`ProviderServer` and `ResourceServer`. Implementations that don''t support resource identity can return empty responses from the `GetResourceIdentitySchemas` method
4+
and an error message the `UpgradeResourceIdentity` method.'
5+
time: 2025-05-21T14:53:26.293403-04:00
6+
custom:
7+
Issue: "516"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: NOTES
2+
body: 'all: To prevent compilation errors, ensure your Go module is updated to at least [email protected], [email protected],
3+
terraform-plugin-sdk/[email protected], and [email protected] before upgrading this dependency.'
4+
time: 2025-05-21T14:53:07.094145-04:00
5+
custom:
6+
Issue: "516"

tfprotov5/provider.go

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ type ProviderServer interface {
2222
// and data sources.
2323
GetProviderSchema(context.Context, *GetProviderSchemaRequest) (*GetProviderSchemaResponse, error)
2424

25+
// GetResourceIdentitySchemas is called when Terraform needs to know
26+
// what the provider's resource identity schemas are.
27+
GetResourceIdentitySchemas(context.Context, *GetResourceIdentitySchemasRequest) (*GetResourceIdentitySchemasResponse, error)
28+
2529
// PrepareProviderConfig is called to give a provider a chance to
2630
// modify the configuration the user specified before validation.
2731
PrepareProviderConfig(context.Context, *PrepareProviderConfigRequest) (*PrepareProviderConfigResponse, error)
@@ -63,29 +67,6 @@ type ProviderServer interface {
6367
EphemeralResourceServer
6468
}
6569

66-
// ProviderServerWithResourceIdentity is a temporary interface for servers
67-
// to implement Resource Identity RPC handling with:
68-
//
69-
// - GetResourceIdentitySchemas
70-
// - UpgradeResourceIdentity
71-
//
72-
// Deprecated: All methods will be moved into the
73-
// ProviderServer and ResourceServer interfaces and this interface will be removed in a future
74-
// version.
75-
type ProviderServerWithResourceIdentity interface {
76-
ProviderServer
77-
78-
// GetResourceIdentitySchemas is called when Terraform needs to know
79-
// what the provider's resource identity schemas are.
80-
GetResourceIdentitySchemas(context.Context, *GetResourceIdentitySchemasRequest) (*GetResourceIdentitySchemasResponse, error) // This will go into the ProviderServer interface
81-
82-
// UpgradeResourceIdentity is called when Terraform has encountered a
83-
// resource with an identity state in a schema that doesn't match the schema's
84-
// current version. It is the provider's responsibility to modify the
85-
// identity state to upgrade it to the latest state schema.
86-
UpgradeResourceIdentity(context.Context, *UpgradeResourceIdentityRequest) (*UpgradeResourceIdentityResponse, error) // This will go into the ResourceServer interface
87-
}
88-
8970
// GetMetadataRequest represents a GetMetadata RPC request.
9071
type GetMetadataRequest struct{}
9172

tfprotov5/resource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ type ResourceServer interface {
6363
// provider must have enabled the MoveResourceState server capability to
6464
// enable these requests.
6565
MoveResourceState(context.Context, *MoveResourceStateRequest) (*MoveResourceStateResponse, error)
66+
67+
// UpgradeResourceIdentity is called when Terraform has encountered a
68+
// resource with an identity state in a schema that doesn't match the schema's
69+
// current version. It is the provider's responsibility to modify the
70+
// identity state to upgrade it to the latest state schema.
71+
UpgradeResourceIdentity(context.Context, *UpgradeResourceIdentityRequest) (*UpgradeResourceIdentityResponse, error)
6672
}
6773

6874
// ValidateResourceTypeConfigRequest is the request Terraform sends when it

tfprotov5/tf5server/server.go

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -572,31 +572,7 @@ func (s *server) GetResourceIdentitySchemas(ctx context.Context, protoReq *tfplu
572572

573573
ctx = tf5serverlogging.DownstreamRequest(ctx)
574574

575-
// TODO: Remove this check and error in preference of
576-
// s.downstream.GetResourceIdentitySchemas below once ProviderServer interface
577-
// implements this RPC method.
578-
// nolint:staticcheck
579-
resourceIdentityProviderServer, ok := s.downstream.(tfprotov5.ProviderServerWithResourceIdentity)
580-
if !ok {
581-
logging.ProtocolError(ctx, "ProviderServer does not implement GetResourceIdentitySchemas")
582-
583-
protoResp := &tfplugin5.GetResourceIdentitySchemas_Response{
584-
Diagnostics: []*tfplugin5.Diagnostic{
585-
{
586-
Severity: tfplugin5.Diagnostic_ERROR,
587-
Summary: "Provider GetResourceIdentitySchemas Not Implemented",
588-
Detail: "A GetResourceIdentitySchemas call was received by the provider, however the provider does not implement the call. " +
589-
"Either upgrade the provider to a version that implements resource identity support or this is a bug in Terraform that should be reported to the Terraform maintainers.",
590-
},
591-
},
592-
}
593-
594-
return protoResp, nil
595-
}
596-
597-
// TODO: Update this to call downstream once optional interface is removed
598-
// resp, err := s.downstream.GetResourceIdentitySchemas(ctx, req)
599-
resp, err := resourceIdentityProviderServer.GetResourceIdentitySchemas(ctx, req)
575+
resp, err := s.downstream.GetResourceIdentitySchemas(ctx, req)
600576

601577
if err != nil {
602578
logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err})
@@ -845,31 +821,7 @@ func (s *server) UpgradeResourceIdentity(ctx context.Context, protoReq *tfplugin
845821

846822
ctx = tf5serverlogging.DownstreamRequest(ctx)
847823

848-
// TODO: Remove this check and error in preference of
849-
// s.downstream.UpgradeResourceIdentity below once ProviderServer interface
850-
// implements this RPC method.
851-
// nolint:staticcheck
852-
resourceIdentityProviderServer, ok := s.downstream.(tfprotov5.ProviderServerWithResourceIdentity)
853-
if !ok {
854-
logging.ProtocolError(ctx, "ProviderServer does not implement UpgradeResourceIdentity")
855-
856-
protoResp := &tfplugin5.UpgradeResourceIdentity_Response{
857-
Diagnostics: []*tfplugin5.Diagnostic{
858-
{
859-
Severity: tfplugin5.Diagnostic_ERROR,
860-
Summary: "Provider UpgradeResourceIdentity Not Implemented",
861-
Detail: "A UpgradeResourceIdentity call was received by the provider, however the provider does not implement the call. " +
862-
"Either upgrade the provider to a version that implements resource identity support or this is a bug in Terraform that should be reported to the Terraform maintainers.",
863-
},
864-
},
865-
}
866-
867-
return protoResp, nil
868-
}
869-
870-
// TODO: Update this to call downstream once optional interface is removed
871-
// resp, err := s.downstream.UpgradeResourceIdentity(ctx, req)
872-
resp, err := resourceIdentityProviderServer.UpgradeResourceIdentity(ctx, req)
824+
resp, err := s.downstream.UpgradeResourceIdentity(ctx, req)
873825

874826
if err != nil {
875827
logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err})

tfprotov6/provider.go

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ type ProviderServer interface {
2222
// and data sources.
2323
GetProviderSchema(context.Context, *GetProviderSchemaRequest) (*GetProviderSchemaResponse, error)
2424

25+
// GetResourceIdentitySchemas is called when Terraform needs to know
26+
// what the provider's resource identity schemas are.
27+
GetResourceIdentitySchemas(context.Context, *GetResourceIdentitySchemasRequest) (*GetResourceIdentitySchemasResponse, error)
28+
2529
// ValidateProviderConfig is called to give a provider a chance to
2630
// validate the configuration the user specified.
2731
ValidateProviderConfig(context.Context, *ValidateProviderConfigRequest) (*ValidateProviderConfigResponse, error)
@@ -63,29 +67,6 @@ type ProviderServer interface {
6367
EphemeralResourceServer
6468
}
6569

66-
// ProviderServerWithResourceIdentity is a temporary interface for servers
67-
// to implement Resource Identity RPC handling with:
68-
//
69-
// - GetResourceIdentitySchemas
70-
// - UpgradeResourceIdentity
71-
//
72-
// Deprecated: All methods will be moved into the
73-
// ProviderServer and ResourceServer interfaces and this interface will be removed in a future
74-
// version.
75-
type ProviderServerWithResourceIdentity interface {
76-
ProviderServer
77-
78-
// GetResourceIdentitySchemas is called when Terraform needs to know
79-
// what the provider's resource identity schemas are.
80-
GetResourceIdentitySchemas(context.Context, *GetResourceIdentitySchemasRequest) (*GetResourceIdentitySchemasResponse, error) // This will go into the ProviderServer interface
81-
82-
// UpgradeResourceIdentity is called when Terraform has encountered a
83-
// resource with an identity state in a schema that doesn't match the schema's
84-
// current version. It is the provider's responsibility to modify the
85-
// identity state to upgrade it to the latest state schema.
86-
UpgradeResourceIdentity(context.Context, *UpgradeResourceIdentityRequest) (*UpgradeResourceIdentityResponse, error) // This will go into the ResourceServer interface
87-
}
88-
8970
// GetMetadataRequest represents a GetMetadata RPC request.
9071
type GetMetadataRequest struct{}
9172

tfprotov6/resource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ type ResourceServer interface {
6363
// provider must have enabled the MoveResourceState server capability to
6464
// enable these requests.
6565
MoveResourceState(context.Context, *MoveResourceStateRequest) (*MoveResourceStateResponse, error)
66+
67+
// UpgradeResourceIdentity is called when Terraform has encountered a
68+
// resource with an identity state in a schema that doesn't match the schema's
69+
// current version. It is the provider's responsibility to modify the
70+
// identity state to upgrade it to the latest state schema.
71+
UpgradeResourceIdentity(context.Context, *UpgradeResourceIdentityRequest) (*UpgradeResourceIdentityResponse, error)
6672
}
6773

6874
// ValidateResourceConfigRequest is the request Terraform sends when it

tfprotov6/tf6server/server.go

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -572,31 +572,7 @@ func (s *server) GetResourceIdentitySchemas(ctx context.Context, protoReq *tfplu
572572

573573
ctx = tf6serverlogging.DownstreamRequest(ctx)
574574

575-
// TODO: Remove this check and error in preference of
576-
// s.downstream.GetResourceIdentitySchemas below once ProviderServer interface
577-
// implements this RPC method.
578-
// nolint:staticcheck
579-
resourceIdentityProviderServer, ok := s.downstream.(tfprotov6.ProviderServerWithResourceIdentity)
580-
if !ok {
581-
logging.ProtocolError(ctx, "ProviderServer does not implement GetResourceIdentitySchemas")
582-
583-
protoResp := &tfplugin6.GetResourceIdentitySchemas_Response{
584-
Diagnostics: []*tfplugin6.Diagnostic{
585-
{
586-
Severity: tfplugin6.Diagnostic_ERROR,
587-
Summary: "Provider GetResourceIdentitySchemas Not Implemented",
588-
Detail: "A GetResourceIdentitySchemas call was received by the provider, however the provider does not implement the call. " +
589-
"Either upgrade the provider to a version that implements resource identity support or this is a bug in Terraform that should be reported to the Terraform maintainers.",
590-
},
591-
},
592-
}
593-
594-
return protoResp, nil
595-
}
596-
597-
// TODO: Update this to call downstream once optional interface is removed
598-
// resp, err := s.downstream.GetResourceIdentitySchemas(ctx, req)
599-
resp, err := resourceIdentityProviderServer.GetResourceIdentitySchemas(ctx, req)
575+
resp, err := s.downstream.GetResourceIdentitySchemas(ctx, req)
600576

601577
if err != nil {
602578
logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err})
@@ -846,31 +822,7 @@ func (s *server) UpgradeResourceIdentity(ctx context.Context, protoReq *tfplugin
846822

847823
ctx = tf6serverlogging.DownstreamRequest(ctx)
848824

849-
// TODO: Remove this check and error in preference of
850-
// s.downstream.UpgradeResourceIdentity below once ProviderServer interface
851-
// implements this RPC method.
852-
// nolint:staticcheck
853-
resourceIdentityProviderServer, ok := s.downstream.(tfprotov6.ProviderServerWithResourceIdentity)
854-
if !ok {
855-
logging.ProtocolError(ctx, "ProviderServer does not implement UpgradeResourceIdentity")
856-
857-
protoResp := &tfplugin6.UpgradeResourceIdentity_Response{
858-
Diagnostics: []*tfplugin6.Diagnostic{
859-
{
860-
Severity: tfplugin6.Diagnostic_ERROR,
861-
Summary: "Provider UpgradeResourceIdentity Not Implemented",
862-
Detail: "A UpgradeResourceIdentity call was received by the provider, however the provider does not implement the call. " +
863-
"Either upgrade the provider to a version that implements resource identity support or this is a bug in Terraform that should be reported to the Terraform maintainers.",
864-
},
865-
},
866-
}
867-
868-
return protoResp, nil
869-
}
870-
871-
// TODO: Update this to call downstream once optional interface is removed
872-
// resp, err := s.downstream.UpgradeResourceIdentity(ctx, req)
873-
resp, err := resourceIdentityProviderServer.UpgradeResourceIdentity(ctx, req)
825+
resp, err := s.downstream.UpgradeResourceIdentity(ctx, req)
874826

875827
if err != nil {
876828
logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err})

0 commit comments

Comments
 (0)