-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Add reference filter and deprecated filter param… #27872
Conversation
design LGTM |
dc77d9f
to
3b052b2
Compare
All right, so
I need to update the PR code to re-use path instead of the reference package 😓 |
@vdemeester Might be worthwhile to bolster the
This has use in scope-matching and other applications. |
3b052b2
to
3208c24
Compare
3208c24
to
dd91673
Compare
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.
Updated, than should fix the build but I have a question 👼
@@ -168,6 +169,20 @@ func ParseIDOrReference(idOrRef string) (digest.Digest, Named, error) { | |||
return "", ref, err | |||
} | |||
|
|||
// Match reports whether ref matches the specified pattern | |||
func Match(pattern string, ref Named) bool { | |||
// FIXME: should we support pattern for NamedTagged or not ? |
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.
The lines below are to keep the current behaviour, not sure I like that… We might want to implement supporting foo/**/[ai]:ta*
and keep the current behavior in images.go
👼 @stevvooe wdyt ?
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.
First, we should implement this in the upstream distribution package. These packages keep diverging and it is extremely disappointing.
As far as support goes, we should support globbing over any of the reference types.
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.
First, we should implement this in the upstream distribution package. These packages keep diverging and it is extremely disappointing.
❤️
if _, ok := patternRef.(NamedTagged); err == nil && ok { | ||
return ref.String() == pattern | ||
} | ||
matched, err := path.Match(pattern, ref.Name()) |
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.
Does this need to use ref.String()
?
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.
If we want to support globbing over any of the reference types, yes we should do that.
}{ | ||
{ | ||
reference: "foo", | ||
pattern: "foo/**/ba[rz]", |
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.
The globbing in golang's stdlib doesn't support **
for multi-component match. This case is still valid but this pattern will only match foo/a/ba[rz]
, not foo/a/b/ba[rz]
. I don't think we need to do more for this PR.
dd91673
to
4a872fe
Compare
Updated and depends on distribution/distribution#2039 👼 |
ee89d27
to
d66e676
Compare
d66e676
to
9220755
Compare
9220755
to
7883d0c
Compare
I think this is blocked by #28235 for now 👼 |
@vdemeester Should be unblocked, now! |
7883d0c
to
6f3f4f6
Compare
@stevvooe It is, PR rebased 👼 |
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.
LGTM
Glad to see this one go.
} | ||
|
||
version := httputils.VersionFromContext(ctx) | ||
if versions.LessThan(version, "1.28") && r.Form.Get("filter") != "" { |
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.
Minor minor nit, but store the value of the filter field instead of getting it twice.
… for `docker images`. This deprecates the `filter` param for the `/images` endpoint and make a new filter called `reference` to replace it. It does change the CLI side (still possible to do `docker images busybox:musl`) but changes the cli code to use the filter instead (so that `docker images --filter busybox:musl` and `docker images busybox:musl` act the same). Signed-off-by: Vincent Demeester <[email protected]>
6f3f4f6
to
820b809
Compare
LGTM |
ping @AkihiroSuda;
|
@@ -1733,7 +1733,7 @@ references on the command line. | |||
- `label=key` or `label="key=value"` of an image label | |||
- `before`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) | |||
- `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) | |||
- **filter** - only return images with the specified name | |||
- `reference`=(`<image-name>[:<tag>]`) |
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.
@vdemeester can you do a follow up PR to;
- add a line to the API changes; https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api.md#v125-api-changes
- maybe add a note to the API reference about the deprecated option
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.
Yep I will do a followup for the docs 😉
@thaJeztah ah, it is discussed in #27938 I will try to find the solution ASAP.. |
@AkihiroSuda ah! yes, no problem, just wanted to let you know 😄 |
Add reference filter and deprecated filter param…
Add reference filter and deprecated filter param for
/images/json
– it was a little bit too confusing for me betweenfilter
andfilters
.This deprecates the
filter
param for the/images/json
endpoint and make a new filter calledreference
to replace it. It does change the CLI side (still possible to dodocker images busybox:musl
) but changes the cli code to use the filter instead (so thatdocker images --filter reference=busybox:musl
anddocker images busybox:musl
act the same)./cc @thaJeztah @cpuguy83 @tiborvass @stevvooe
🐸
Signed-off-by: Vincent Demeester [email protected]