terraform: minor cleanup

This commit is contained in:
Armon Dadgar 2014-09-19 14:54:21 -07:00
parent a1c4a27715
commit 9594ed6e1c
1 changed files with 4 additions and 11 deletions

View File

@ -217,6 +217,9 @@ func EncodeDependencies(g *depgraph.Graph) {
// configGraph turns a configuration structure into a dependency graph. // configGraph turns a configuration structure into a dependency graph.
func graphAddConfigResources( func graphAddConfigResources(
g *depgraph.Graph, c *config.Config, s *State) { g *depgraph.Graph, c *config.Config, s *State) {
// TODO: Handle non-root modules
mod := s.ModuleByPath(rootModulePath)
// This tracks all the resource nouns // This tracks all the resource nouns
nouns := make(map[string]*depgraph.Noun) nouns := make(map[string]*depgraph.Noun)
for _, r := range c.Resources { for _, r := range c.Resources {
@ -232,12 +235,7 @@ func graphAddConfigResources(
index = i index = i
} }
tainted := false
var state *ResourceState var state *ResourceState
// TODO: Handle non-root modules
mod := s.ModuleByPath(rootModulePath)
if s != nil && mod != nil { if s != nil && mod != nil {
// Lookup the resource state // Lookup the resource state
state = mod.Resources[name] state = mod.Resources[name]
@ -254,11 +252,6 @@ func graphAddConfigResources(
state = mod.Resources[r.Id()] state = mod.Resources[r.Id()]
} }
} }
// Determine if this resource is tainted
if state != nil && len(state.Tainted) > 0 {
tainted = true
}
} }
if state == nil { if state == nil {
@ -277,7 +270,7 @@ func graphAddConfigResources(
Id: name, Id: name,
State: state, State: state,
Config: NewResourceConfig(r.RawConfig), Config: NewResourceConfig(r.RawConfig),
Tainted: tainted, Tainted: len(state.Tainted) > 0,
}, },
}, },
} }