core: make orphans flattenable

Got this while playing around in a module:

> * unflattenable node: aws_security_group.internal (orphan)
> *terraform.graphNodeOrphanResource

Basically just copied implementation from
d503cc2d82
This commit is contained in:
Paul Hinze 2015-05-11 22:24:11 -05:00
parent a2cadbb5c1
commit 0273732dec
1 changed files with 23 additions and 0 deletions

View File

@ -176,6 +176,13 @@ func (n *graphNodeOrphanResource) DependentOn() []string {
return n.dependentOn
}
func (n *graphNodeOrphanResource) Flatten(p []string) (dag.Vertex, error) {
return &graphNodeOrphanResourceFlat{
graphNodeOrphanResource: n,
PathValue: p,
}, nil
}
func (n *graphNodeOrphanResource) Name() string {
return fmt.Sprintf("%s (orphan)", n.ResourceName)
}
@ -290,3 +297,19 @@ func (n *graphNodeOrphanResource) EvalTree() EvalNode {
func (n *graphNodeOrphanResource) dependableName() string {
return n.ResourceName
}
// Same as graphNodeOrphanResource, but for flattening
type graphNodeOrphanResourceFlat struct {
*graphNodeOrphanResource
PathValue []string
}
func (n *graphNodeOrphanResourceFlat) Name() string {
return fmt.Sprintf(
"%s.%s", modulePrefixStr(n.PathValue), n.graphNodeOrphanResource.Name())
}
func (n *graphNodeOrphanResourceFlat) Path() []string {
return n.PathValue
}