Merge pull request #30019 from hashicorp/alisdair/fix-provider-schema-for-deleted-resource-instance
core: Fix schema loading for deleted resources
This commit is contained in:
commit
d24403799e
|
@ -136,6 +136,9 @@ func (n *NodeAbstractResourceInstance) Provider() addrs.Provider {
|
||||||
if n.Config != nil {
|
if n.Config != nil {
|
||||||
return n.Config.Provider
|
return n.Config.Provider
|
||||||
}
|
}
|
||||||
|
if n.storedProviderConfig.Provider.Type != "" {
|
||||||
|
return n.storedProviderConfig.Provider
|
||||||
|
}
|
||||||
return addrs.ImpliedProviderForUnqualifiedType(n.Addr.Resource.ContainingResource().ImpliedProvider())
|
return addrs.ImpliedProviderForUnqualifiedType(n.Addr.Resource.ContainingResource().ImpliedProvider())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,10 @@ import (
|
||||||
|
|
||||||
func TestNodeAbstractResourceInstanceProvider(t *testing.T) {
|
func TestNodeAbstractResourceInstanceProvider(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
Addr addrs.AbsResourceInstance
|
Addr addrs.AbsResourceInstance
|
||||||
Config *configs.Resource
|
Config *configs.Resource
|
||||||
Want addrs.Provider
|
StoredProviderConfig addrs.AbsProviderConfig
|
||||||
|
Want addrs.Provider
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Addr: addrs.Resource{
|
Addr: addrs.Resource{
|
||||||
|
@ -87,6 +88,28 @@ func TestNodeAbstractResourceInstanceProvider(t *testing.T) {
|
||||||
Type: "happycloud",
|
Type: "happycloud",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Addr: addrs.Resource{
|
||||||
|
Mode: addrs.DataResourceMode,
|
||||||
|
Type: "null_resource",
|
||||||
|
Name: "baz",
|
||||||
|
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
|
||||||
|
Config: nil,
|
||||||
|
StoredProviderConfig: addrs.AbsProviderConfig{
|
||||||
|
Module: addrs.RootModule,
|
||||||
|
Provider: addrs.Provider{
|
||||||
|
Hostname: addrs.DefaultProviderRegistryHost,
|
||||||
|
Namespace: "awesomecorp",
|
||||||
|
Type: "null",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// The stored provider config overrides the default behavior.
|
||||||
|
Want: addrs.Provider{
|
||||||
|
Hostname: addrs.DefaultProviderRegistryHost,
|
||||||
|
Namespace: "awesomecorp",
|
||||||
|
Type: "null",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
@ -104,6 +127,7 @@ func TestNodeAbstractResourceInstanceProvider(t *testing.T) {
|
||||||
NodeAbstractResource: NodeAbstractResource{
|
NodeAbstractResource: NodeAbstractResource{
|
||||||
Config: test.Config,
|
Config: test.Config,
|
||||||
},
|
},
|
||||||
|
storedProviderConfig: test.StoredProviderConfig,
|
||||||
}
|
}
|
||||||
got := node.Provider()
|
got := node.Provider()
|
||||||
if got != test.Want {
|
if got != test.Want {
|
||||||
|
|
Loading…
Reference in New Issue