-
Notifications
You must be signed in to change notification settings - Fork 2k
Support '!=' operator in filters and record its usage #6035
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: master
Are you sure you want to change the base?
Support '!=' operator in filters and record its usage #6035
Conversation
In `Add()` (vendor/github.com/docker/docker/api/types/filters/parse.go), we previously assigned `args.fields[key][value] = true` with "true" being a placeholder. Now, it holds `isEqualOp`, a boolean indicating whether the filter uses `=` (true) or `!=` (false). This enables us to distinguish between inclusion and exclusion filters. The `Set()` function (opts/opts.go) has been updated to detect both `=` and `!=` in filter strings, replacing the previous convention of using a trailing `!` to indicate negation. Update `confirmationMessage()` function (cli/command/system/prune.go) to include isEqualOp value in print out for prune command. The daemon is to be updated [this issue](moby/moby#13533) to support exclusionary filters. Signed-off-by: Mohammed Aminu Futa <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6035 +/- ##
=======================================
Coverage 58.89% 58.89%
=======================================
Files 358 358
Lines 29962 30001 +39
=======================================
+ Hits 17647 17670 +23
- Misses 11334 11350 +16
Partials 981 981 🚀 New features to boost your workflow:
|
func (args Args) Add(key, value string, isEqualOps ...bool) { | ||
isEqualOp := true | ||
if len(isEqualOps) > 0 { | ||
isEqualOp = isEqualOps[0] | ||
} |
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 code is in a vendored file; it's code that's maintained in the https://github.com/moby/moby repository, and should not be modified here, but in upstream; https://github.com/moby/moby/blob/b466483877ee8047e33c66ad05b857b0340b81e4/api/types/filters/parse.go#L126-L133
The trickier bit here is that these are part of the API, so changing the format could require versioning to make sure that things don't break with a new CLI connecting to an older API version (or vice-versa)
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.
Seen it. thanks
yes versioning will be required. I've some suggestion for updating the docker daemon here(moby/moby#13533)
Introduced matchWithOperator to determine inclusionary (=) or exclusionary (!=) filtering based on CLI input, per changes in [this PR](docker/cli#6035). Integrated it into Match, ExactMatch, UniqueExactMatch, and FuzzyMatch functions Also created GetPair Function and updated the Add function for use in the CLI update in the above PR Signed-off-by: Mohammed Aminu Futa <[email protected]>
closes #6021
In
Add()
(vendor/github.com/docker/docker/api/types/filters/parse.go), we previously assignedargs.fields[key][value] = true
with "true" being a placeholder.Now, it holds
isEqualOp
, a boolean indicating whether the filter uses=
(true) or!=
(false). This enables us to distinguish between inclusion and exclusion filters.The
Set()
function (opts/opts.go) has been updated to detect both=
and!=
in filter strings, replacing the previous convention of using a trailing!
to indicate negation.Update
confirmationMessage()
function (cli/command/system/prune.go) to include isEqualOp value in print out for prune command.The daemon is to be updated this issue to support exclusionary filters.