diff options
author | appilon <apilon@hashicorp.com> | 2019-02-27 16:43:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-27 16:43:31 -0500 |
commit | 844b5a68d8af4791755b8f0ad293cc99f5959183 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/hashicorp/terraform/dag | |
parent | 303b299eeb6b06e939e35905e4b34cb410dd9dc3 (diff) | |
parent | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (diff) | |
download | terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.gz terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.zst terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.zip |
Merge pull request #27 from terraform-providers/go-modules-2019-02-22
[MODULES] Switch to Go Modules
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/dag')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/dag/dag.go | 21 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/terraform/dag/marshal.go | 12 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/terraform/dag/walk.go | 16 |
3 files changed, 37 insertions, 12 deletions
diff --git a/vendor/github.com/hashicorp/terraform/dag/dag.go b/vendor/github.com/hashicorp/terraform/dag/dag.go index f8776bc..b7eb10c 100644 --- a/vendor/github.com/hashicorp/terraform/dag/dag.go +++ b/vendor/github.com/hashicorp/terraform/dag/dag.go | |||
@@ -106,7 +106,7 @@ func (g *AcyclicGraph) TransitiveReduction() { | |||
106 | uTargets := g.DownEdges(u) | 106 | uTargets := g.DownEdges(u) |
107 | vs := AsVertexList(g.DownEdges(u)) | 107 | vs := AsVertexList(g.DownEdges(u)) |
108 | 108 | ||
109 | g.DepthFirstWalk(vs, func(v Vertex, d int) error { | 109 | g.depthFirstWalk(vs, false, func(v Vertex, d int) error { |
110 | shared := uTargets.Intersection(g.DownEdges(v)) | 110 | shared := uTargets.Intersection(g.DownEdges(v)) |
111 | for _, vPrime := range AsVertexList(shared) { | 111 | for _, vPrime := range AsVertexList(shared) { |
112 | g.RemoveEdge(BasicEdge(u, vPrime)) | 112 | g.RemoveEdge(BasicEdge(u, vPrime)) |
@@ -187,9 +187,18 @@ type vertexAtDepth struct { | |||
187 | } | 187 | } |
188 | 188 | ||
189 | // depthFirstWalk does a depth-first walk of the graph starting from | 189 | // depthFirstWalk does a depth-first walk of the graph starting from |
190 | // the vertices in start. This is not exported now but it would make sense | 190 | // the vertices in start. |
191 | // to export this publicly at some point. | ||
192 | func (g *AcyclicGraph) DepthFirstWalk(start []Vertex, f DepthWalkFunc) error { | 191 | func (g *AcyclicGraph) DepthFirstWalk(start []Vertex, f DepthWalkFunc) error { |
192 | return g.depthFirstWalk(start, true, f) | ||
193 | } | ||
194 | |||
195 | // This internal method provides the option of not sorting the vertices during | ||
196 | // the walk, which we use for the Transitive reduction. | ||
197 | // Some configurations can lead to fully-connected subgraphs, which makes our | ||
198 | // transitive reduction algorithm O(n^3). This is still passable for the size | ||
199 | // of our graphs, but the additional n^2 sort operations would make this | ||
200 | // uncomputable in a reasonable amount of time. | ||
201 | func (g *AcyclicGraph) depthFirstWalk(start []Vertex, sorted bool, f DepthWalkFunc) error { | ||
193 | defer g.debug.BeginOperation(typeDepthFirstWalk, "").End("") | 202 | defer g.debug.BeginOperation(typeDepthFirstWalk, "").End("") |
194 | 203 | ||
195 | seen := make(map[Vertex]struct{}) | 204 | seen := make(map[Vertex]struct{}) |
@@ -219,7 +228,11 @@ func (g *AcyclicGraph) DepthFirstWalk(start []Vertex, f DepthWalkFunc) error { | |||
219 | 228 | ||
220 | // Visit targets of this in a consistent order. | 229 | // Visit targets of this in a consistent order. |
221 | targets := AsVertexList(g.DownEdges(current.Vertex)) | 230 | targets := AsVertexList(g.DownEdges(current.Vertex)) |
222 | sort.Sort(byVertexName(targets)) | 231 | |
232 | if sorted { | ||
233 | sort.Sort(byVertexName(targets)) | ||
234 | } | ||
235 | |||
223 | for _, t := range targets { | 236 | for _, t := range targets { |
224 | frontier = append(frontier, &vertexAtDepth{ | 237 | frontier = append(frontier, &vertexAtDepth{ |
225 | Vertex: t, | 238 | Vertex: t, |
diff --git a/vendor/github.com/hashicorp/terraform/dag/marshal.go b/vendor/github.com/hashicorp/terraform/dag/marshal.go index 16d5dd6..c567d27 100644 --- a/vendor/github.com/hashicorp/terraform/dag/marshal.go +++ b/vendor/github.com/hashicorp/terraform/dag/marshal.go | |||
@@ -273,6 +273,9 @@ func (e *encoder) Encode(i interface{}) { | |||
273 | } | 273 | } |
274 | 274 | ||
275 | func (e *encoder) Add(v Vertex) { | 275 | func (e *encoder) Add(v Vertex) { |
276 | if e == nil { | ||
277 | return | ||
278 | } | ||
276 | e.Encode(marshalTransform{ | 279 | e.Encode(marshalTransform{ |
277 | Type: typeTransform, | 280 | Type: typeTransform, |
278 | AddVertex: newMarshalVertex(v), | 281 | AddVertex: newMarshalVertex(v), |
@@ -281,6 +284,9 @@ func (e *encoder) Add(v Vertex) { | |||
281 | 284 | ||
282 | // Remove records the removal of Vertex v. | 285 | // Remove records the removal of Vertex v. |
283 | func (e *encoder) Remove(v Vertex) { | 286 | func (e *encoder) Remove(v Vertex) { |
287 | if e == nil { | ||
288 | return | ||
289 | } | ||
284 | e.Encode(marshalTransform{ | 290 | e.Encode(marshalTransform{ |
285 | Type: typeTransform, | 291 | Type: typeTransform, |
286 | RemoveVertex: newMarshalVertex(v), | 292 | RemoveVertex: newMarshalVertex(v), |
@@ -288,6 +294,9 @@ func (e *encoder) Remove(v Vertex) { | |||
288 | } | 294 | } |
289 | 295 | ||
290 | func (e *encoder) Connect(edge Edge) { | 296 | func (e *encoder) Connect(edge Edge) { |
297 | if e == nil { | ||
298 | return | ||
299 | } | ||
291 | e.Encode(marshalTransform{ | 300 | e.Encode(marshalTransform{ |
292 | Type: typeTransform, | 301 | Type: typeTransform, |
293 | AddEdge: newMarshalEdge(edge), | 302 | AddEdge: newMarshalEdge(edge), |
@@ -295,6 +304,9 @@ func (e *encoder) Connect(edge Edge) { | |||
295 | } | 304 | } |
296 | 305 | ||
297 | func (e *encoder) RemoveEdge(edge Edge) { | 306 | func (e *encoder) RemoveEdge(edge Edge) { |
307 | if e == nil { | ||
308 | return | ||
309 | } | ||
298 | e.Encode(marshalTransform{ | 310 | e.Encode(marshalTransform{ |
299 | Type: typeTransform, | 311 | Type: typeTransform, |
300 | RemoveEdge: newMarshalEdge(edge), | 312 | RemoveEdge: newMarshalEdge(edge), |
diff --git a/vendor/github.com/hashicorp/terraform/dag/walk.go b/vendor/github.com/hashicorp/terraform/dag/walk.go index 23c87ad..f03b100 100644 --- a/vendor/github.com/hashicorp/terraform/dag/walk.go +++ b/vendor/github.com/hashicorp/terraform/dag/walk.go | |||
@@ -166,7 +166,7 @@ func (w *Walker) Update(g *AcyclicGraph) { | |||
166 | w.wait.Add(1) | 166 | w.wait.Add(1) |
167 | 167 | ||
168 | // Add to our own set so we know about it already | 168 | // Add to our own set so we know about it already |
169 | log.Printf("[DEBUG] dag/walk: added new vertex: %q", VertexName(v)) | 169 | log.Printf("[TRACE] dag/walk: added new vertex: %q", VertexName(v)) |
170 | w.vertices.Add(raw) | 170 | w.vertices.Add(raw) |
171 | 171 | ||
172 | // Initialize the vertex info | 172 | // Initialize the vertex info |
@@ -198,7 +198,7 @@ func (w *Walker) Update(g *AcyclicGraph) { | |||
198 | // Delete it out of the map | 198 | // Delete it out of the map |
199 | delete(w.vertexMap, v) | 199 | delete(w.vertexMap, v) |
200 | 200 | ||
201 | log.Printf("[DEBUG] dag/walk: removed vertex: %q", VertexName(v)) | 201 | log.Printf("[TRACE] dag/walk: removed vertex: %q", VertexName(v)) |
202 | w.vertices.Delete(raw) | 202 | w.vertices.Delete(raw) |
203 | } | 203 | } |
204 | 204 | ||
@@ -229,7 +229,7 @@ func (w *Walker) Update(g *AcyclicGraph) { | |||
229 | changedDeps.Add(waiter) | 229 | changedDeps.Add(waiter) |
230 | 230 | ||
231 | log.Printf( | 231 | log.Printf( |
232 | "[DEBUG] dag/walk: added edge: %q waiting on %q", | 232 | "[TRACE] dag/walk: added edge: %q waiting on %q", |
233 | VertexName(waiter), VertexName(dep)) | 233 | VertexName(waiter), VertexName(dep)) |
234 | w.edges.Add(raw) | 234 | w.edges.Add(raw) |
235 | } | 235 | } |
@@ -253,7 +253,7 @@ func (w *Walker) Update(g *AcyclicGraph) { | |||
253 | changedDeps.Add(waiter) | 253 | changedDeps.Add(waiter) |
254 | 254 | ||
255 | log.Printf( | 255 | log.Printf( |
256 | "[DEBUG] dag/walk: removed edge: %q waiting on %q", | 256 | "[TRACE] dag/walk: removed edge: %q waiting on %q", |
257 | VertexName(waiter), VertexName(dep)) | 257 | VertexName(waiter), VertexName(dep)) |
258 | w.edges.Delete(raw) | 258 | w.edges.Delete(raw) |
259 | } | 259 | } |
@@ -296,7 +296,7 @@ func (w *Walker) Update(g *AcyclicGraph) { | |||
296 | info.depsCancelCh = cancelCh | 296 | info.depsCancelCh = cancelCh |
297 | 297 | ||
298 | log.Printf( | 298 | log.Printf( |
299 | "[DEBUG] dag/walk: dependencies changed for %q, sending new deps", | 299 | "[TRACE] dag/walk: dependencies changed for %q, sending new deps", |
300 | VertexName(v)) | 300 | VertexName(v)) |
301 | 301 | ||
302 | // Start the waiter | 302 | // Start the waiter |
@@ -383,10 +383,10 @@ func (w *Walker) walkVertex(v Vertex, info *walkerVertex) { | |||
383 | // Run our callback or note that our upstream failed | 383 | // Run our callback or note that our upstream failed |
384 | var err error | 384 | var err error |
385 | if depsSuccess { | 385 | if depsSuccess { |
386 | log.Printf("[DEBUG] dag/walk: walking %q", VertexName(v)) | 386 | log.Printf("[TRACE] dag/walk: walking %q", VertexName(v)) |
387 | err = w.Callback(v) | 387 | err = w.Callback(v) |
388 | } else { | 388 | } else { |
389 | log.Printf("[DEBUG] dag/walk: upstream errored, not walking %q", VertexName(v)) | 389 | log.Printf("[TRACE] dag/walk: upstream errored, not walking %q", VertexName(v)) |
390 | err = errWalkUpstream | 390 | err = errWalkUpstream |
391 | } | 391 | } |
392 | 392 | ||
@@ -423,7 +423,7 @@ func (w *Walker) waitDeps( | |||
423 | return | 423 | return |
424 | 424 | ||
425 | case <-time.After(time.Second * 5): | 425 | case <-time.After(time.Second * 5): |
426 | log.Printf("[DEBUG] dag/walk: vertex %q, waiting for: %q", | 426 | log.Printf("[TRACE] dag/walk: vertex %q, waiting for: %q", |
427 | VertexName(v), VertexName(dep)) | 427 | VertexName(v), VertexName(dep)) |
428 | } | 428 | } |
429 | } | 429 | } |