parent
16df9c37cf
commit
ad7eee7ba4
|
@ -39,17 +39,19 @@ func (n *EvalRefresh) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
|
|
||||||
// Refresh!
|
// Refresh!
|
||||||
priorVal := state.Value
|
priorVal := state.Value
|
||||||
// TODO: Shim our new state type into the old one
|
req := providers.ReadResourceRequest{
|
||||||
//provider := *n.Provider
|
TypeName: n.Addr.Resource.Type,
|
||||||
//state, err = provider.Refresh(legacyInfo, state)
|
PriorState: priorVal,
|
||||||
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())
|
|
||||||
}
|
}
|
||||||
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
|
// Call post-refresh hook
|
||||||
err = ctx.Hook(func(h Hook) (HookAction, error) {
|
err = ctx.Hook(func(h Hook) (HookAction, error) {
|
||||||
return h.PostRefresh(absAddr, states.CurrentGen, priorVal, state.Value)
|
return h.PostRefresh(absAddr, states.CurrentGen, priorVal, state.Value)
|
||||||
|
|
Loading…
Reference in New Issue