terraform: copy the provider input configs for the shadow context

This commit is contained in:
Mitchell Hashimoto 2016-10-08 16:51:41 +08:00
parent fdeb4656c9
commit a014b098b0
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 13 additions and 3 deletions

View File

@ -31,6 +31,12 @@ func newShadowContext(c *Context) (*Context, *Context, Shadow) {
panic(err) panic(err)
} }
// Copy the provider inputs
providerInputRaw, err := copystructure.Copy(c.providerInputConfig)
if err != nil {
panic(err)
}
// The factories // The factories
componentsReal, componentsShadow := newShadowComponentFactory(c.components) 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 // a ton since we're doing far less compared to the real side
// and our operations are MUCH faster. // and our operations are MUCH faster.
parallelSem: NewSemaphore(4), 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 // Create the real context. This is effectively just a copy of

View File

@ -72,9 +72,11 @@ func (p *shadowResourceProviderReal) Close() error {
func (p *shadowResourceProviderReal) Input( func (p *shadowResourceProviderReal) Input(
input UIInput, c *ResourceConfig) (*ResourceConfig, error) { input UIInput, c *ResourceConfig) (*ResourceConfig, error) {
cCopy := c.DeepCopy()
result, err := p.ResourceProvider.Input(input, c) result, err := p.ResourceProvider.Input(input, c)
p.Shared.Input.SetValue(&shadowResourceProviderInput{ p.Shared.Input.SetValue(&shadowResourceProviderInput{
Config: c.DeepCopy(), Config: cCopy,
Result: result.DeepCopy(), Result: result.DeepCopy(),
ResultErr: err, ResultErr: err,
}) })
@ -94,9 +96,11 @@ func (p *shadowResourceProviderReal) Validate(c *ResourceConfig) ([]string, []er
} }
func (p *shadowResourceProviderReal) Configure(c *ResourceConfig) error { func (p *shadowResourceProviderReal) Configure(c *ResourceConfig) error {
cCopy := c.DeepCopy()
err := p.ResourceProvider.Configure(c) err := p.ResourceProvider.Configure(c)
p.Shared.Configure.SetValue(&shadowResourceProviderConfigure{ p.Shared.Configure.SetValue(&shadowResourceProviderConfigure{
Config: c.DeepCopy(), Config: cCopy,
Result: err, Result: err,
}) })