Skip to content

Commit

Permalink
ephemeral: add WriteOnlyAttributesAllowed client capability
Browse files Browse the repository at this point in the history
we allow it for all requests
  • Loading branch information
DanielMSchmidt committed Dec 4, 2024
1 parent f3b28eb commit e98e14c
Show file tree
Hide file tree
Showing 11 changed files with 1,332 additions and 1,282 deletions.
4 changes: 4 additions & 0 deletions docs/plugin-protocol/tfplugin5.8.proto
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ message ClientCapabilities {
// The deferral_allowed capability signals that the client is able to
// handle deferred responses from the provider.
bool deferral_allowed = 1;

// The write_only_attributes_allowed capability signals that the client
// is able to handle write_only attributes for managed resources.
bool write_only_attributes_allowed = 2;
}

message Function {
Expand Down
4 changes: 4 additions & 0 deletions docs/plugin-protocol/tfplugin6.8.proto
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ message ClientCapabilities {
// The deferral_allowed capability signals that the client is able to
// handle deferred responses from the provider.
bool deferral_allowed = 1;

// The write_only_attributes_allowed capability signals that the client
// is able to handle write_only attributes for managed resources.
bool write_only_attributes_allowed = 2;
}

// Deferred is a message that indicates that change is deferred for a reason.
Expand Down
3 changes: 2 additions & 1 deletion internal/plugin6/grpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ func (p *GRPCProvider) ConfigureProvider(r providers.ConfigureProviderRequest) (
Msgpack: mp,
},
ClientCapabilities: &proto6.ClientCapabilities{
DeferralAllowed: r.ClientCapabilities.DeferralAllowed,
DeferralAllowed: r.ClientCapabilities.DeferralAllowed,
WriteOnlyAttributesAllowed: r.ClientCapabilities.WriteOnlyAttributesAllowed,
},
}

Expand Down
4 changes: 4 additions & 0 deletions internal/providers/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ type ClientCapabilities struct {
// The deferral_allowed capability signals that the client is able to
// handle deferred responses from the provider.
DeferralAllowed bool

// The write_only_attributes_allowed capability signals that the client
// is able to handle write_only attributes for managed resources.
WriteOnlyAttributesAllowed bool
}

type ValidateProviderConfigRequest struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ func (p *ProviderInstance) CheckClient(ctx context.Context, phase EvalPhase) (pr
TerraformVersion: version.SemVer.String(),
Config: unmarkedArgs,
ClientCapabilities: providers.ClientCapabilities{
DeferralAllowed: true,
DeferralAllowed: true,
WriteOnlyAttributesAllowed: true,
},
})
diags = diags.Append(resp.Diagnostics)
Expand Down
3 changes: 2 additions & 1 deletion internal/terraform/eval_context_builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ func (ctx *BuiltinEvalContext) ConfigureProvider(addr addrs.AbsProviderConfig, c
TerraformVersion: version.String(),
Config: cfg,
ClientCapabilities: providers.ClientCapabilities{
DeferralAllowed: ctx.Deferrals().DeferralAllowed(),
DeferralAllowed: ctx.Deferrals().DeferralAllowed(),
WriteOnlyAttributesAllowed: true,
},
}

Expand Down
15 changes: 10 additions & 5 deletions internal/terraform/node_resource_abstract_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ func (n *NodeAbstractResourceInstance) planDestroy(ctx EvalContext, currentState
PriorPrivate: currentState.Private,
ProviderMeta: metaConfigVal,
ClientCapabilities: providers.ClientCapabilities{
DeferralAllowed: deferralAllowed,
DeferralAllowed: deferralAllowed,
WriteOnlyAttributesAllowed: true,
},
})
deferred = resp.Deferred
Expand Down Expand Up @@ -639,7 +640,8 @@ func (n *NodeAbstractResourceInstance) refresh(ctx EvalContext, deposedKey state
Private: state.Private,
ProviderMeta: metaConfigVal,
ClientCapabilities: providers.ClientCapabilities{
DeferralAllowed: deferralAllowed,
DeferralAllowed: deferralAllowed,
WriteOnlyAttributesAllowed: true,
},
})

Expand Down Expand Up @@ -941,7 +943,8 @@ func (n *NodeAbstractResourceInstance) plan(
PriorPrivate: priorPrivate,
ProviderMeta: metaConfigVal,
ClientCapabilities: providers.ClientCapabilities{
DeferralAllowed: deferralAllowed,
DeferralAllowed: deferralAllowed,
WriteOnlyAttributesAllowed: true,
},
})
// If we don't support deferrals, but the provider reports a deferral and does not
Expand Down Expand Up @@ -1114,7 +1117,8 @@ func (n *NodeAbstractResourceInstance) plan(
PriorPrivate: plannedPrivate,
ProviderMeta: metaConfigVal,
ClientCapabilities: providers.ClientCapabilities{
DeferralAllowed: deferralAllowed,
DeferralAllowed: deferralAllowed,
WriteOnlyAttributesAllowed: true,
},
})

Expand Down Expand Up @@ -1561,7 +1565,8 @@ func (n *NodeAbstractResourceInstance) readDataSource(ctx EvalContext, configVal
Config: configVal,
ProviderMeta: metaConfigVal,
ClientCapabilities: providers.ClientCapabilities{
DeferralAllowed: deferralAllowed,
DeferralAllowed: deferralAllowed,
WriteOnlyAttributesAllowed: true,
},
})

Expand Down
3 changes: 2 additions & 1 deletion internal/terraform/node_resource_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ func (n *graphNodeImportState) Execute(ctx EvalContext, op walkOperation) (diags
TypeName: n.Addr.Resource.Resource.Type,
ID: n.ID,
ClientCapabilities: providers.ClientCapabilities{
DeferralAllowed: false,
DeferralAllowed: false,
WriteOnlyAttributesAllowed: true,
},
})
diags = diags.Append(resp.Diagnostics)
Expand Down
3 changes: 2 additions & 1 deletion internal/terraform/node_resource_plan_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,8 @@ func (n *NodePlannableResourceInstance) importState(ctx EvalContext, addr addrs.
TypeName: addr.Resource.Resource.Type,
ID: importId,
ClientCapabilities: providers.ClientCapabilities{
DeferralAllowed: deferralAllowed,
DeferralAllowed: deferralAllowed,
WriteOnlyAttributesAllowed: true,
},
})
}
Expand Down
Loading

0 comments on commit e98e14c

Please sign in to comment.