terraform: rename attach config to only attach provider config
This commit is contained in:
parent
0e666aa575
commit
dfa02e4412
|
@ -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
|
||||||
|
}
|
|
@ -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")
|
m := testModule(t, "apply-count-dec-one")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
p.ApplyFn = testApplyFn
|
p.ApplyFn = testApplyFn
|
||||||
|
|
|
@ -58,6 +58,7 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
|
||||||
&MissingProviderTransformer{Providers: b.Providers, Factory: providerFactory},
|
&MissingProviderTransformer{Providers: b.Providers, Factory: providerFactory},
|
||||||
&ProviderTransformer{},
|
&ProviderTransformer{},
|
||||||
&ParentProviderTransformer{},
|
&ParentProviderTransformer{},
|
||||||
|
&AttachProviderConfigTransformer{Module: b.Module},
|
||||||
|
|
||||||
// Provisioner-related transformations
|
// Provisioner-related transformations
|
||||||
&MissingProvisionerTransformer{Provisioners: b.Provisioners},
|
&MissingProvisionerTransformer{Provisioners: b.Provisioners},
|
||||||
|
@ -75,9 +76,6 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
|
||||||
// Connect references so ordering is correct
|
// Connect references so ordering is correct
|
||||||
&ReferenceTransformer{},
|
&ReferenceTransformer{},
|
||||||
|
|
||||||
// Attach the configurations
|
|
||||||
&AttachConfigTransformer{Module: b.Module},
|
|
||||||
|
|
||||||
// Single root
|
// Single root
|
||||||
&RootTransformer{},
|
&RootTransformer{},
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,16 +20,17 @@ type GraphNodeAttachProvider interface {
|
||||||
AttachProvider(*config.ProviderConfig)
|
AttachProvider(*config.ProviderConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AttachConfigTransformer goes through the graph and attaches configuration
|
// AttachProviderConfigTransformer goes through the graph and attaches
|
||||||
// structures to nodes that implement the interfaces above.
|
// provider configuration structures to nodes that implement the interfaces
|
||||||
|
// above.
|
||||||
//
|
//
|
||||||
// The attached configuration structures are directly from the configuration.
|
// The attached configuration structures are directly from the configuration.
|
||||||
// If they're going to be modified, a copy should be made.
|
// 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
|
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 {
|
if err := t.attachProviders(g); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,7 @@ func (t *AttachConfigTransformer) Transform(g *Graph) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *AttachConfigTransformer) attachProviders(g *Graph) error {
|
func (t *AttachProviderConfigTransformer) attachProviders(g *Graph) error {
|
||||||
// Go through and find GraphNodeAttachProvider
|
// Go through and find GraphNodeAttachProvider
|
||||||
for _, v := range g.Vertices() {
|
for _, v := range g.Vertices() {
|
||||||
// Only care about GraphNodeAttachProvider implementations
|
// Only care about GraphNodeAttachProvider implementations
|
|
@ -2,6 +2,7 @@ package terraform
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/config/module"
|
"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.
|
// Go through all the modules in the diff.
|
||||||
|
log.Printf("[TRACE] DiffTransformer: starting")
|
||||||
var nodes []*NodeApplyableResource
|
var nodes []*NodeApplyableResource
|
||||||
for _, m := range t.Diff.Modules {
|
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
|
// TODO: If this is a destroy diff then add a module destroy node
|
||||||
|
|
||||||
// Go through all the resources in this module.
|
// Go through all the resources in this module.
|
||||||
for name, inst := range m.Resources {
|
for name, inst := range m.Resources {
|
||||||
|
log.Printf("[TRACE] DiffTransformer: Resource %q: %#v", name, inst)
|
||||||
// TODO: Destroy diff
|
// TODO: Destroy diff
|
||||||
|
|
||||||
// If this diff has no attribute changes, then we have
|
// If this diff has no attribute changes, then we have
|
||||||
|
|
Loading…
Reference in New Issue