Skip to content

Commit

Permalink
Removed validation of top-level config keys from Winlogbeat (#4657)
Browse files Browse the repository at this point in the history
This behavior was inconsistent with other Beats and caused maintainability issues.
  • Loading branch information
andrewkroh authored and ruflin committed Jul 14, 2017
1 parent 29f4cc7 commit 2c0b000
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 40 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ https://github.com/elastic/beats/compare/v6.0.0-alpha2...master[Check the HEAD d

*Winlogbeat*

- Removed validation of top-level config keys. This behavior was inconsistent with other Beats
and caused maintainability issues. {pull}4657[4657]

==== Added

*Affecting all Beats*
Expand Down
28 changes: 1 addition & 27 deletions winlogbeat/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package config

import (
"fmt"
"sort"
"strings"

"github.com/joeshaw/multierror"
)
Expand Down Expand Up @@ -40,31 +38,7 @@ var (
// Validate validates the Settings data and returns an error describing
// all problems or nil if there are none.
func (s Settings) Validate() error {
// TODO: winlogbeat should not try to validate top-level beats config

validKeys := []string{
"fields", "fields_under_root", "tags", "name", "queue", "max_procs",
"processors", "logging", "output", "path", "winlogbeat", "dashboards",
}
sort.Strings(validKeys)

// Check for invalid top-level keys.
var errs multierror.Errors
for k := range s.Raw {
k = strings.ToLower(k)
i := sort.SearchStrings(validKeys, k)
if i >= len(validKeys) || validKeys[i] != k {
errs = append(errs, fmt.Errorf("Invalid top-level key '%s' "+
"found. Valid keys are %s", k, strings.Join(validKeys, ", ")))
}
}

err := s.Winlogbeat.Validate()
if err != nil {
errs = append(errs, err)
}

return errs.Err()
return s.Winlogbeat.Validate()
}

// WinlogbeatConfig contains all of Winlogbeat configuration data.
Expand Down
13 changes: 0 additions & 13 deletions winlogbeat/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ func TestConfigValidate(t *testing.T) {
},
"", // No Error
},
{
Settings{
WinlogbeatConfig{
EventLogs: []map[string]interface{}{
{"Name": "App"},
},
},
map[string]interface{}{"other": "value"},
},
"1 error: Invalid top-level key 'other' found. Valid keys are dashboards, " +
"fields, fields_under_root, logging, max_procs, " +
"name, output, path, processors, queue, tags, winlogbeat",
},
{
WinlogbeatConfig{},
"1 error: At least one event log must be configured as part of " +
Expand Down

0 comments on commit 2c0b000

Please sign in to comment.