send and receive Private through ReadResource
Send Private data blob through ReadResource as well. This will allow for extra flexibility for future providers that may want to pass data out of band through to their resource Read functions.
This commit is contained in:
parent
e2b2f1bbbc
commit
dcab82e897
|
@ -535,6 +535,11 @@ func (s *GRPCProviderServer) ReadResource(_ context.Context, req *proto.ReadReso
|
||||||
Msgpack: newStateMP,
|
Msgpack: newStateMP,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helper/schema did previously handle private data during refresh, but
|
||||||
|
// core is now going to expect this to be maintained in order to
|
||||||
|
// persist it in the state.
|
||||||
|
resp.Private = req.Private
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,6 +330,7 @@ func (p *GRPCProvider) ReadResource(r providers.ReadResourceRequest) (resp provi
|
||||||
protoReq := &proto.ReadResource_Request{
|
protoReq := &proto.ReadResource_Request{
|
||||||
TypeName: r.TypeName,
|
TypeName: r.TypeName,
|
||||||
CurrentState: &proto.DynamicValue{Msgpack: mp},
|
CurrentState: &proto.DynamicValue{Msgpack: mp},
|
||||||
|
Private: r.Private,
|
||||||
}
|
}
|
||||||
|
|
||||||
protoResp, err := p.client.ReadResource(p.ctx, protoReq)
|
protoResp, err := p.client.ReadResource(p.ctx, protoReq)
|
||||||
|
@ -348,6 +349,7 @@ func (p *GRPCProvider) ReadResource(r providers.ReadResourceRequest) (resp provi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp.NewState = state
|
resp.NewState = state
|
||||||
|
resp.Private = protoResp.Private
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,6 +176,10 @@ type ReadResourceRequest struct {
|
||||||
|
|
||||||
// PriorState contains the previously saved state value for this resource.
|
// PriorState contains the previously saved state value for this resource.
|
||||||
PriorState cty.Value
|
PriorState cty.Value
|
||||||
|
|
||||||
|
// Private is an opaque blob that will be stored in state along with the
|
||||||
|
// resource. It is intended only for interpretation by the provider itself.
|
||||||
|
Private []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReadResourceResponse struct {
|
type ReadResourceResponse struct {
|
||||||
|
@ -184,6 +188,10 @@ type ReadResourceResponse struct {
|
||||||
|
|
||||||
// Diagnostics contains any warnings or errors from the method call.
|
// Diagnostics contains any warnings or errors from the method call.
|
||||||
Diagnostics tfdiags.Diagnostics
|
Diagnostics tfdiags.Diagnostics
|
||||||
|
|
||||||
|
// Private is an opaque blob that will be stored in state along with the
|
||||||
|
// resource. It is intended only for interpretation by the provider itself.
|
||||||
|
Private []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlanResourceChangeRequest struct {
|
type PlanResourceChangeRequest struct {
|
||||||
|
|
|
@ -55,6 +55,7 @@ func (n *EvalRefresh) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
req := providers.ReadResourceRequest{
|
req := providers.ReadResourceRequest{
|
||||||
TypeName: n.Addr.Resource.Type,
|
TypeName: n.Addr.Resource.Type,
|
||||||
PriorState: priorVal,
|
PriorState: priorVal,
|
||||||
|
Private: state.Private,
|
||||||
}
|
}
|
||||||
|
|
||||||
provider := *n.Provider
|
provider := *n.Provider
|
||||||
|
@ -87,6 +88,7 @@ func (n *EvalRefresh) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
|
|
||||||
newState := state.DeepCopy()
|
newState := state.DeepCopy()
|
||||||
newState.Value = resp.NewState
|
newState.Value = resp.NewState
|
||||||
|
newState.Private = resp.Private
|
||||||
|
|
||||||
// Call post-refresh hook
|
// Call post-refresh hook
|
||||||
err = ctx.Hook(func(h Hook) (HookAction, error) {
|
err = ctx.Hook(func(h Hook) (HookAction, error) {
|
||||||
|
|
Loading…
Reference in New Issue