Skip to content
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

Missing support for passing multiple filters of the same type #629

Open
LewisGaul opened this issue Sep 1, 2024 · 2 comments · May be fixed by #635
Open

Missing support for passing multiple filters of the same type #629

LewisGaul opened this issue Sep 1, 2024 · 2 comments · May be fixed by #635
Labels
enhancement New feature or request

Comments

@LewisGaul
Copy link
Collaborator

Filtering can be performed when listing objects or pruning objects. In some components a TypedDict is used to indicate the supported filter types, while in other components a plain Dict[str,str] is used. In either case, this does not support something like docker ps --filter label=foo=1 --filter label=bar.

This was originally brought up in #590, which specifically attempts to address the case of filtering by multiple labels, but the problem is wider than that (see discussion thread #590 (comment)).

This issue tracks fully resolving the root of the issue, which involves needing to change the APIs, as well as adding better typing to all components' filters.

@LewisGaul
Copy link
Collaborator Author

My proposal for the new API is:

docker.container.list(filters=[
    ("label", "foo"),
    ("label", "bar=1"),
    ("status", "created"),
    ("status", "running"),
    ("name", "prefix-*"),
])

This is implemented at master...LewisGaul:python-on-whales:filters-rework.

@gabrieldemarmiesse how should we handle the backwards incompatible change? Do we need to continue to accept Dict[str,str] on all these APIs and emit deprecation warnings?

@LewisGaul LewisGaul added the enhancement New feature or request label Sep 1, 2024
@gabrieldemarmiesse
Copy link
Owner

The new API looks good! Though I believe we shouldn't pull the rug on our users if we can avoid it, so as you say backward compatibility + depreciation warning seems the way to go here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants