diff --git a/terraform/node_provisioner.go b/terraform/node_provisioner.go index cdd74f4bb..31ed1a8c8 100644 --- a/terraform/node_provisioner.go +++ b/terraform/node_provisioner.go @@ -28,7 +28,7 @@ var ( func (n *NodeProvisioner) Name() string { result := fmt.Sprintf("provisioner.%s", n.NameValue) - if len(n.PathValue) > 1 { + if len(n.PathValue) > 0 { result = fmt.Sprintf("%s.%s", n.PathValue.String(), result) } diff --git a/terraform/transform_provisioner.go b/terraform/transform_provisioner.go index a3081207c..971bdb522 100644 --- a/terraform/transform_provisioner.go +++ b/terraform/transform_provisioner.go @@ -2,6 +2,7 @@ package terraform import ( "fmt" + "log" "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/config/configschema" @@ -57,6 +58,7 @@ func (t *ProvisionerTransformer) Transform(g *Graph) error { continue } + log.Printf("[TRACE] ProvisionerTransformer: %s is provisioned by %s (%q)", dag.VertexName(v), key, dag.VertexName(m[key])) g.Connect(dag.BasicEdge(v, m[key])) } } @@ -120,6 +122,7 @@ func (t *MissingProvisionerTransformer) Transform(g *Graph) error { // Add the missing provisioner node to the graph m[key] = g.Add(newV) + log.Printf("[TRACE] MissingProviderTransformer: added implicit provisioner %s, first implied by %s", key, dag.VertexName(v)) } } diff --git a/terraform/transform_provisioner_test.go b/terraform/transform_provisioner_test.go index b7002226f..546c9b697 100644 --- a/terraform/transform_provisioner_test.go +++ b/terraform/transform_provisioner_test.go @@ -86,6 +86,7 @@ func TestMissingProvisionerTransformer_module(t *testing.T) { if err := tf.Transform(&g); err != nil { t.Fatalf("err: %s", err) } + t.Logf("graph after StateTransformer:\n%s", g.StringWithNodeTypes()) } { @@ -100,6 +101,7 @@ func TestMissingProvisionerTransformer_module(t *testing.T) { if err := transform.Transform(&g); err != nil { t.Fatalf("err: %s", err) } + t.Logf("graph after MissingProvisionerTransformer:\n%s", g.StringWithNodeTypes()) } { @@ -107,12 +109,13 @@ func TestMissingProvisionerTransformer_module(t *testing.T) { if err := transform.Transform(&g); err != nil { t.Fatalf("err: %s", err) } + t.Logf("graph after ProvisionerTransformer:\n%s", g.StringWithNodeTypes()) } actual := strings.TrimSpace(g.String()) expected := strings.TrimSpace(testTransformMissingProvisionerModuleStr) if actual != expected { - t.Fatalf("bad:\n\n%s", actual) + t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected) } }