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.
This commit is contained in:
James Bardin 2018-05-29 10:13:46 -04:00 committed by Martin Atkins
parent c8dfc944fe
commit fd4b427162
2 changed files with 3 additions and 3 deletions

View File

@ -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 {

View File

@ -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
}