Skip to content

Commit

Permalink
Add changelog and uses match.Matcher interface (elastic#9504)
Browse files Browse the repository at this point in the history
* blacklist changelog

* Uses match.Matcher instead of *regexp.Matcher
  • Loading branch information
ph committed Dec 12, 2018
1 parent 3bd004f commit fa99c82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ https://github.com/elastic/beats/compare/v6.5.0...6.x[Check the HEAD diff]

*Filebeat*

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

*Heartbeat*

*Journalbeat*

*Metricbeat*

- Fix issue preventing diskio metrics collection for idle disks. {issue}9124[9124] {pull}9125[9125]
- Allow beats to blacklist certain part of the configuration while using Central Management. {pull}9099[9099]

*Packetbeat*

*Packetbeat*

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

0 comments on commit fa99c82

Please sign in to comment.