remove UnkeyedInstanceShim from some provider nodes

Remove the shims where they aren't necessary from the Init and Close
provider nodes. This also removed some provider path checks from the
builtin eval context, which cannot be resolved since the context may not
be created with a ModuleInstance path.
This commit is contained in:
James Bardin 2020-03-23 16:28:19 -04:00
parent b3fc0dab94
commit 2474b87ff4
2 changed files with 6 additions and 27 deletions

View File

@ -118,12 +118,6 @@ func (ctx *BuiltinEvalContext) Input() UIInput {
}
func (ctx *BuiltinEvalContext) InitProvider(addr addrs.AbsProviderConfig) (providers.Interface, error) {
//if !addr.Module.Equal(ctx.Path().Module()) {
// // This indicates incorrect use of InitProvider: it should be used
// // only from the module that the provider configuration belongs to.
// panic(fmt.Sprintf("%s initialized by wrong module %s", addr, ctx.Path()))
//}
// If we already initialized, it is an error
if p := ctx.Provider(addr); p != nil {
return nil, fmt.Errorf("%s is already initialized", addr)
@ -159,12 +153,6 @@ func (ctx *BuiltinEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) *Pro
}
func (ctx *BuiltinEvalContext) CloseProvider(addr addrs.AbsProviderConfig) error {
if !addr.Module.Equal(ctx.Path().Module()) {
// This indicates incorrect use of CloseProvider: it should be used
// only from the module that the provider configuration belongs to.
panic(fmt.Sprintf("%s closed by wrong module %s", addr, ctx.Path()))
}
ctx.ProviderLock.Lock()
defer ctx.ProviderLock.Unlock()
@ -227,13 +215,13 @@ func (ctx *BuiltinEvalContext) ProviderInput(pc addrs.AbsProviderConfig) map[str
func (ctx *BuiltinEvalContext) SetProviderInput(pc addrs.AbsProviderConfig, c map[string]cty.Value) {
absProvider := pc
if !absProvider.Module.Equal(ctx.Path().Module()) {
// This indicates incorrect use of InitProvider: it should be used
// only from the module that the provider configuration belongs to.
panic(fmt.Sprintf("%s initialized by wrong module %s", absProvider, ctx.Path()))
}
//if !absProvider.Module.Equal(ctx.Path().Module()) {
// // This indicates incorrect use of InitProvider: it should be used
// // only from the module that the provider configuration belongs to.
// panic(fmt.Sprintf("%s initialized by wrong module %s", absProvider, ctx.Path()))
//}
if !ctx.Path().IsRoot() {
if !pc.Module.IsRoot() {
// Only root module provider configurations can have input.
log.Printf("[WARN] BuiltinEvalContext: attempt to SetProviderInput for non-root module")
return

View File

@ -470,11 +470,6 @@ func (n *graphNodeCloseProvider) Name() string {
return n.Addr.String() + " (close)"
}
// GraphNodeModuleInstance impl.
func (n *graphNodeCloseProvider) Path() addrs.ModuleInstance {
return n.Addr.Module.UnkeyedInstanceShim()
}
// GraphNodeModulePath
func (n *graphNodeCloseProvider) ModulePath() addrs.Module {
return n.Addr.Module
@ -534,10 +529,6 @@ func (n *graphNodeProxyProvider) ProviderAddr() addrs.AbsProviderConfig {
return n.addr
}
func (n *graphNodeProxyProvider) Path() addrs.ModuleInstance {
return n.addr.Module.UnkeyedInstanceShim()
}
func (n *graphNodeProxyProvider) ModulePath() addrs.Module {
return n.addr.Module
}