6 "github.com/hashicorp/terraform/config"
7 "github.com/hashicorp/terraform/config/module"
10 // OrphanOutputTransformer finds the outputs that aren't present
11 // in the given config that are in the state and adds them to the graph
13 type OrphanOutputTransformer struct {
14 Module *module.Tree // Root module
15 State *State // State is the root state
18 func (t *OrphanOutputTransformer) Transform(g *Graph) error {
20 log.Printf("[DEBUG] No state, no orphan outputs")
24 for _, ms := range t.State.Modules {
25 if err := t.transform(g, ms); err != nil {
32 func (t *OrphanOutputTransformer) transform(g *Graph, ms *ModuleState) error {
37 path := normalizeModulePath(ms.Path)
39 // Get the config for this path, which is nil if the entire module has been
42 if m := t.Module.Child(path[1:]); m != nil {
46 // add all the orphaned outputs to the graph
47 for _, n := range ms.RemovedOutputs(c) {
48 g.Add(&NodeOutputOrphan{OutputName: n, PathValue: path})