terraform: remove graph annotations

This commit is contained in:
Mitchell Hashimoto 2017-01-26 20:13:42 -08:00
parent a561934f61
commit 348cfa0ed7
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 0 additions and 66 deletions

View File

@ -29,11 +29,6 @@ type Graph struct {
// RootModuleName
Path []string
// annotations are the annotations that are added to vertices. Annotations
// are arbitrary metadata taht is used for various logic. Annotations
// should have unique keys that are referenced via constants.
annotations map[dag.Vertex]map[string]interface{}
// dependableMap is a lookaside table for fast lookups for connecting
// dependencies by their GraphNodeDependable value to avoid O(n^3)-like
// situations and turn them into O(1) with respect to the number of new
@ -52,29 +47,6 @@ func (g *Graph) DirectedGraph() dag.Grapher {
return &g.AcyclicGraph
}
// Annotations returns the annotations that are configured for the
// given vertex. The map is guaranteed to be non-nil but may be empty.
//
// The returned map may be modified to modify the annotations of the
// vertex.
func (g *Graph) Annotations(v dag.Vertex) map[string]interface{} {
g.once.Do(g.init)
// If this vertex isn't in the graph, then just return an empty map
if !g.HasVertex(v) {
return map[string]interface{}{}
}
// Get the map, if it doesn't exist yet then initialize it
m, ok := g.annotations[v]
if !ok {
m = make(map[string]interface{})
g.annotations[v] = m
}
return m
}
// Add is the same as dag.Graph.Add.
func (g *Graph) Add(v dag.Vertex) dag.Vertex {
g.once.Do(g.init)
@ -89,14 +61,6 @@ func (g *Graph) Add(v dag.Vertex) dag.Vertex {
}
}
// If this initializes annotations, then do that
if av, ok := v.(GraphNodeAnnotationInit); ok {
as := g.Annotations(v)
for k, v := range av.AnnotationInit() {
as[k] = v
}
}
return v
}
@ -111,9 +75,6 @@ func (g *Graph) Remove(v dag.Vertex) dag.Vertex {
}
}
// Remove the annotations
delete(g.annotations, v)
// Call upwards to remove it from the actual graph
return g.Graph.Remove(v)
}
@ -133,12 +94,6 @@ func (g *Graph) Replace(o, n dag.Vertex) bool {
}
}
// Move the annotation if it exists
if m, ok := g.annotations[o]; ok {
g.annotations[n] = m
delete(g.annotations, o)
}
return g.Graph.Replace(o, n)
}
@ -195,13 +150,6 @@ func (g *Graph) ConnectTo(v dag.Vertex, targets []string) []string {
return missing
}
// Dependable finds the vertices in the graph that have the given dependable
// names and returns them.
func (g *Graph) Dependable(n string) dag.Vertex {
// TODO: do we need this?
return nil
}
// Walk walks the graph with the given walker for callbacks. The graph
// will be walked with full parallelism, so the walker should expect
// to be called in concurrently.
@ -210,10 +158,6 @@ func (g *Graph) Walk(walker GraphWalker) error {
}
func (g *Graph) init() {
if g.annotations == nil {
g.annotations = make(map[dag.Vertex]map[string]interface{})
}
if g.dependableMap == nil {
g.dependableMap = make(map[string]dag.Vertex)
}
@ -346,16 +290,6 @@ func (g *Graph) walk(walker GraphWalker) error {
return g.AcyclicGraph.Walk(walkFn)
}
// GraphNodeAnnotationInit is an interface that allows a node to
// initialize it's annotations.
//
// AnnotationInit will be called _once_ when the node is added to a
// graph for the first time and is expected to return it's initial
// annotations.
type GraphNodeAnnotationInit interface {
AnnotationInit() map[string]interface{}
}
// GraphNodeDependable is an interface which says that a node can be
// depended on (an edge can be placed between this node and another) according
// to the well-known name returned by DependableName.