mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
update Refresh
Use the new ReadResource provider method
This commit is contained in:
parent
16df9c37cf
commit
ad7eee7ba4
@ -39,17 +39,19 @@ func (n *EvalRefresh) Eval(ctx EvalContext) (interface{}, error) {
|
||||
|
||||
// Refresh!
|
||||
priorVal := state.Value
|
||||
// TODO: Shim our new state type into the old one
|
||||
//provider := *n.Provider
|
||||
//state, err = provider.Refresh(legacyInfo, state)
|
||||
return nil, fmt.Errorf("EvalRefresh is not yet updated for new state type")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %s", n.Addr.Absolute(ctx.Path()), err.Error())
|
||||
req := providers.ReadResourceRequest{
|
||||
TypeName: n.Addr.Resource.Type,
|
||||
PriorState: priorVal,
|
||||
}
|
||||
if state == nil {
|
||||
log.Printf("[TRACE] EvalRefresh: after refresh, %s has nil state", n.Addr)
|
||||
|
||||
provider := *n.Provider
|
||||
resp := provider.ReadResource(req)
|
||||
if resp.Diagnostics.HasErrors() {
|
||||
return nil, fmt.Errorf("%s: %s", n.Addr.Absolute(ctx.Path()), resp.Diagnostics.Err())
|
||||
}
|
||||
|
||||
state.Value = resp.NewState
|
||||
|
||||
// Call post-refresh hook
|
||||
err = ctx.Hook(func(h Hook) (HookAction, error) {
|
||||
return h.PostRefresh(absAddr, states.CurrentGen, priorVal, state.Value)
|
||||
|
Loading…
Reference in New Issue
Block a user