Cherry-pick #18148 to 7.x: Build config files with Go text/template#18212
Merged
andrewkroh merged 3 commits intoelastic:7.xfrom May 5, 2020
Merged
Cherry-pick #18148 to 7.x: Build config files with Go text/template#18212andrewkroh merged 3 commits intoelastic:7.xfrom
andrewkroh merged 3 commits intoelastic:7.xfrom
Conversation
Rather than relying on file concatenation followed by Go text/template we'll just
use Go text/template. This makes is easier to customize a template without having
to modify libbeat since you can just overwrite a template section (like inject your own
processors section).
This works by loading all of the templates from `libbeat/_meta/config/*.tmpl` followed
by templates from `$mybeat/_meta/config/*.tmpl`. Files loaded last take precedence
(it uses go text/template ParseGlob). Finally each template is created from
`libbeat/_meta/config/default{., reference, docker}.yml.tmpl` (which can be changed
if needed, see elastic/agent).
(cherry picked from commit c81adcc)
20095e1 to
5f6eef9
Compare
Contributor
|
Pinging @elastic/siem (Team:SIEM) |
Contributor
💔 Build FailedExpand to view the summary
Build stats
Steps errorsExpand to view the steps failures
Log outputExpand to view the last 100 lines of log output
|
Member
Author
|
run tests |
kvch
approved these changes
May 5, 2020
Member
Author
|
run tests |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #18148 to 7.x branch. Original message:
What does this PR do?
Rather than relying on file concatenation followed by Go text/template we'll just
use Go text/template. This makes is easier to customize a template without having
to modify libbeat since you can just overwrite a template section (like inject your own
processors section).
This works by loading all of the templates from
libbeat/_meta/config/*.tmplfollowedby templates from
$mybeat/_meta/config/*.tmpl. Files loaded last take precedence(it uses go text/template ParseGlob). Finally each template is created from
libbeat/_meta/config/default{., reference, docker}.yml.tmpl(which can be changedif needed, see elastic-agent as an example).
Why is it important?
I need to customize the default processors in the Winlogbeat configuration file and I don't want to add some special logic to the libbeat config files (see an example in https://github.com/elastic/beats/pull/18153/files#diff-5a4f08fe070667029d82636401b2aaf9R95). So with this change a Beat can more easily tailor the config to its needs.
Checklist
- [x] I have made corresponding changes to the documentation- [ ] I have added tests that prove my fix is effective or that my feature worksCHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Author's Checklist
How to test this PR locally
make update