mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
core: fix "provider ... couldn't be found" bug
The `CloseProviderTransformer` relies on the `ProvidedBy()` interface to look up the proper dependency for the the graph nodes it adds. This interface needs to yield the name of a provider, _AND_ for flattened nodes it needs to yield the full path to a provider. Destroy nodes did not implement this second part, which resulted in "provider X couldn't be found" when both of these were true: * A module included a resource that dependend on a provider * The root did _NOT_ include a provider config Implementing a proper ProvidedBy() on the flattened version of destroy nodes solves the issue. fixes #2581
This commit is contained in:
parent
7f908e0ac6
commit
f97c635ef6
@ -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.
|
||||
|
@ -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
Block a user