-
Notifications
You must be signed in to change notification settings - Fork 254
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
Fix raw-filter flags by binding flags to viper only if command is run #1202
Conversation
I'm not entirely sure this is the best way to fix this. It's probably the shortest, but it doesn't remove the original footgun that we can easily bind two flagsets to the same viper config. |
This approach seems reasonable. I'm sure there's probably a "better" way to do it, but I suspect it involves bigger refactors. I do think what we need however is a test for this. Could you add a new test case into https://github.com/cilium/hubble/blob/main/cmd/cli_test.go where you call |
2d61ef7
to
ce1d9f9
Compare
The raw-filter flags are broken since we bind them to viper twice with the same name, during initalization. Once for `hubble observe` and once for `hubble observe flows`. This means that only the flags for `hubble observe flows` work, as it is registered later and overwrites the binding for `hubble observe` We fix this by only binding the flags of the command we actually run. Fixes: cilium#1201 Signed-off-by: Fabian Fischer <fabian.fischer@isovalent.com>
ce1d9f9
to
fb43016
Compare
Good point, I totally forgot about that. I added a test case for it. Had to do a very minor change to printing raw filters toactually use the output defined by the command, so that the test case actually works. |
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.
Nice catch!
The raw-filter flags are broken since we bind them to viper twice with the same name, during initalization. Once for
hubble observe
and once forhubble observe flows
. This means that only the flags forhubble observe flows
work, as it is registered later and overwrites the binding forhubble observe
We fix this by only binding the flags of the command we actually run.
Fixes: #1201