From 8019b90b8aceec8e00465aa2d1acb32d58a9b63d Mon Sep 17 00:00:00 2001 From: James Shubin Date: Tue, 12 Jun 2018 17:36:30 -0400 Subject: [PATCH] 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. --- lang/interpret.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lang/interpret.go b/lang/interpret.go index 9ee14a1b..083653fa 100644 --- a/lang/interpret.go +++ b/lang/interpret.go @@ -47,7 +47,6 @@ func interpret(ast interfaces.Stmt) (*pgraph.Graph, error) { var receive = make(map[string]map[string]map[string]*engine.Send) for _, res := range output.Resources { - graph.AddVertex(res) kind := res.Kind() name := res.Name() 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) } // more than one compatible resource exists... we allow - // duplicates, if they're going to not conflict... - // XXX: does it matter which one we add to the graph? + // duplicates, if they're not going to conflict... + // 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 + graph.AddVertex(res) } for _, e := range output.Edges {