Skip to content

Commit 17e7338

Browse files
add client capabilites across the board
1 parent 7f8ff8d commit 17e7338

File tree

10 files changed

+237
-183
lines changed

10 files changed

+237
-183
lines changed

docs/plugin-protocol/tfplugin5.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,8 @@ message InvokeAction {
970970
repeated LinkedResource linked_resources = 2;
971971
// response from the plan
972972
DynamicValue config = 3;
973+
// metadata
974+
ClientCapabilities client_capabilities = 4;
973975
}
974976

975977
message Event {

docs/plugin-protocol/tfplugin6.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,8 @@ message InvokeAction {
10081008
repeated LinkedResource linked_resources = 2;
10091009
// response from the plan
10101010
DynamicValue config = 3;
1011+
// metadata
1012+
ClientCapabilities client_capabilities = 4;
10111013
}
10121014

10131015
message Event {

internal/grpcwrap/provider.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,10 @@ func (p *provider) PlanAction(_ context.Context, req *tfplugin5.PlanAction_Reque
919919
ActionType: req.ActionType,
920920
ProposedActionData: configVal,
921921
LinkedResources: inputLinkedResources,
922+
ClientCapabilities: providers.ClientCapabilities{
923+
DeferralAllowed: true,
924+
WriteOnlyAttributesAllowed: true,
925+
},
922926
})
923927

924928
resp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, planResp.Diagnostics)
@@ -1015,6 +1019,10 @@ func (p *provider) InvokeAction(req *tfplugin5.InvokeAction_Request, server tfpl
10151019
ActionType: req.ActionType,
10161020
PlannedActionData: configVal,
10171021
LinkedResources: linkedResourceData,
1022+
ClientCapabilities: providers.ClientCapabilities{
1023+
DeferralAllowed: true,
1024+
WriteOnlyAttributesAllowed: true,
1025+
},
10181026
})
10191027

10201028
if invokeResp.Diagnostics.HasErrors() {

internal/grpcwrap/provider6.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,10 @@ func (p *provider6) PlanAction(_ context.Context, req *tfplugin6.PlanAction_Requ
990990
ActionType: req.ActionType,
991991
ProposedActionData: configVal,
992992
LinkedResources: inputLinkedResources,
993+
ClientCapabilities: providers.ClientCapabilities{
994+
DeferralAllowed: true,
995+
WriteOnlyAttributesAllowed: true,
996+
},
993997
})
994998

995999
resp.Diagnostics = convert.AppendProtoDiag(resp.Diagnostics, planResp.Diagnostics)
@@ -1086,6 +1090,10 @@ func (p *provider6) InvokeAction(req *tfplugin6.InvokeAction_Request, server tfp
10861090
ActionType: req.ActionType,
10871091
PlannedActionData: configVal,
10881092
LinkedResources: linkedResourceData,
1093+
ClientCapabilities: providers.ClientCapabilities{
1094+
DeferralAllowed: true,
1095+
WriteOnlyAttributesAllowed: true,
1096+
},
10891097
})
10901098

10911099
if invokeResp.Diagnostics.HasErrors() {

internal/plugin/grpc_provider.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,9 +1501,10 @@ func (p *GRPCProvider) InvokeAction(r providers.InvokeActionRequest) (resp provi
15011501
}
15021502

15031503
protoReq := &proto.InvokeAction_Request{
1504-
ActionType: r.ActionType,
1505-
Config: &proto.DynamicValue{Msgpack: configMP},
1506-
LinkedResources: linkedResources,
1504+
ActionType: r.ActionType,
1505+
Config: &proto.DynamicValue{Msgpack: configMP},
1506+
LinkedResources: linkedResources,
1507+
ClientCapabilities: clientCapabilitiesToProto(r.ClientCapabilities),
15071508
}
15081509

15091510
protoClient, err := p.client.InvokeAction(p.ctx, protoReq)

internal/plugin6/grpc_provider.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,9 +1518,10 @@ func (p *GRPCProvider) InvokeAction(r providers.InvokeActionRequest) (resp provi
15181518
}
15191519

15201520
protoReq := &proto6.InvokeAction_Request{
1521-
ActionType: r.ActionType,
1522-
Config: &proto6.DynamicValue{Msgpack: configMP},
1523-
LinkedResources: linkedResources,
1521+
ActionType: r.ActionType,
1522+
Config: &proto6.DynamicValue{Msgpack: configMP},
1523+
LinkedResources: linkedResources,
1524+
ClientCapabilities: clientCapabilitiesToProto(r.ClientCapabilities),
15241525
}
15251526

15261527
protoClient, err := p.client.InvokeAction(p.ctx, protoReq)

internal/providers/provider.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,9 +915,10 @@ type PlanActionResponse struct {
915915
}
916916

917917
type InvokeActionRequest struct {
918-
ActionType string
919-
LinkedResources []LinkedResourceInvokeData
920-
PlannedActionData cty.Value
918+
ActionType string
919+
LinkedResources []LinkedResourceInvokeData
920+
PlannedActionData cty.Value
921+
ClientCapabilities ClientCapabilities
921922
}
922923

923924
type InvokeActionResponse struct {

internal/terraform/node_action_apply.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ func invokeActions(ctx EvalContext, actionInvocations []*plans.ActionInvocationI
140140
return h.StartAction(hookIdentity)
141141
})
142142
resp := provider.InvokeAction(providers.InvokeActionRequest{
143-
ActionType: orderedActionInvocations[i].Addr.Action.Action.Type,
144-
PlannedActionData: unmarkedConfigValue,
143+
ActionType: orderedActionInvocations[i].Addr.Action.Action.Type,
144+
PlannedActionData: unmarkedConfigValue,
145+
ClientCapabilities: ctx.ClientCapabilities(),
145146
})
146147

147148
diags = diags.Append(resp.Diagnostics)

internal/tfplugin5/tfplugin5.pb.go

Lines changed: 101 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/tfplugin6/tfplugin6.pb.go

Lines changed: 101 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)