From a014b098b00dbf29922ab2d1b56988b665681710 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 8 Oct 2016 16:51:41 +0800 Subject: [PATCH] terraform: copy the provider input configs for the shadow context --- terraform/shadow_context.go | 8 +++++++- terraform/shadow_resource_provider.go | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/terraform/shadow_context.go b/terraform/shadow_context.go index 5eb31cf3d..eba8640fb 100644 --- a/terraform/shadow_context.go +++ b/terraform/shadow_context.go @@ -31,6 +31,12 @@ func newShadowContext(c *Context) (*Context, *Context, Shadow) { panic(err) } + // Copy the provider inputs + providerInputRaw, err := copystructure.Copy(c.providerInputConfig) + if err != nil { + panic(err) + } + // The factories componentsReal, componentsShadow := newShadowComponentFactory(c.components) @@ -50,7 +56,7 @@ func newShadowContext(c *Context) (*Context, *Context, Shadow) { // a ton since we're doing far less compared to the real side // and our operations are MUCH faster. parallelSem: NewSemaphore(4), - providerInputConfig: make(map[string]map[string]interface{}), + providerInputConfig: providerInputRaw.(map[string]map[string]interface{}), } // Create the real context. This is effectively just a copy of diff --git a/terraform/shadow_resource_provider.go b/terraform/shadow_resource_provider.go index b6713ce8f..0cf1813a5 100644 --- a/terraform/shadow_resource_provider.go +++ b/terraform/shadow_resource_provider.go @@ -72,9 +72,11 @@ func (p *shadowResourceProviderReal) Close() error { func (p *shadowResourceProviderReal) Input( input UIInput, c *ResourceConfig) (*ResourceConfig, error) { + cCopy := c.DeepCopy() + result, err := p.ResourceProvider.Input(input, c) p.Shared.Input.SetValue(&shadowResourceProviderInput{ - Config: c.DeepCopy(), + Config: cCopy, Result: result.DeepCopy(), ResultErr: err, }) @@ -94,9 +96,11 @@ func (p *shadowResourceProviderReal) Validate(c *ResourceConfig) ([]string, []er } func (p *shadowResourceProviderReal) Configure(c *ResourceConfig) error { + cCopy := c.DeepCopy() + err := p.ResourceProvider.Configure(c) p.Shared.Configure.SetValue(&shadowResourceProviderConfigure{ - Config: c.DeepCopy(), + Config: cCopy, Result: err, })