-
Notifications
You must be signed in to change notification settings - Fork 2.5k
refactor(cli): add custom flag groups #8594
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
base: main
Are you sure you want to change the base?
Conversation
14b4f69
to
39470c7
Compare
can you confirm if it's possible to add a flag to an existing flag group, it it has to be a new one? |
This PR does not support adding flags to existing flag groups. It supports additional flag groups. If we need to extend flags in the production version, I think it's sufficient to group flags that are only valid in the production version into a dedicated flag group for production. As far as I know, this approach meets the requirements, but if adding to existing groups is mandatory, the implementation will need to be adjusted. |
- Introduced a new extension system to support custom CLI flag groups for various commands. - Updated command definitions to utilize the new `CustomFlagGroups` method, enhancing modularity and flexibility. - Added tests to validate the behavior of custom flag groups and ensure proper integration with existing command structures. - Improved overall flag handling by allowing extensions to define their own flag groups, facilitating future enhancements.
ed62483
to
84eb623
Compare
@knqyf263 looks good. Will this support setting the flag value both from the command and environment variable? IMO, changing an existing flag group is not a requirement from our side. @tamirkiviti13 wdyt? |
…ble support - Added a test case to verify the behavior of the `TRIVY_FOO` environment variable in the `TestCustomFlagGroups` function. - Ensured that the flag system correctly retrieves values from both environment variables and custom flags. - Improved test coverage for the flag handling functionality.
fe64ab8
to
51cefc4
Compare
@danielciuraru86 @knqyf263 @itaysk |
yes that was my thinking as well |
I don't mind either way, but since I thought that gathering flags available only in the enterprise version in one place would make them easier to view, I have currently implemented only the addition of custom flag groups. This also keeps the implementation simple. However, if there is a good reason to include them in the existing Scan Flags group, we can implement that. |
the reason is better UX IMO. for example, let's assume |
These flags are currently displayed by default regardless of whether an Aqua token is passed. In other words, they will always be displayed when running |
In other words, I think that for OSS users it would be better if they were grouped separately, while for enterprise users it may be preferable that they are merged into the existing flag group. |
I tend to agree with @knqyf263, because the flags are always displayed. |
I do think we should display the extension flags always, not only to authenticated users, but with a label or indicator that they are differentiated (like some product uses the term "pro" features). if we group all "pro" features in a single seperate group (and I suspect we'll have quite a few of those new features) it wouldn't make much sense UX wise. Consider also that in the documentation they would be mixed, for example, to continue my earlier example the |
Why is that? For those who are interested in enterprise features, they can simply refer to the dedicated flag group to see what options are available. Therefore, having an Enterprise flag group is somewhat logical for me. I’d like to understand how you think it would impact the UX.
Does that mean that, from that perspective, it would be better to separate the Enterprise features from OSS features? Or are you suggesting that even in the documentation, mixing OSS and Enterprise features is preferable? Additionally, I attempted to write a PoC, but the implementation cost turned out to be higher than expected. Once again, considering that mixing Enterprise flags into the existing flag group might negatively impact the user experience for OSS users, I’m not sure whether the benefits of incurring that implementation cost would be worthwhile for most Trivy users. I would like to understand whether the decision is based on accepting a degraded UX for OSS users if it improves UX for Enterprise users or if the belief is that mixing the flags would yield a better UX for OSS users as well. |
Description
This PR introduces a new extension system to support custom CLI flag groups for various Trivy commands. The implementation:
CustomFlagGroups
function that collects flag groups from registered extensionsCustomOptions
map to the flag options to store custom valuesThis enhancement improves modularity and flexibility by allowing extensions to define their own CLI flags without modifying the core codebase. This is primarily an internal change for Aqua Security.
Related PRs
Checklist