From fd4b427162feba8efacd19d0006c06ce93f3068e Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 29 May 2018 10:13:46 -0400 Subject: [PATCH] index provider schemas by type A provider's schema is the same regardless of its address in the config. Key them by type so that an evaluation referencing a provider from an address not included in the graph can still find the schema. --- terraform/eval_context_builtin.go | 4 ++-- terraform/evaluate.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/terraform/eval_context_builtin.go b/terraform/eval_context_builtin.go index 6a28a0fc0..ff114682d 100644 --- a/terraform/eval_context_builtin.go +++ b/terraform/eval_context_builtin.go @@ -141,7 +141,7 @@ func (ctx *BuiltinEvalContext) InitProvider(typeName string, addr addrs.Provider if ctx.ProviderSchemas == nil { ctx.ProviderSchemas = make(map[string]*ProviderSchema) } - ctx.ProviderSchemas[key] = schema + ctx.ProviderSchemas[typeName] = schema return p, nil } @@ -161,7 +161,7 @@ func (ctx *BuiltinEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) *Pro ctx.ProviderLock.Lock() defer ctx.ProviderLock.Unlock() - return ctx.ProviderSchemas[addr.String()] + return ctx.ProviderSchemas[addr.ProviderConfig.Type] } func (ctx *BuiltinEvalContext) CloseProvider(addr addrs.ProviderConfig) error { diff --git a/terraform/evaluate.go b/terraform/evaluate.go index ffc5b70c2..3fe5f5c4d 100644 --- a/terraform/evaluate.go +++ b/terraform/evaluate.go @@ -690,7 +690,7 @@ func (d *evaluationStateData) getResourceSchema(addr addrs.Resource, providerAdd defer d.Evaluator.ProvidersLock.Unlock() log.Printf("[TRACE] Need provider schema for %s", providerAddr) - providerSchema := d.Evaluator.ProviderSchemas[providerAddr.String()] + providerSchema := d.Evaluator.ProviderSchemas[providerAddr.ProviderConfig.Type] if providerSchema == nil { return nil }