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

Adds ability to pass through []string key #32

Merged
merged 1 commit into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions v1/plugin/config_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ func (c *ConfigPolicy) AddNewIntRule(ns []string, key string, req bool, opts ...
}
k := strings.Join(ns, ".")
if c.integerRules[k] == nil {
c.integerRules[k] = &rpc.IntegerPolicy{Rules: map[string]*rpc.IntegerRule{}}
c.integerRules[k] = &rpc.IntegerPolicy{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want c.integerRules[k] to be a slice instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It uses this format to maintain backward compatibility.

Rules: map[string]*rpc.IntegerRule{},
Key: ns,
}
}
c.integerRules[k].Rules[key] = &rule
return nil
Expand All @@ -84,7 +87,10 @@ func (c *ConfigPolicy) AddNewBoolRule(ns []string, key string, req bool, opts ..
}
k := strings.Join(ns, ".") // Method used in daemon/ctree
if c.boolRules[k] == nil {
c.boolRules[k] = &rpc.BoolPolicy{Rules: map[string]*rpc.BoolRule{}}
c.boolRules[k] = &rpc.BoolPolicy{
Rules: map[string]*rpc.BoolRule{},
Key: ns,
}
}
c.boolRules[k].Rules[key] = rule
return nil
Expand All @@ -109,7 +115,10 @@ func (c *ConfigPolicy) AddNewFloatRule(ns []string, key string, req bool, opts .
}
k := strings.Join(ns, ".")
if c.floatRules[k] == nil {
c.floatRules[k] = &rpc.FloatPolicy{Rules: map[string]*rpc.FloatRule{}}
c.floatRules[k] = &rpc.FloatPolicy{
Rules: map[string]*rpc.FloatRule{},
Key: ns,
}
}
c.floatRules[k].Rules[key] = rule
return nil
Expand All @@ -132,7 +141,10 @@ func (c *ConfigPolicy) AddNewStringRule(ns []string, key string, req bool, opts
}
k := strings.Join(ns, ".") // Method used in daemon/ctree
if c.stringRules[k] == nil {
c.stringRules[k] = &rpc.StringPolicy{Rules: map[string]*rpc.StringRule{}}
c.stringRules[k] = &rpc.StringPolicy{
Rules: map[string]*rpc.StringRule{},
Key: ns,
}
}
c.stringRules[k].Rules[key] = rule
return nil
Expand Down
176 changes: 90 additions & 86 deletions v1/plugin/rpc/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.