Skip to content

Commit

Permalink
fix partial init errors
Browse files Browse the repository at this point in the history
  • Loading branch information
VenelinMartinov committed Dec 6, 2024
1 parent 0852d64 commit 03b9498
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions pkg/tfshim/sdk-v2/provider2.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (p *planResourceChangeImpl) Apply(

resp, err := p.server.ApplyResourceChange(ctx, t, ty, cfg, st, pl, priv, meta)
if err != nil {
return nil, err
return resp, err
}
return &v2InstanceState2{
resourceType: t,
Expand Down Expand Up @@ -662,25 +662,26 @@ func (s *grpcServer) ApplyResourceChange(
}
req.ProviderMeta = &tfprotov5.DynamicValue{MsgPack: providerMetaVal}
}
resp, err := s.gserver.ApplyResourceChange(ctx, req)
if err := handleDiagnostics(ctx, resp.Diagnostics, err); err != nil {
return nil, err
}
newState, err := msgpack.Unmarshal(resp.NewState.MsgPack, ty)
if err != nil {
return nil, err
}
resp, applyErr := s.gserver.ApplyResourceChange(ctx, req)
newState := cty.Value{}
var meta map[string]interface{}
if resp.Private != nil {
if err := json.Unmarshal(resp.Private, &meta); err != nil {
if resp != nil && resp.NewState != nil {
newState, err = msgpack.Unmarshal(resp.NewState.MsgPack, ty)
if err != nil {
return nil, err
}
if resp.Private != nil {
if err := json.Unmarshal(resp.Private, &meta); err != nil {
return nil, err
}
}
}
returnErr := handleDiagnostics(ctx, resp.Diagnostics, applyErr)
return &v2InstanceState2{
resourceType: typeName,
stateValue: newState,
meta: meta,
}, nil
}, returnErr
}

func (s *grpcServer) ReadResource(
Expand Down

0 comments on commit 03b9498

Please sign in to comment.