diff --git a/config/testing.go b/config/testing.go new file mode 100644 index 000000000..f7bfadd9e --- /dev/null +++ b/config/testing.go @@ -0,0 +1,15 @@ +package config + +import ( + "testing" +) + +// TestRawConfig is used to create a RawConfig for testing. +func TestRawConfig(t *testing.T, c map[string]interface{}) *RawConfig { + cfg, err := NewRawConfig(c) + if err != nil { + t.Fatalf("err: %s", err) + } + + return cfg +} diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 4d4d7b7d9..b6955b5c5 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -960,7 +960,7 @@ func TestContext2Apply_countDecrease(t *testing.T) { } } -func TestContext2Apply_countDecreaseToOne(t *testing.T) { +func TestContext2Apply_countDecreaseToOneX(t *testing.T) { m := testModule(t, "apply-count-dec-one") p := testProvider("aws") p.ApplyFn = testApplyFn diff --git a/terraform/graph_builder_apply.go b/terraform/graph_builder_apply.go index 8ff13343f..f5e7e7b85 100644 --- a/terraform/graph_builder_apply.go +++ b/terraform/graph_builder_apply.go @@ -58,6 +58,7 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer { &MissingProviderTransformer{Providers: b.Providers, Factory: providerFactory}, &ProviderTransformer{}, &ParentProviderTransformer{}, + &AttachProviderConfigTransformer{Module: b.Module}, // Provisioner-related transformations &MissingProvisionerTransformer{Provisioners: b.Provisioners}, @@ -75,9 +76,6 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer { // Connect references so ordering is correct &ReferenceTransformer{}, - // Attach the configurations - &AttachConfigTransformer{Module: b.Module}, - // Single root &RootTransformer{}, } diff --git a/terraform/transform_attach_config.go b/terraform/transform_attach_config_provider.go similarity index 82% rename from terraform/transform_attach_config.go rename to terraform/transform_attach_config_provider.go index 1802ac5d9..4b41a2d0f 100644 --- a/terraform/transform_attach_config.go +++ b/terraform/transform_attach_config_provider.go @@ -20,16 +20,17 @@ type GraphNodeAttachProvider interface { AttachProvider(*config.ProviderConfig) } -// AttachConfigTransformer goes through the graph and attaches configuration -// structures to nodes that implement the interfaces above. +// AttachProviderConfigTransformer goes through the graph and attaches +// provider configuration structures to nodes that implement the interfaces +// above. // // The attached configuration structures are directly from the configuration. // If they're going to be modified, a copy should be made. -type AttachConfigTransformer struct { +type AttachProviderConfigTransformer struct { Module *module.Tree // Module is the root module for the config } -func (t *AttachConfigTransformer) Transform(g *Graph) error { +func (t *AttachProviderConfigTransformer) Transform(g *Graph) error { if err := t.attachProviders(g); err != nil { return err } @@ -37,7 +38,7 @@ func (t *AttachConfigTransformer) Transform(g *Graph) error { return nil } -func (t *AttachConfigTransformer) attachProviders(g *Graph) error { +func (t *AttachProviderConfigTransformer) attachProviders(g *Graph) error { // Go through and find GraphNodeAttachProvider for _, v := range g.Vertices() { // Only care about GraphNodeAttachProvider implementations diff --git a/terraform/transform_diff.go b/terraform/transform_diff.go index f0455f5e3..8f91d5729 100644 --- a/terraform/transform_diff.go +++ b/terraform/transform_diff.go @@ -2,6 +2,7 @@ package terraform import ( "fmt" + "log" "github.com/hashicorp/terraform/config/module" ) @@ -30,12 +31,15 @@ func (t *DiffTransformer) Transform(g *Graph) error { } // Go through all the modules in the diff. + log.Printf("[TRACE] DiffTransformer: starting") var nodes []*NodeApplyableResource for _, m := range t.Diff.Modules { + log.Printf("[TRACE] DiffTransformer: Module: %s", m) // TODO: If this is a destroy diff then add a module destroy node // Go through all the resources in this module. for name, inst := range m.Resources { + log.Printf("[TRACE] DiffTransformer: Resource %q: %#v", name, inst) // TODO: Destroy diff // If this diff has no attribute changes, then we have