Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Fixes issues in cpolicy where merge would modify caller
Browse files Browse the repository at this point in the history
In cpolicy, when Merge is called it modifies the callers rules which is
not the desired behavior. This adds the creation of a new node that is
used to contain the merged rules.
  • Loading branch information
IRCody committed Aug 17, 2016
1 parent f7767bd commit 7f3fa5b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions control/plugin/cpolicy/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,17 @@ func (c ConfigPolicyNode) Merge(n ctree.Node) ctree.Node {
cd := n.(*ConfigPolicyNode)
// For the rules in the passed ConfigPolicyNode(converted) add each rule to
// this ConfigPolicyNode overwriting where needed.
no := NewPolicyNode()
for _, r := range c.rules {
no.Add(r)
}

for _, r := range cd.rules {
c.Add(r)

no.Add(r)
}
// Return modified version of ConfigPolicyNode(as ctree.Node)
return c
return no
}

// addRulesToConfigPolicyNode accepts a map of empty interfaces that will be
Expand Down

0 comments on commit 7f3fa5b

Please sign in to comment.