pgraph, yamlgraph: Allow specifying notify value from YAML

This commit is contained in:
James Shubin
2017-02-06 16:29:02 -05:00
parent 5bdd2ca02f
commit ed268ad683
2 changed files with 14 additions and 5 deletions

View File

@@ -50,7 +50,11 @@ func (g *Graph) Graphviz() (out string) {
for j := range g.Adjacency[i] { for j := range g.Adjacency[i] {
k := g.Adjacency[i][j] k := g.Adjacency[i][j]
// use str for clearer output ordering // use str for clearer output ordering
str += fmt.Sprintf("\t%s -> %s [label=%s];\n", i.GetName(), j.GetName(), k.Name) if k.Notify {
str += fmt.Sprintf("\t%s -> %s [label=%s,style=bold];\n", i.GetName(), j.GetName(), k.Name)
} else {
str += fmt.Sprintf("\t%s -> %s [label=%s];\n", i.GetName(), j.GetName(), k.Name)
}
} }
} }
out += str out += str

View File

@@ -47,9 +47,10 @@ type Vertex struct {
// Edge is the data structure of an edge. // Edge is the data structure of an edge.
type Edge struct { type Edge struct {
Name string `yaml:"name"` Name string `yaml:"name"`
From Vertex `yaml:"from"` From Vertex `yaml:"from"`
To Vertex `yaml:"to"` To Vertex `yaml:"to"`
Notify bool `yaml:"notify"`
} }
// Resources is the data structure of the set of resources. // Resources is the data structure of the set of resources.
@@ -231,7 +232,11 @@ func (c *GraphConfig) NewGraphFromConfig(hostname string, world gapi.World, noop
if _, ok := lookup[util.FirstToUpper(e.To.Kind)][e.To.Name]; !ok { if _, ok := lookup[util.FirstToUpper(e.To.Kind)][e.To.Name]; !ok {
return nil, fmt.Errorf("Can't find 'to' name!") return nil, fmt.Errorf("Can't find 'to' name!")
} }
graph.AddEdge(lookup[util.FirstToUpper(e.From.Kind)][e.From.Name], lookup[util.FirstToUpper(e.To.Kind)][e.To.Name], pgraph.NewEdge(e.Name)) from := lookup[util.FirstToUpper(e.From.Kind)][e.From.Name]
to := lookup[util.FirstToUpper(e.To.Kind)][e.To.Name]
edge := pgraph.NewEdge(e.Name)
edge.Notify = e.Notify
graph.AddEdge(from, to, edge)
} }
return graph, nil return graph, nil