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 we're expanding, then expand the nodes, and then rewalk the graph
|
||||||
if rn.ExpandMode > ResourceExpandNone {
|
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()
|
ns, err := rn.Expand()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1148,14 +1153,14 @@ func (c *walkContext) genericWalkFn(cb genericWalkFunc) depgraph.WalkFunc {
|
||||||
for _, n := range ns {
|
for _, n := range ns {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
||||||
go func() {
|
go func(n *depgraph.Noun) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := walkFn(n); err != nil {
|
if err := walkFn(n); err != nil {
|
||||||
l.Lock()
|
l.Lock()
|
||||||
defer l.Unlock()
|
defer l.Unlock()
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
}()
|
}(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the subgraph
|
// Wait for the subgraph
|
||||||
|
@ -1515,13 +1520,22 @@ func (c *walkContext) computeResourceMultiVariable(
|
||||||
// TODO: Not use only root module
|
// TODO: Not use only root module
|
||||||
module := c.Context.state.RootModule()
|
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
|
var values []string
|
||||||
for i := 0; i < cr.Count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
id := fmt.Sprintf("%s.%d", v.ResourceId(), i)
|
id := fmt.Sprintf("%s.%d", v.ResourceId(), i)
|
||||||
|
|
||||||
// If we're dealing with only a single resource, then the
|
// If we're dealing with only a single resource, then the
|
||||||
// ID doesn't have a trailing index.
|
// ID doesn't have a trailing index.
|
||||||
if cr.Count == 1 {
|
if count == 1 {
|
||||||
id = v.ResourceId()
|
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
|
// Add a depedency from the root, since the create node
|
||||||
// does not depend on us
|
// does not depend on us
|
||||||
g.Root.Deps = append(g.Root.Deps, &depgraph.Dependency{
|
if g.Root != nil {
|
||||||
Name: newN.Name,
|
g.Root.Deps = append(g.Root.Deps, &depgraph.Dependency{
|
||||||
Source: g.Root,
|
Name: newN.Name,
|
||||||
Target: newN,
|
Source: g.Root,
|
||||||
})
|
Target: newN,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Set the ReplacePrimary flag on the new instance so that
|
// Set the ReplacePrimary flag on the new instance so that
|
||||||
// it will become the new primary, and Diposed flag on the
|
// 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.
|
// Expand will expand this node into a subgraph if Expand is set.
|
||||||
func (n *GraphNodeResource) Expand() ([]*depgraph.Noun, error) {
|
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 := new(depgraph.Graph)
|
||||||
|
g.Meta = &GraphMeta{
|
||||||
|
ModulePath: n.Resource.Info.ModulePath,
|
||||||
|
}
|
||||||
|
|
||||||
// Determine the nodes to create. If we're just looking for the
|
// Determine the nodes to create. If we're just looking for the
|
||||||
// nodes to create, return that.
|
// nodes to create, return that.
|
||||||
|
|
Loading…
Reference in New Issue