mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 00:41:27 -06:00
d905b990a5
Make the interface name reflect the new return type of the method. Remove the confusingly named and unused ResourceAddress method from the resource nodes as well.
37 lines
917 B
Go
37 lines
917 B
Go
package terraform
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/hashicorp/terraform/addrs"
|
|
"github.com/hashicorp/terraform/configs/configschema"
|
|
"github.com/hashicorp/terraform/dag"
|
|
)
|
|
|
|
// ResourceCountTransformer is a GraphTransformer that expands the count
|
|
// out for a specific resource.
|
|
//
|
|
// This assumes that the count is already interpolated.
|
|
type ResourceCountTransformer struct {
|
|
Concrete ConcreteResourceInstanceNodeFunc
|
|
Schema *configschema.Block
|
|
|
|
Addr addrs.ConfigResource
|
|
InstanceAddrs []addrs.AbsResourceInstance
|
|
}
|
|
|
|
func (t *ResourceCountTransformer) Transform(g *Graph) error {
|
|
for _, addr := range t.InstanceAddrs {
|
|
abstract := NewNodeAbstractResourceInstance(addr)
|
|
abstract.Schema = t.Schema
|
|
var node dag.Vertex = abstract
|
|
if f := t.Concrete; f != nil {
|
|
node = f(abstract)
|
|
}
|
|
|
|
log.Printf("[TRACE] ResourceCountTransformer: adding %s as %T", addr, node)
|
|
g.Add(node)
|
|
}
|
|
return nil
|
|
}
|