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

Add changelog and uses match.Matcher interface #9504

Merged
merged 2 commits into from
Dec 12, 2018
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
4 changes: 4 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha1...master[Check the HEAD d

*Filebeat*

- Allow beats to blacklist certain part of the configuration while using Central Management. {pull}9099[9099]

*Heartbeat*

*Journalbeat*

*Metricbeat*

- Allow beats to blacklist certain part of the configuration while using Central Management. {pull}9099[9099]

*Packetbeat*

*Winlogbeat*
Expand Down
10 changes: 5 additions & 5 deletions x-pack/libbeat/management/blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ package management

import (
"fmt"
"regexp"
"strings"

"github.com/joeshaw/multierror"
"github.com/pkg/errors"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/match"
"github.com/elastic/beats/x-pack/libbeat/management/api"
)

// ConfigBlacklist takes a ConfigBlocks object and filter it based on the given
// blacklist settings
type ConfigBlacklist struct {
patterns map[string]*regexp.Regexp
patterns map[string]match.Matcher
}

// ConfigBlacklistSettings holds a list of fields and regular expressions to blacklist
Expand All @@ -46,11 +46,11 @@ func (f *ConfigBlacklistSettings) Unpack(from interface{}) error {
// NewConfigBlacklist filters configs from CM according to a given blacklist
func NewConfigBlacklist(cfg ConfigBlacklistSettings) (*ConfigBlacklist, error) {
list := ConfigBlacklist{
patterns: map[string]*regexp.Regexp{},
patterns: map[string]match.Matcher{},
}

for field, pattern := range cfg.Patterns {
exp, err := regexp.Compile(pattern)
exp, err := match.Compile(pattern)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("Given expression is not a valid regexp: %s", pattern))
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func (c *ConfigBlacklist) isBlacklisted(blockType string, block *api.ConfigBlock
return false
}

func (c *ConfigBlacklist) isBlacklistedBlock(pattern *regexp.Regexp, segments []string, current *common.Config) bool {
func (c *ConfigBlacklist) isBlacklistedBlock(pattern match.Matcher, segments []string, current *common.Config) bool {
if current.IsDict() {
switch len(segments) {
case 0:
Expand Down