Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed validation of top-level config keys from Winlogbeat #4657

Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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