lang: Don't add identical resources to graph
This means that it's legal to produce two compatible (usually identical) resources without a compile error and without causing two of them to get run. It's too bad puppet never got this right. It's probably worth checking if this could be done for edges too, and if the logic can be contained in the engine and not in the frontend.
This commit is contained in:
@@ -47,7 +47,6 @@ func interpret(ast interfaces.Stmt) (*pgraph.Graph, error) {
|
|||||||
var receive = make(map[string]map[string]map[string]*engine.Send)
|
var receive = make(map[string]map[string]map[string]*engine.Send)
|
||||||
|
|
||||||
for _, res := range output.Resources {
|
for _, res := range output.Resources {
|
||||||
graph.AddVertex(res)
|
|
||||||
kind := res.Kind()
|
kind := res.Kind()
|
||||||
name := res.Name()
|
name := res.Name()
|
||||||
if _, exists := lookup[kind]; !exists {
|
if _, exists := lookup[kind]; !exists {
|
||||||
@@ -64,10 +63,13 @@ func interpret(ast interfaces.Stmt) (*pgraph.Graph, error) {
|
|||||||
return nil, errwrap.Wrapf(err, "incompatible duplicate resource `%s` found", res)
|
return nil, errwrap.Wrapf(err, "incompatible duplicate resource `%s` found", res)
|
||||||
}
|
}
|
||||||
// more than one compatible resource exists... we allow
|
// more than one compatible resource exists... we allow
|
||||||
// duplicates, if they're going to not conflict...
|
// duplicates, if they're not going to conflict...
|
||||||
// XXX: does it matter which one we add to the graph?
|
// TODO: does it matter which one we add to the graph?
|
||||||
|
// currently we add the first one that was found...
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
lookup[kind][name] = res // add to temporary lookup table
|
lookup[kind][name] = res // add to temporary lookup table
|
||||||
|
graph.AddVertex(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range output.Edges {
|
for _, e := range output.Edges {
|
||||||
|
|||||||
Reference in New Issue
Block a user