Skip to content

Conversation

mohammedfuta2000
Copy link
Contributor

closes #6021
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 to support exclusionary filters.

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-commenter
Copy link

codecov-commenter commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 38.88889% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
opts/opts.go 0.00% 11 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment on lines +133 to +137
func (args Args) Add(key, value string, isEqualOps ...bool) {
isEqualOp := true
if len(isEqualOps) > 0 {
isEqualOp = isEqualOps[0]
}
Copy link
Member

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)

Copy link
Contributor Author

@mohammedfuta2000 mohammedfuta2000 Apr 24, 2025

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)

mohammedfuta2000 added a commit to mohammedfuta2000/moby that referenced this pull request Apr 25, 2025
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--filter does not work with negatives anywhere other than prune
3 participants