From 4089d33dea3a20920201611c0c4efe93c4e6a977 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 11 Feb 2015 18:05:04 -0800 Subject: [PATCH] terraform: provider merging should be parent OVER child --- terraform/context_test.go | 10 ++++++---- terraform/eval_provider.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/terraform/context_test.go b/terraform/context_test.go index 9245eb42e..3abf65bb2 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -291,14 +291,13 @@ func TestContext2Plan_moduleProviderInherit(t *testing.T) { } } -/* -func TestContextPlan_moduleProviderDefaults(t *testing.T) { +func TestContext2Plan_moduleProviderDefaults(t *testing.T) { var l sync.Mutex var calls []string toCount := 0 m := testModule(t, "plan-module-provider-defaults") - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": func() (ResourceProvider, error) { @@ -335,7 +334,9 @@ func TestContextPlan_moduleProviderDefaults(t *testing.T) { } if toCount != 1 { - t.Fatal("provider in child didn't set proper config") + t.Fatalf( + "provider in child didn't set proper config\n\n"+ + "toCount: %d", toCount) } actual := calls @@ -346,6 +347,7 @@ func TestContextPlan_moduleProviderDefaults(t *testing.T) { } } +/* func TestContextPlan_moduleProviderDefaultsVar(t *testing.T) { var l sync.Mutex var calls []string diff --git a/terraform/eval_provider.go b/terraform/eval_provider.go index bc5dc0092..35d6e87c5 100644 --- a/terraform/eval_provider.go +++ b/terraform/eval_provider.go @@ -21,7 +21,7 @@ func (n *EvalConfigProvider) Eval( // Get the parent configuration if there is one if parent := ctx.ParentProviderConfig(n.Provider); parent != nil { - merged := parent.raw.Merge(config.raw) + merged := config.raw.Merge(parent.raw) config = NewResourceConfig(merged) }