From c8513eefa0ef765d005ae81a88c0bbdfa1898eac Mon Sep 17 00:00:00 2001 From: Vijay Samuel Date: Tue, 24 Jul 2018 11:32:39 -0700 Subject: [PATCH] Add custom unpack to log hints config to avoid env resolution --- CHANGELOG.asciidoc | 2 ++ filebeat/autodiscover/builder/hints/config.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index abc86c8c189..33e179beb5a 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -54,6 +54,8 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff] *Filebeat* +- Add custom unpack to log hints config to avoid env resolution {pull}7710[7710] + *Heartbeat* *Metricbeat* diff --git a/filebeat/autodiscover/builder/hints/config.go b/filebeat/autodiscover/builder/hints/config.go index dab0a21105e..2269daa88de 100644 --- a/filebeat/autodiscover/builder/hints/config.go +++ b/filebeat/autodiscover/builder/hints/config.go @@ -39,3 +39,21 @@ func defaultConfig() config { Config: cfg, } } + +func (c *config) Unpack(from *common.Config) error { + tmpConfig := struct { + Key string `config:"key"` + }{ + Key: c.Key, + } + if err := from.Unpack(&tmpConfig); err != nil { + return err + } + + if config, err := from.Child("config", -1); err == nil { + c.Config = config + } + + c.Key = tmpConfig.Key + return nil +}