-
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: Migrate to urfave/cli #11700
feat: Migrate to urfave/cli #11700
Conversation
641882d
to
6d59298
Compare
Huge thank you for this. It will make things much more consistent and more easily make changes down the road. Some initial questions for our chat today after quickly scanning this PR:
|
1. Windows only flags now show up in linux output, is there a way to filter these? I don't find this as a blocker Action items from discussion:
|
This looks good no diff between the file generated and the file from master
Once I added your Makefile changes locally, I think the only difference is the lack of a newline. # telegraf from your branch
❯ ./telegraf version | od -c
0000000 T e l e g r a f 1 . 2 4 . 0 -
0000020 a a b 9 5 4 a 8 ( g i t : c
0000040 l i v 2 @ a a b 9 5 4 a 8 )
0000056
# this is telegraf built from master
❯ /tmp/telegraf version | od -c
0000000 T e l e g r a f 1 . 2 4 . 0 -
0000020 9 e a 2 d e a c ( g i t : m
0000040 a s t e r @ 9 e a 2 d e a c ) \n
0000060 |
@powersj I've added the missing newline, nice find! |
I've tested windows service by running the following commands:
With a simple config:
There was an issue I resolved in the latest commit, were I had added an error channel that was blocking the service from starting. I replaced it with just printing an error message. The struct |
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 completed my testing on macOS, went through each of the options, and ensured they worked as I understood them.
On Linux, I tried several invalid configs and options to ensure we still error as expected.
I have put a few comments below, primarily nits and clean-up.
Move run function behind interface
remove hardcoded usages
fix windows service issues rename AgentManager to Telegraf
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.
+1
Looks great, and makes it much easier for us to maintain the CLI going forward, as well as extend it with additional subcommand and flags.
My only concern was re: internal variables, but we can chat as a team about that and make changes before v1.24.0 if needed.
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 |
related to: #11316
There is a goal to clean up the flags and commands of Telegraf (#11316), to help that effort I've migrated the project from using the standard library flag package to using urfave/cli. The urfave/cli package offers a clean and straightforward way to implement flags and commands. I believe this will help provide and easy foundation to begin updating and maintaining the flags/commands.
The goal of this pull request is to just begin using "urfave/cli" package, with no breaking changes, so everything should work as it does now. Then in future pull requests, we can begin deprecating and introducing new flags/commands. I've also added test coverage around the flag/commands which didn't exist before. To add the test coverage I moved the main business logic to a separate function called
runApp
where the actual agent, pprof, and config get passed in. These are mocked out in the new tests.The flags
--sample-config
and--version
have already been marked as deprecated because there are duplicate commands that already existstelegraf config
andtelegraf version
. I also marked--plugin-directory
as deprecated as this is a feature that was quickly disabled after introduction and would require a special build of Telegraf to get working that is not being released officially.