terraform: rename attach config to only attach provider config

This commit is contained in:
Mitchell Hashimoto 2016-09-16 16:30:29 -07:00
parent 0e666aa575
commit dfa02e4412
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
5 changed files with 27 additions and 9 deletions

15
config/testing.go Normal file
View File

@ -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
}

View File

@ -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

View File

@ -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{},
}

View File

@ -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

View File

@ -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