-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
feat: generate the plugins sample config #10886
Conversation
ebd8649
to
1952a49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this idea
95485b2
to
4ea064b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! A few questions before this afternoon
TODO:
|
c6a0032
to
c5b9de1
Compare
Edit file vs rename/remove
Not sure why it is failing now, while it worked before
712df21
to
7b06807
Compare
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
resolve: #9733
Description
Adding a tool called
generate_plugindata
that reads a plugins README.md and extracts the sample config, then using the source file as a template inject the sample configuration into it. The purpose is to avoid having to maintain the sample config in two different spots, in the README.md and in the code. This will lead to removing 11,000 lines of duplicate sample configuration from our source code that we no longer have to maintain!Each plugin would have a header like this:
Then the sample config function would be updated like this:
and if you run
make
you would see this output:Plugin migration
All the plugins have been migrated to this new format in separate pull requests. Separate pull requests were made to keep this pull request smaller and easier to review originally this was 396 files changed with all plugins migrated. I wrote a simple local tool to help automate the migration of the plugins. Unfortunately, there are minor differences between the README.md and source code configs that will have to be manually reviewed and fixed to determine the correct one.
Testing
Resulting telegraf.conf: https://gist.github.com/sspaink/554f4843e87afbaa39bb436625a39b4d
You can generate your own local config by running the following commands:
git checkout -b testbranch
git merge origin/generatesampleconfig && git merge origin/updateinputconifg_a-l --no-edit && git merge origin/updateinputconifg_m-z --no-edit && git merge origin/updateaggregatorconfig --no-edit && git merge origin/updateprocessorconfig --no-edit && git merge origin/updateoutputconfig -s recursive -X theirs --no-edit
make
./telegraf config > telegraf.conf
git reset --hard origin/generatesampleconfig