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

Commit

Permalink
Changed keyNode types to use embedded types
Browse files Browse the repository at this point in the history
  • Loading branch information
IRCody committed Oct 7, 2016
1 parent d969354 commit 92097f5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions control/plugin/cpolicy/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ func (c *ConfigPolicy) Get(ns []string) *ConfigPolicyNode {
}

type keyNode struct {
Key []string
Node *ConfigPolicyNode
Key []string
*ConfigPolicyNode
}

func (c *ConfigPolicy) GetAll() []keyNode {

ret := make([]keyNode, 0)
for _, node := range c.config.GetAll() {
key := node.Key
switch t := node.N.(type) {
switch t := node.Node.(type) {
case *ConfigPolicyNode:
ret = append(ret, keyNode{Key: key, Node: t})
ret = append(ret, keyNode{Key: key, ConfigPolicyNode: t})
}
}
return ret
Expand Down
2 changes: 1 addition & 1 deletion control/plugin/rpc/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewGetConfigPolicyReply(policy *cpolicy.ConfigPolicy) (*GetConfigPolicyRepl
for _, node := range policy.GetAll() {
key := strings.Join(node.Key, ".")

for _, rule := range node.Node.RulesAsTable() {
for _, rule := range node.RulesAsTable() {
switch rule.Type {
case cpolicy.BoolType:
r := &BoolRule{
Expand Down
3 changes: 1 addition & 2 deletions control/plugin_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ func (p *pluginManager) LoadPlugin(details *pluginDetails, emitter gomit.Emitter
if lPlugin.ConfigPolicy != nil {
// Get plugin config defaults
defaults := cdata.NewNode()
for _, kn := range lPlugin.ConfigPolicy.GetAll() {
cpolicy := kn.Node
for _, cpolicy := range lPlugin.ConfigPolicy.GetAll() {
_, errs := cpolicy.AddDefaults(defaults.Table())
if len(errs.Errors()) > 0 {
for _, err := range errs.Errors() {
Expand Down
6 changes: 3 additions & 3 deletions pkg/ctree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (c *ConfigTree) Add(ns []string, inNode Node) {

type keyNode struct {
Key []string
N Node
Node
}

func (c *ConfigTree) GetAll() []keyNode {
Expand All @@ -137,8 +137,8 @@ func (c *ConfigTree) getAll(node *node, key []string, res *[]keyNode) []keyNode
}
if node.Node != nil {
k := keyNode{
Key: key,
N: node.Node,
Key: key,
Node: node.Node,
}
*res = append(*res, k)
}
Expand Down

0 comments on commit 92097f5

Please sign in to comment.