mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
terraform: remove meta nodes
This commit is contained in:
parent
4fe0c4ada4
commit
fecb68f117
@ -1104,9 +1104,6 @@ func (c *walkContext) genericWalkFn(cb genericWalkFunc) depgraph.WalkFunc {
|
|||||||
return wc.Walk()
|
return wc.Walk()
|
||||||
case *GraphNodeResource:
|
case *GraphNodeResource:
|
||||||
// Continue, we care about this the most
|
// Continue, we care about this the most
|
||||||
case *GraphNodeResourceMeta:
|
|
||||||
// Skip it
|
|
||||||
return nil
|
|
||||||
case *GraphNodeResourceProvider:
|
case *GraphNodeResourceProvider:
|
||||||
sharedProvider := m.Provider
|
sharedProvider := m.Provider
|
||||||
|
|
||||||
|
@ -97,16 +97,6 @@ type GraphNodeResource struct {
|
|||||||
ExpandMode ResourceExpandMode
|
ExpandMode ResourceExpandMode
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphNodeResourceMeta is a node type in the graph that represents the
|
|
||||||
// metadata for a resource. There will be one meta node for every resource
|
|
||||||
// in the configuration.
|
|
||||||
type GraphNodeResourceMeta struct {
|
|
||||||
ID string
|
|
||||||
Name string
|
|
||||||
Type string
|
|
||||||
Count int
|
|
||||||
}
|
|
||||||
|
|
||||||
// GraphNodeResourceProvider is a node type in the graph that represents
|
// GraphNodeResourceProvider is a node type in the graph that represents
|
||||||
// the configuration for a resource provider.
|
// the configuration for a resource provider.
|
||||||
type GraphNodeResourceProvider struct {
|
type GraphNodeResourceProvider struct {
|
||||||
@ -335,13 +325,6 @@ func graphEncodeDependencies(g *depgraph.Graph) {
|
|||||||
}
|
}
|
||||||
inject = append(inject, target.Resource.Id)
|
inject = append(inject, target.Resource.Id)
|
||||||
|
|
||||||
case *GraphNodeResourceMeta:
|
|
||||||
// Inject each sub-resource as a depedency
|
|
||||||
for i := 0; i < target.Count; i++ {
|
|
||||||
id := fmt.Sprintf("%s.%d", target.ID, i)
|
|
||||||
inject = append(inject, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
case *GraphNodeResourceProvider:
|
case *GraphNodeResourceProvider:
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|
||||||
@ -702,33 +685,6 @@ func graphAddDiff(g *depgraph.Graph, d *ModuleDiff) error {
|
|||||||
num--
|
num--
|
||||||
i--
|
i--
|
||||||
|
|
||||||
case *GraphNodeResourceMeta:
|
|
||||||
// Check if any of the resources part of the meta node
|
|
||||||
// are being destroyed, because we must be destroyed first.
|
|
||||||
for i := 0; i < target.Count; i++ {
|
|
||||||
id := fmt.Sprintf("%s.%d", target.ID, i)
|
|
||||||
for _, n2 := range nlist {
|
|
||||||
rn2 := n2.Meta.(*GraphNodeResource)
|
|
||||||
if id == rn2.Resource.Id {
|
|
||||||
newDep := &depgraph.Dependency{
|
|
||||||
Name: n.Name,
|
|
||||||
Source: n2,
|
|
||||||
Target: n,
|
|
||||||
}
|
|
||||||
injected[newDep] = struct{}{}
|
|
||||||
n2.Deps = append(n2.Deps, newDep)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop the dependency, since there is
|
|
||||||
// nothing that needs to be done for a meta
|
|
||||||
// resource on destroy.
|
|
||||||
deps[i], deps[num-1] = deps[num-1], nil
|
|
||||||
num--
|
|
||||||
i--
|
|
||||||
|
|
||||||
case *GraphNodeModule:
|
case *GraphNodeModule:
|
||||||
// We invert any module dependencies so we're destroyed
|
// We invert any module dependencies so we're destroyed
|
||||||
// first, before any modules are applied.
|
// first, before any modules are applied.
|
||||||
@ -1049,8 +1005,6 @@ func graphAddRoot(g *depgraph.Graph) {
|
|||||||
if m.Index != -1 {
|
if m.Index != -1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case *GraphNodeResourceMeta:
|
|
||||||
// Always in the graph
|
|
||||||
case *GraphNodeResourceProvider:
|
case *GraphNodeResourceProvider:
|
||||||
// ResourceProviders don't need to be in the root deps because
|
// ResourceProviders don't need to be in the root deps because
|
||||||
// they're always pointed to by some resource.
|
// they're always pointed to by some resource.
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/depgraph"
|
"github.com/hashicorp/terraform/depgraph"
|
||||||
"github.com/hashicorp/terraform/digraph"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GraphDotOpts are options for turning a graph into dot format.
|
// GraphDotOpts are options for turning a graph into dot format.
|
||||||
@ -221,6 +220,7 @@ func graphDotAddResources(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle the meta resources
|
// Handle the meta resources
|
||||||
|
/*
|
||||||
edgeBuf.Reset()
|
edgeBuf.Reset()
|
||||||
for _, n := range g.Nouns {
|
for _, n := range g.Nouns {
|
||||||
_, ok := n.Meta.(*GraphNodeResourceMeta)
|
_, ok := n.Meta.(*GraphNodeResourceMeta)
|
||||||
@ -264,6 +264,7 @@ func graphDotAddResources(
|
|||||||
buf.WriteString(edgeBuf.String())
|
buf.WriteString(edgeBuf.String())
|
||||||
buf.WriteString("\n")
|
buf.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func graphDotAddResourceProviders(
|
func graphDotAddResourceProviders(
|
||||||
|
Loading…
Reference in New Issue
Block a user