mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-09 16:50:08 -04:00
The dag package is a port over from Terraform to Packer, changing what little there was to fit our current dependency ecosystem. Most of the changes are on the type of diagnostics returned, as Terraform has its own type for them, while we rely on hcl's Diagnostics. Other than that, the functionality is essentially equivalent, and the code was barely touched.
36 lines
735 B
Go
36 lines
735 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package dag
|
|
|
|
// Edge represents an edge in the graph, with a source and target vertex.
|
|
type Edge interface {
|
|
Source() Vertex
|
|
Target() Vertex
|
|
|
|
Hashable
|
|
}
|
|
|
|
// BasicEdge returns an Edge implementation that simply tracks the source
|
|
// and target given as-is.
|
|
func BasicEdge(source, target Vertex) Edge {
|
|
return &basicEdge{S: source, T: target}
|
|
}
|
|
|
|
// basicEdge is a basic implementation of Edge that has the source and
|
|
// target vertex.
|
|
type basicEdge struct {
|
|
S, T Vertex
|
|
}
|
|
|
|
func (e *basicEdge) Hashcode() interface{} {
|
|
return [...]interface{}{e.S, e.T}
|
|
}
|
|
|
|
func (e *basicEdge) Source() Vertex {
|
|
return e.S
|
|
}
|
|
|
|
func (e *basicEdge) Target() Vertex {
|
|
return e.T
|
|
}
|