Skip to content

Commit

Permalink
Dont append to slices in mergeStruct
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Nov 18, 2015
1 parent 19e5d97 commit 4be19fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@ func (a *Agent) LoadPlugins(filters []string, config *Config) ([]string, error)
var names []string

for name, plugin := range config.PluginsDeclared() {
fmt.Println("Declared plugin: ", plugin)
if sliceContains(name, filters) || len(filters) == 0 {
config, err := config.ApplyPlugin(name, plugin)
if err != nil {
return nil, err
}
fmt.Println("Applied plugin: ", plugin)

a.plugins = append(a.plugins, &runningPlugin{name, plugin, config})
names = append(names, name)
Expand Down
11 changes: 6 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,12 @@ func mergeStruct(base, overlay interface{}, fields []string) error {
overlayValue.Type(), field)
}
baseFieldValue := findField(field, baseValue)
if overlayFieldValue.Kind() == reflect.Slice {
baseFieldValue.Set(reflect.AppendSlice(baseFieldValue, overlayFieldValue))
} else {
baseFieldValue.Set(overlayFieldValue)
}
baseFieldValue.Set(overlayFieldValue)
// if overlayFieldValue.Kind() == reflect.Slice {
// baseFieldValue.Set(reflect.AppendSlice(baseFieldValue, overlayFieldValue))
// } else {
// baseFieldValue.Set(overlayFieldValue)
// }
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions plugins/apache/apache.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (n *Apache) Description() string {
func (n *Apache) Gather(acc plugins.Accumulator) error {
var wg sync.WaitGroup
var outerr error
fmt.Println(n.Urls)

for _, u := range n.Urls {
addr, err := url.Parse(u)
Expand Down

0 comments on commit 4be19fb

Please sign in to comment.