mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-26 00:16:25 -06:00
terraform: MissingProviderTransformer now injects missing modules
This commit is contained in:
parent
1d3f11f0ba
commit
6f607d0c59
@ -1,6 +1,5 @@
|
||||
package terraform
|
||||
|
||||
/*
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
@ -127,4 +126,3 @@ aws_instance.foo:
|
||||
provider = aws
|
||||
foo = bar
|
||||
`
|
||||
*/
|
||||
|
@ -223,8 +223,13 @@ func (t *MissingProviderTransformer) Transform(g *Graph) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Add this new vertex to our check list
|
||||
check = append(check, v)
|
||||
// We'll need the parent provider as well, so let's
|
||||
// add a dummy node to check to make sure that we add
|
||||
// that parent provider.
|
||||
check = append(check, &graphNodeProviderConsumerDummy{
|
||||
ProviderValue: p,
|
||||
PathValue: path[:len(path)-1],
|
||||
})
|
||||
}
|
||||
|
||||
m[key] = g.Add(v)
|
||||
@ -509,3 +514,20 @@ func (n *graphNodeProviderFlat) DependentOn() []string {
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// graphNodeProviderConsumerDummy is a struct that never enters the real
|
||||
// graph (though it could to no ill effect). It implements
|
||||
// GraphNodeProviderConsumer and GraphNodeSubpath as a way to force
|
||||
// certain transformations.
|
||||
type graphNodeProviderConsumerDummy struct {
|
||||
ProviderValue string
|
||||
PathValue []string
|
||||
}
|
||||
|
||||
func (n *graphNodeProviderConsumerDummy) Path() []string {
|
||||
return n.PathValue
|
||||
}
|
||||
|
||||
func (n *graphNodeProviderConsumerDummy) ProvidedBy() []string {
|
||||
return []string{n.ProviderValue}
|
||||
}
|
||||
|
@ -300,6 +300,7 @@ provider.foo (close)
|
||||
const testTransformMissingProviderModuleChildStr = `
|
||||
module.moo.foo_instance.qux (import id: bar)
|
||||
module.moo.provider.foo
|
||||
provider.foo
|
||||
`
|
||||
|
||||
const testTransformPruneProviderBasicStr = `
|
||||
|
Loading…
Reference in New Issue
Block a user