func provisionerMapKey(k string, v dag.Vertex) string {
	pathPrefix := ""
	if sp, ok := v.(GraphNodeSubPath); ok {
		raw := normalizeModulePath(sp.Path())
		if len(raw) > len(rootModulePath) {
			pathPrefix = modulePrefixStr(raw) + "."
		}
	}
	return pathPrefix + k
}
provisionerMapKey is a helper that gives us the key to use for the
maps returned by things such as provisionerVertexMap.
package terraform
import (
	"fmt"
	"github.com/hashicorp/go-multierror"
	"github.com/hashicorp/terraform/dag"
)
type GraphNodeProvisioner interface {
	ProvisionerName() string
}
type GraphNodeCloseProvisioner interface {
	CloseProvisionerName() string
}
type GraphNodeProvisionerConsumer interface {
	ProvisionedBy() []string
}
type ProvisionerTransformer struct{}
func (t *ProvisionerTransformer) Transform(g *Graph) error {
	var err error
	m := provisionerVertexMap(g)
	for _, v := range g.Vertices() {
		if pv, ok := v.(GraphNodeProvisionerConsumer); ok {
			for _, p := range pv.ProvisionedBy() {
				key := provisionerMapKey(p, pv)
				if m[key] == nil {
					err = multierror.Append(err, fmt.Errorf(
						"%s: provisioner %s couldn't be found",
						dag.VertexName(v), p))
					continue
				}
				g.Connect(dag.BasicEdge(v, m[key]))
			}
		}
	}
	return err
}
type MissingProvisionerTransformer struct {
	Provisioners []string
}
func (t *MissingProvisionerTransformer) Transform(g *Graph) error {
	supported := make(map[string]struct{}, len(t.Provisioners))
	for _, v := range t.Provisioners {
		supported[v] = struct{}{}
	}
	m := provisionerVertexMap(g)
	for _, v := range g.Vertices() {
		pv, ok := v.(GraphNodeProvisionerConsumer)
		if !ok {
			continue
		}
		var path []string
		if sp, ok := pv.(GraphNodeSubPath); ok {
			raw := normalizeModulePath(sp.Path())
			if len(raw) > len(rootModulePath) {
				path = raw
			}
		}
		for _, p := range pv.ProvisionedBy() {
			key := provisionerMapKey(p, pv)
			if _, ok := m[key]; ok {
				continue
			}
			if _, ok := supported[p]; !ok {
				continue
			}
			var newV dag.Vertex = &NodeProvisioner{
				NameValue: p,
				PathValue: path,
			}
			m[key] = g.Add(newV)
		}
	}
	return nil
}
type CloseProvisionerTransformer struct{}
func (t *CloseProvisionerTransformer) Transform(g *Graph) error {
	m := closeProvisionerVertexMap(g)
	for _, v := range g.Vertices() {
		if pv, ok := v.(GraphNodeProvisionerConsumer); ok {
			for _, p := range pv.ProvisionedBy() {
				source := m[p]
				if source == nil {
					source = &graphNodeCloseProvisioner{ProvisionerNameValue: p}
					g.Add(source)
					m[p] = source
				}
				g.Connect(dag.BasicEdge(source, v))
			}
		}
	}
	return nil
}