github.com/ezbercih/terraform@v0.1.1-0.20140729011846-3c33865e0839/depgraph/dependency.go (about) 1 package depgraph 2 3 import ( 4 "github.com/hashicorp/terraform/digraph" 5 ) 6 7 // Dependency is used to create a directed edge between two nouns. 8 // One noun may depend on another and provide version constraints 9 // that cannot be violated 10 type Dependency struct { 11 Name string 12 Meta interface{} 13 Constraints []Constraint 14 Source *Noun 15 Target *Noun 16 } 17 18 // Constraint is used by dependencies to allow arbitrary constraints 19 // between nouns 20 type Constraint interface { 21 Satisfied(head, tail *Noun) (bool, error) 22 } 23 24 // Head returns the source, or dependent noun 25 func (d *Dependency) Head() digraph.Node { 26 return d.Source 27 } 28 29 // Tail returns the target, or depended upon noun 30 func (d *Dependency) Tail() digraph.Node { 31 return d.Target 32 } 33 34 func (d *Dependency) String() string { 35 return d.Name 36 }