Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/unreleased/NOTES-20250916-124728.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: NOTES
body: 'helper/schema: Update the provider server to handle Action RPCs by returning an error since they are not supported by SDKv2.'
time: 2025-09-16T12:47:28.705896-04:00
custom:
Issue: "1522"
64 changes: 64 additions & 0 deletions helper/schema/grpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func (s *GRPCProviderServer) GetMetadata(ctx context.Context, req *tfprotov5.Get
EphemeralResources: make([]tfprotov5.EphemeralResourceMetadata, 0),
Functions: make([]tfprotov5.FunctionMetadata, 0),
ListResources: make([]tfprotov5.ListResourceMetadata, 0),
Actions: make([]tfprotov5.ActionMetadata, 0),
Resources: make([]tfprotov5.ResourceMetadata, 0, len(s.provider.ResourcesMap)),
ServerCapabilities: s.serverCapabilities(),
}
Expand Down Expand Up @@ -227,6 +228,7 @@ func (s *GRPCProviderServer) GetProviderSchema(ctx context.Context, req *tfproto
EphemeralResourceSchemas: make(map[string]*tfprotov5.Schema, 0),
Functions: make(map[string]*tfprotov5.Function, 0),
ListResourceSchemas: make(map[string]*tfprotov5.Schema, 0),
ActionSchemas: make(map[string]*tfprotov5.ActionSchema, 0),
ResourceSchemas: make(map[string]*tfprotov5.Schema, len(s.provider.ResourcesMap)),
ServerCapabilities: s.serverCapabilities(),
}
Expand Down Expand Up @@ -2065,6 +2067,68 @@ func (s *GRPCProviderServer) ListResource(ctx context.Context, req *tfprotov5.Li
return resp, nil
}

func (s *GRPCProviderServer) ValidateActionConfig(ctx context.Context, req *tfprotov5.ValidateActionConfigRequest) (*tfprotov5.ValidateActionConfigResponse, error) {
ctx = logging.InitContext(ctx)

logging.HelperSchemaTrace(ctx, "Returning error for action type validate")

resp := &tfprotov5.ValidateActionConfigResponse{
Diagnostics: []*tfprotov5.Diagnostic{
{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "Unknown Action Type",
Detail: fmt.Sprintf("The %q action type is not supported by this provider.", req.ActionType),
},
},
}

return resp, nil
}

func (s *GRPCProviderServer) PlanAction(ctx context.Context, req *tfprotov5.PlanActionRequest) (*tfprotov5.PlanActionResponse, error) {
ctx = logging.InitContext(ctx)

logging.HelperSchemaTrace(ctx, "Returning error for action type plan")

resp := &tfprotov5.PlanActionResponse{
Diagnostics: []*tfprotov5.Diagnostic{
{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "Unknown Action Type",
Detail: fmt.Sprintf("The %q action type is not supported by this provider.", req.ActionType),
},
},
}

return resp, nil
}

func (s *GRPCProviderServer) InvokeAction(ctx context.Context, req *tfprotov5.InvokeActionRequest) (*tfprotov5.InvokeActionServerStream, error) {
ctx = logging.InitContext(ctx)

logging.HelperSchemaTrace(ctx, "Returning error for action invoke")

event := make([]tfprotov5.InvokeActionEvent, 0)

event = append(event, tfprotov5.InvokeActionEvent{
Type: tfprotov5.CompletedInvokeActionEventType{
Diagnostics: []*tfprotov5.Diagnostic{
{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "Unknown Action Type",
Detail: fmt.Sprintf("The %q action type is not supported by this provider.", req.ActionType),
},
},
},
})

resp := &tfprotov5.InvokeActionServerStream{
Events: slices.Values(event),
}

return resp, nil
}

func pathToAttributePath(path cty.Path) *tftypes.AttributePath {
var steps []tftypes.AttributePathStep

Expand Down
3 changes: 3 additions & 0 deletions helper/schema/grpc_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3763,6 +3763,7 @@ func TestGRPCProviderServerGetMetadata(t *testing.T) {
Functions: []tfprotov5.FunctionMetadata{},
EphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
ListResources: []tfprotov5.ListResourceMetadata{},
Actions: []tfprotov5.ActionMetadata{},
Resources: []tfprotov5.ResourceMetadata{},
ServerCapabilities: &tfprotov5.ServerCapabilities{
GetProviderSchemaOptional: true,
Expand Down Expand Up @@ -3792,6 +3793,7 @@ func TestGRPCProviderServerGetMetadata(t *testing.T) {
Functions: []tfprotov5.FunctionMetadata{},
EphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
ListResources: []tfprotov5.ListResourceMetadata{},
Actions: []tfprotov5.ActionMetadata{},
Resources: []tfprotov5.ResourceMetadata{
{
TypeName: "test_resource1",
Expand All @@ -3817,6 +3819,7 @@ func TestGRPCProviderServerGetMetadata(t *testing.T) {
Functions: []tfprotov5.FunctionMetadata{},
EphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
ListResources: []tfprotov5.ListResourceMetadata{},
Actions: []tfprotov5.ActionMetadata{},
Resources: []tfprotov5.ResourceMetadata{
{
TypeName: "test_resource1",
Expand Down