Merge pull request #2755 from hashicorp/b-provider-couldnt-be-found-destroy-node
core: fix "provider ... couldn't be found" bug
This commit is contained in:
commit
b9f5d85b22
|
@ -894,6 +894,43 @@ func TestContext2Apply_moduleProviderAliasTargets(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestContext2Apply_moduleProviderCloseNested(t *testing.T) {
|
||||
m := testModule(t, "apply-module-provider-close-nested")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
Path: []string{"root", "child", "subchild"},
|
||||
Resources: map[string]*ResourceState{
|
||||
"aws_instance.foo": &ResourceState{
|
||||
Type: "aws_instance",
|
||||
Primary: &InstanceState{
|
||||
ID: "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Destroy: true,
|
||||
})
|
||||
|
||||
if _, err := ctx.Plan(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if _, err := ctx.Apply(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Apply_moduleVarResourceCount(t *testing.T) {
|
||||
m := testModule(t, "apply-module-var-resource-count")
|
||||
p := testProvider("aws")
|
||||
|
|
|
@ -335,6 +335,13 @@ func (n *graphNodeResourceDestroyFlat) CreateNode() dag.Vertex {
|
|||
return n.FlatCreateNode
|
||||
}
|
||||
|
||||
func (n *graphNodeResourceDestroyFlat) ProvidedBy() []string {
|
||||
prefix := modulePrefixStr(n.PathValue)
|
||||
return modulePrefixList(
|
||||
n.GraphNodeConfigResource.ProvidedBy(),
|
||||
prefix)
|
||||
}
|
||||
|
||||
// graphNodeResourceDestroy represents the logical destruction of a
|
||||
// resource. This node doesn't mean it will be destroyed for sure, but
|
||||
// instead that if a destroy were to happen, it must happen at this point.
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module "subchild" {
|
||||
source = "./subchild"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
resource "aws_instance" "foo" {}
|
|
@ -0,0 +1,3 @@
|
|||
module "child" {
|
||||
source = "./child"
|
||||
}
|
|
@ -130,7 +130,7 @@ func (t *CloseProviderTransformer) Transform(g *Graph) error {
|
|||
provider, ok := pm[p]
|
||||
if !ok {
|
||||
err = multierror.Append(err, fmt.Errorf(
|
||||
"%s: provider %s couldn't be found",
|
||||
"%s: provider %s couldn't be found for closing",
|
||||
dag.VertexName(v), p))
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue