github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/terraform/transform_removed_modules.go (about)

     1  package terraform
     2  
     3  import (
     4  	"log"
     5  
     6  	"github.com/hashicorp/terraform/config/module"
     7  )
     8  
     9  // RemoveModuleTransformer implements GraphTransformer to add nodes indicating
    10  // when a module was removed from the configuration.
    11  type RemovedModuleTransformer struct {
    12  	Module *module.Tree // root module
    13  	State  *State
    14  }
    15  
    16  func (t *RemovedModuleTransformer) Transform(g *Graph) error {
    17  	// nothing to remove if there's no state!
    18  	if t.State == nil {
    19  		return nil
    20  	}
    21  
    22  	for _, m := range t.State.Modules {
    23  		c := t.Module.Child(m.Path[1:])
    24  		if c != nil {
    25  			continue
    26  		}
    27  
    28  		log.Printf("[DEBUG] module %s no longer in config\n", modulePrefixStr(m.Path))
    29  		g.Add(&NodeModuleRemoved{PathValue: m.Path})
    30  	}
    31  	return nil
    32  }