WIP start only referring to provier by adddress
Don't try to build a full adress based on the context path for providers in EvalContextBuiltin. Only use the name explicitly provided.
This commit is contained in:
parent
f0727501c1
commit
1d54d4b10d
|
@ -92,18 +92,13 @@ func (ctx *BuiltinEvalContext) InitProvider(n string) (ResourceProvider, error)
|
||||||
ctx.ProviderLock.Lock()
|
ctx.ProviderLock.Lock()
|
||||||
defer ctx.ProviderLock.Unlock()
|
defer ctx.ProviderLock.Unlock()
|
||||||
|
|
||||||
providerPath := make([]string, len(ctx.Path())+1)
|
|
||||||
copy(providerPath, ctx.Path())
|
|
||||||
providerPath[len(providerPath)-1] = n
|
|
||||||
key := PathCacheKey(providerPath)
|
|
||||||
|
|
||||||
typeName := strings.SplitN(n, ".", 2)[0]
|
typeName := strings.SplitN(n, ".", 2)[0]
|
||||||
p, err := ctx.Components.ResourceProvider(typeName, key)
|
p, err := ctx.Components.ResourceProvider(typeName, n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ProviderCache[key] = p
|
ctx.ProviderCache[n] = p
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,11 +108,7 @@ func (ctx *BuiltinEvalContext) Provider(n string) ResourceProvider {
|
||||||
ctx.ProviderLock.Lock()
|
ctx.ProviderLock.Lock()
|
||||||
defer ctx.ProviderLock.Unlock()
|
defer ctx.ProviderLock.Unlock()
|
||||||
|
|
||||||
providerPath := make([]string, len(ctx.Path())+1)
|
return ctx.ProviderCache[n]
|
||||||
copy(providerPath, ctx.Path())
|
|
||||||
providerPath[len(providerPath)-1] = n
|
|
||||||
|
|
||||||
return ctx.ProviderCache[PathCacheKey(providerPath)]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *BuiltinEvalContext) CloseProvider(n string) error {
|
func (ctx *BuiltinEvalContext) CloseProvider(n string) error {
|
||||||
|
@ -126,15 +117,11 @@ func (ctx *BuiltinEvalContext) CloseProvider(n string) error {
|
||||||
ctx.ProviderLock.Lock()
|
ctx.ProviderLock.Lock()
|
||||||
defer ctx.ProviderLock.Unlock()
|
defer ctx.ProviderLock.Unlock()
|
||||||
|
|
||||||
providerPath := make([]string, len(ctx.Path())+1)
|
|
||||||
copy(providerPath, ctx.Path())
|
|
||||||
providerPath[len(providerPath)-1] = n
|
|
||||||
|
|
||||||
var provider interface{}
|
var provider interface{}
|
||||||
provider = ctx.ProviderCache[PathCacheKey(providerPath)]
|
provider = ctx.ProviderCache[n]
|
||||||
if provider != nil {
|
if provider != nil {
|
||||||
if p, ok := provider.(ResourceProviderCloser); ok {
|
if p, ok := provider.(ResourceProviderCloser); ok {
|
||||||
delete(ctx.ProviderCache, PathCacheKey(providerPath))
|
delete(ctx.ProviderCache, n)
|
||||||
return p.Close()
|
return p.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue