terraform: Refresh should work on Context state
This commit is contained in:
parent
38b3734d12
commit
c96886edce
|
@ -186,14 +186,11 @@ func (c *Context) Refresh() (*State, error) {
|
||||||
return c.state, err
|
return c.state, err
|
||||||
}
|
}
|
||||||
|
|
||||||
s := new(State)
|
|
||||||
s.init()
|
|
||||||
err = g.Walk(c.refreshWalkFn(s))
|
|
||||||
|
|
||||||
// Update our state
|
// Update our state
|
||||||
c.state = s
|
c.state = c.state.deepcopy()
|
||||||
|
|
||||||
return s, err
|
err = g.Walk(c.refreshWalkFn())
|
||||||
|
return c.state, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop stops the running task.
|
// Stop stops the running task.
|
||||||
|
@ -569,9 +566,7 @@ func (c *Context) planDestroyWalkFn(result *Plan) depgraph.WalkFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) refreshWalkFn(result *State) depgraph.WalkFunc {
|
func (c *Context) refreshWalkFn() depgraph.WalkFunc {
|
||||||
var l sync.Mutex
|
|
||||||
|
|
||||||
cb := func(r *Resource) error {
|
cb := func(r *Resource) error {
|
||||||
if r.State.ID == "" {
|
if r.State.ID == "" {
|
||||||
return nil
|
return nil
|
||||||
|
@ -592,9 +587,9 @@ func (c *Context) refreshWalkFn(result *State) depgraph.WalkFunc {
|
||||||
// Fix the type to be the type we have
|
// Fix the type to be the type we have
|
||||||
rs.Type = r.State.Type
|
rs.Type = r.State.Type
|
||||||
|
|
||||||
l.Lock()
|
c.sl.Lock()
|
||||||
result.Resources[r.Id] = rs
|
c.state.Resources[r.Id] = rs
|
||||||
l.Unlock()
|
c.sl.Unlock()
|
||||||
|
|
||||||
for _, h := range c.hooks {
|
for _, h := range c.hooks {
|
||||||
handleHook(h.PostRefresh(r.Id, rs))
|
handleHook(h.PostRefresh(r.Id, rs))
|
||||||
|
|
Loading…
Reference in New Issue