terraform: MissingProviderTransformer now injects missing modules
This commit is contained in:
parent
1d3f11f0ba
commit
6f607d0c59
|
@ -1,6 +1,5 @@
|
||||||
package terraform
|
package terraform
|
||||||
|
|
||||||
/*
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -127,4 +126,3 @@ aws_instance.foo:
|
||||||
provider = aws
|
provider = aws
|
||||||
foo = bar
|
foo = bar
|
||||||
`
|
`
|
||||||
*/
|
|
||||||
|
|
|
@ -223,8 +223,13 @@ func (t *MissingProviderTransformer) Transform(g *Graph) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add this new vertex to our check list
|
// We'll need the parent provider as well, so let's
|
||||||
check = append(check, v)
|
// 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)
|
m[key] = g.Add(v)
|
||||||
|
@ -509,3 +514,20 @@ func (n *graphNodeProviderFlat) DependentOn() []string {
|
||||||
|
|
||||||
return result
|
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 = `
|
const testTransformMissingProviderModuleChildStr = `
|
||||||
module.moo.foo_instance.qux (import id: bar)
|
module.moo.foo_instance.qux (import id: bar)
|
||||||
module.moo.provider.foo
|
module.moo.provider.foo
|
||||||
|
provider.foo
|
||||||
`
|
`
|
||||||
|
|
||||||
const testTransformPruneProviderBasicStr = `
|
const testTransformPruneProviderBasicStr = `
|
||||||
|
|
Loading…
Reference in New Issue