Support '!=' operator in filters and record its usage#6035
Support '!=' operator in filters and record its usage#6035mohammedfuta2000 wants to merge 1 commit intodocker:masterfrom
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 <mohammedfuta2000@gmail.com>
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
| 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.
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.
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 <mohammedfuta2000@gmail.com>
closes #6021
In
Add()(vendor/github.com/docker/docker/api/types/filters/parse.go), we previously assignedargs.fields[key][value] = truewith "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.