Skip to content

Commit

Permalink
[Filebeat] Update fileset input merging to replaces paths and append …
Browse files Browse the repository at this point in the history
…processors. (#16450) (#16525)

* Update go-ucfg to 0.8.3 to use the new field merging adjustments. Update fileset input merging to replaces paths and append procesors.

* Add changelog entry.

(cherry picked from commit 9695092)
  • Loading branch information
blakerouse authored Feb 24, 2020
1 parent 408ebc0 commit dcaf7c2
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 41 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix index names for indexing not always guaranteed to be lower case. {pull}16081[16081]
- Upgrade go-ucfg to latest v0.8.1. {pull}15937{15937}
- Fix loading processors from annotation hints. {pull}16348[16348]
- Upgrade go-ucfg to latest v0.8.3. {pull}16450{16450}

*Auditbeat*

Expand All @@ -103,6 +104,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix mapping error for cloudtrail additionalEventData field {pull}16088[16088]
- Fix a connection error in httpjson input. {pull}16123[16123]
- Improve `elasticsearch/audit` fileset to handle timestamps correctly. {pull}15942[15942]
- Fix merging of fileset inputs to replace paths and append processors. {pull}16450{16450}

*Heartbeat*

Expand Down
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,8 @@ Apache License 2.0

--------------------------------------------------------------------
Dependency: github.com/elastic/go-ucfg
Version: v0.8.2
Revision: ab69586e10820006b250d04c98cc3b848e227808
Version: v0.8.3
Revision: f3ae3b220df32cfcae011ec6bbf87a711e6bf06b
License type (autodetected): Apache-2.0
./vendor/github.com/elastic/go-ucfg/LICENSE:
--------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion filebeat/fileset/fileset.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
"strings"
"text/template"

"github.com/elastic/go-ucfg"

errw "github.com/pkg/errors"
"gopkg.in/yaml.v2"

Expand Down Expand Up @@ -362,7 +364,7 @@ func (fs *Fileset) getInputConfig() (*common.Config, error) {
if err != nil {
return nil, fmt.Errorf("Error creating config from input overrides: %v", err)
}
cfg, err = common.MergeConfigs(cfg, overrides)
cfg, err = common.MergeConfigsWithOptions([]*common.Config{cfg, overrides}, ucfg.FieldReplaceValues("**.paths"), ucfg.FieldAppendValues("**.processors"))
if err != nil {
return nil, fmt.Errorf("Error applying config overrides: %v", err)
}
Expand Down
18 changes: 18 additions & 0 deletions libbeat/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ func MergeConfigs(cfgs ...*Config) (*Config, error) {
return config, nil
}

func MergeConfigsWithOptions(cfgs []*Config, options ...ucfg.Option) (*Config, error) {
config := NewConfig()
for _, c := range cfgs {
if err := config.MergeWithOpts(c, options...); err != nil {
return nil, err
}
}
return config, nil
}

func NewConfigWithYAML(in []byte, source string) (*Config, error) {
opts := append(
[]ucfg.Option{
Expand Down Expand Up @@ -164,6 +174,14 @@ func (c *Config) Merge(from interface{}) error {
return c.access().Merge(from, configOpts...)
}

func (c *Config) MergeWithOpts(from interface{}, opts ...ucfg.Option) error {
o := configOpts
if opts != nil {
o = append(o, opts...)
}
return c.access().Merge(from, o...)
}

func (c *Config) Unpack(to interface{}) error {
return c.access().Unpack(to, configOpts...)
}
Expand Down
8 changes: 7 additions & 1 deletion vendor/github.com/elastic/go-ucfg/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 70 additions & 2 deletions vendor/github.com/elastic/go-ucfg/merge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

113 changes: 113 additions & 0 deletions vendor/github.com/elastic/go-ucfg/opts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dcaf7c2

Please sign in to comment.