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

Cherry-pick #16450 to 7.x: [Filebeat] Update fileset input merging to replaces paths and append processors. #16525

Merged
merged 1 commit into from
Feb 24, 2020
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
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