terraform: more tests passing
This commit is contained in:
parent
101ac636a2
commit
3b89a7bdc7
|
@ -1135,6 +1135,11 @@ func (c *walkContext) genericWalkFn(cb genericWalkFunc) depgraph.WalkFunc {
|
|||
|
||||
// If we're expanding, then expand the nodes, and then rewalk the graph
|
||||
if rn.ExpandMode > ResourceExpandNone {
|
||||
// Interpolate the count
|
||||
rc := NewResourceConfig(rn.Config.RawCount)
|
||||
rc.interpolate(c)
|
||||
|
||||
// Expand the node to the actual resources
|
||||
ns, err := rn.Expand()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1148,14 +1153,14 @@ func (c *walkContext) genericWalkFn(cb genericWalkFunc) depgraph.WalkFunc {
|
|||
for _, n := range ns {
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
go func(n *depgraph.Noun) {
|
||||
defer wg.Done()
|
||||
if err := walkFn(n); err != nil {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}()
|
||||
}(n)
|
||||
}
|
||||
|
||||
// Wait for the subgraph
|
||||
|
@ -1515,13 +1520,22 @@ func (c *walkContext) computeResourceMultiVariable(
|
|||
// TODO: Not use only root module
|
||||
module := c.Context.state.RootModule()
|
||||
|
||||
// TODO: handle computed here
|
||||
count, err := cr.Count()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf(
|
||||
"Error reading %s count: %s",
|
||||
v.ResourceId(),
|
||||
err)
|
||||
}
|
||||
|
||||
var values []string
|
||||
for i := 0; i < cr.Count; i++ {
|
||||
for i := 0; i < count; i++ {
|
||||
id := fmt.Sprintf("%s.%d", v.ResourceId(), i)
|
||||
|
||||
// If we're dealing with only a single resource, then the
|
||||
// ID doesn't have a trailing index.
|
||||
if cr.Count == 1 {
|
||||
if count == 1 {
|
||||
id = v.ResourceId()
|
||||
}
|
||||
|
||||
|
|
|
@ -603,11 +603,13 @@ func graphAddDiff(g *depgraph.Graph, d *ModuleDiff) error {
|
|||
|
||||
// Add a depedency from the root, since the create node
|
||||
// does not depend on us
|
||||
g.Root.Deps = append(g.Root.Deps, &depgraph.Dependency{
|
||||
Name: newN.Name,
|
||||
Source: g.Root,
|
||||
Target: newN,
|
||||
})
|
||||
if g.Root != nil {
|
||||
g.Root.Deps = append(g.Root.Deps, &depgraph.Dependency{
|
||||
Name: newN.Name,
|
||||
Source: g.Root,
|
||||
Target: newN,
|
||||
})
|
||||
}
|
||||
|
||||
// Set the ReplacePrimary flag on the new instance so that
|
||||
// it will become the new primary, and Diposed flag on the
|
||||
|
@ -1590,9 +1592,18 @@ func (p *graphSharedProvider) MergeConfig(
|
|||
|
||||
// Expand will expand this node into a subgraph if Expand is set.
|
||||
func (n *GraphNodeResource) Expand() ([]*depgraph.Noun, error) {
|
||||
count := 1
|
||||
// Expand the count out, which should be interpolated at this point
|
||||
count, err := n.Config.Count()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Printf("[DEBUG] %s: expanding to count = %d", n.Resource.Id, count)
|
||||
|
||||
// TODO: can we DRY this up?
|
||||
g := new(depgraph.Graph)
|
||||
g.Meta = &GraphMeta{
|
||||
ModulePath: n.Resource.Info.ModulePath,
|
||||
}
|
||||
|
||||
// Determine the nodes to create. If we're just looking for the
|
||||
// nodes to create, return that.
|
||||
|
|
Loading…
Reference in New Issue