terraform: missing provider should be flattenable

This commit is contained in:
Mitchell Hashimoto 2015-05-01 15:23:37 -07:00
parent 86d07d3b5b
commit 416e7a2077
2 changed files with 30 additions and 10 deletions

View File

@ -220,16 +220,6 @@ type graphNodeModuleFlatWrap struct {
DependentOnPrefix string
}
// GraphNodeProvider impl.
func (n *graphNodeModuleFlatWrap) ProviderName() string {
pn, ok := n.Vertex.(GraphNodeProvider)
if !ok {
return ""
}
return fmt.Sprintf("%s.%s", n.NamePrefix, pn.ProviderName())
}
// GraphNodeProviderConsumer impl.
func (n *graphNodeModuleFlatWrap) ProvidedBy() []string {
pn, ok := n.Vertex.(GraphNodeProviderConsumer)

View File

@ -224,6 +224,14 @@ func (n *graphNodeMissingProvider) DotOrigin() bool {
return true
}
// GraphNodeFlattenable impl.
func (n *graphNodeMissingProvider) Flatten(p []string) (dag.Vertex, error) {
return &graphNodeMissingProviderFlat{
graphNodeMissingProvider: n,
PathValue: p,
}, nil
}
func providerVertexMap(g *Graph) map[string]dag.Vertex {
m := make(map[string]dag.Vertex)
for _, v := range g.Vertices() {
@ -234,3 +242,25 @@ func providerVertexMap(g *Graph) map[string]dag.Vertex {
return m
}
// Same as graphNodeMissingProvider, but for flattening
type graphNodeMissingProviderFlat struct {
*graphNodeMissingProvider
PathValue []string
}
func (n *graphNodeMissingProviderFlat) Name() string {
return fmt.Sprintf(
"%s.%s", modulePrefixStr(n.PathValue), n.graphNodeMissingProvider.Name())
}
func (n *graphNodeMissingProviderFlat) Path() []string {
return n.PathValue
}
func (n *graphNodeMissingProviderFlat) ProviderName() string {
return fmt.Sprintf(
"%s.%s", modulePrefixStr(n.PathValue),
n.graphNodeMissingProvider.ProviderName())
}