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

Add reference filter and deprecated filter param… #27872

Merged
merged 1 commit into from
Nov 11, 2016

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Oct 29, 2016

Add reference filter and deprecated filter param for /images/json – it was a little bit too confusing for me between filter and filters.

This deprecates the filter param for the /images/json 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 reference=busybox:musl and docker images busybox:musl act the same).

$ docker images busybox
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox             uclibc              e02e811dd08f        3 weeks ago         1.093 MB
busybox             musl                733eb3059dce        3 weeks ago         1.213 MB
busybox             glibc               21c16b6787c6        3 weeks ago         4.187 MB
busybox             latest              2b8fd9751c4c        4 months ago        1.093 MB
$ docker images --filter reference=busybox
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox             uclibc              e02e811dd08f        3 weeks ago         1.093 MB
busybox             musl                733eb3059dce        3 weeks ago         1.213 MB
busybox             glibc               21c16b6787c6        3 weeks ago         4.187 MB
busybox             latest              2b8fd9751c4c        4 months ago        1.093 MB
# […]
$ docker images busybox:uclibc
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox             uclibc              e02e811dd08f        3 weeks ago         1.093 MB
$ docker images --filter reference=busybox:uclibc
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox             uclibc              e02e811dd08f        3 weeks ago         1.093 MB
$ docker images busyb
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
$ docker images --filter reference=busyb
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
  • Validate the new filter (name, …) 👼
  • Add tests for the new filter
  • Add docs for the new filter

/cc @thaJeztah @cpuguy83 @tiborvass @stevvooe

🐸

Signed-off-by: Vincent Demeester [email protected]

@thaJeztah
Copy link
Member

design LGTM

@vdemeester vdemeester added this to the 1.13.0 milestone Oct 29, 2016
@vdemeester vdemeester force-pushed the images-filter-filters branch 3 times, most recently from dc77d9f to 3b052b2 Compare October 29, 2016 01:02
@vdemeester
Copy link
Member Author

All right, so docker images … support a little bit of globbing

λ docker images "centos/*a*"                                                                                                                          
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos/mariadb      latest              23d3ef33ce06        3 months ago        370.6 MB
centos/etherpad     latest              097d06617332        3 months ago        378.1 MB

I need to update the PR code to re-use path instead of the reference package 😓

@vdemeester vdemeester added the status/failing-ci Indicates that the PR in its current state fails the test suite label Oct 29, 2016
@stevvooe
Copy link
Contributor

stevvooe commented Nov 3, 2016

@vdemeester Might be worthwhile to bolster the reference package with glob-based matching:

references.Match(ref, "foo/**/ba[rz]")

This has use in scope-matching and other applications.

@vdemeester vdemeester force-pushed the images-filter-filters branch from 3b052b2 to 3208c24 Compare November 3, 2016 13:01
@vdemeester vdemeester removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Nov 3, 2016
@vdemeester vdemeester force-pushed the images-filter-filters branch from 3208c24 to dd91673 Compare November 3, 2016 13:06
Copy link
Member Author

@vdemeester vdemeester left a 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 ?
Copy link
Member Author

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 ?

Copy link
Contributor

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.

Copy link
Member Author

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())
Copy link
Contributor

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()?

Copy link
Member Author

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]",
Copy link
Contributor

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.

@vdemeester
Copy link
Member Author

Updated and depends on distribution/distribution#2039 👼

@vdemeester vdemeester force-pushed the images-filter-filters branch 2 times, most recently from ee89d27 to d66e676 Compare November 10, 2016 13:46
@vdemeester vdemeester force-pushed the images-filter-filters branch from d66e676 to 9220755 Compare November 10, 2016 14:34
@vdemeester vdemeester added the status/failing-ci Indicates that the PR in its current state fails the test suite label Nov 10, 2016
@vdemeester vdemeester force-pushed the images-filter-filters branch from 9220755 to 7883d0c Compare November 10, 2016 17:51
@vdemeester vdemeester removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Nov 10, 2016
@vdemeester
Copy link
Member Author

I think this is blocked by #28235 for now 👼

@stevvooe
Copy link
Contributor

@vdemeester Should be unblocked, now!

@vdemeester vdemeester force-pushed the images-filter-filters branch from 7883d0c to 6f3f4f6 Compare November 11, 2016 09:36
@vdemeester vdemeester removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Nov 11, 2016
@vdemeester
Copy link
Member Author

@stevvooe It is, PR rebased 👼

Copy link
Member

@cpuguy83 cpuguy83 left a 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") != "" {
Copy link
Member

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]>
@stevvooe
Copy link
Contributor

LGTM

@thaJeztah
Copy link
Member

ping @AkihiroSuda;

15:35:31 ----------------------------------------------------------------------
15:35:31 FAIL: docker_cli_prune_unix_test.go:26: DockerSwarmSuite.TestPruneNetwork
15:35:31 
15:35:31 [dfc709b8ed9a0] waiting for daemon to start
15:35:31 [dfc709b8ed9a0] daemon started
15:35:31 docker_cli_prune_unix_test.go:31:
15:35:31     c.Assert(err, checker.IsNil)
15:35:31 ... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc42310d720), Stderr:[]uint8(nil)} ("exit status 1")
15:35:31 
15:35:31 [dfc709b8ed9a0] exiting daemon
15:35:34 
15:35:34 ----------------------------------------------------------------------

@@ -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>]`)
Copy link
Member

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;

Copy link
Member Author

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 😉

@cpuguy83 cpuguy83 merged commit de32553 into moby:master Nov 11, 2016
@vdemeester vdemeester deleted the images-filter-filters branch November 11, 2016 16:28
@AkihiroSuda
Copy link
Member

@thaJeztah ah, it is discussed in #27938 I will try to find the solution ASAP..

@thaJeztah
Copy link
Member

@AkihiroSuda ah! yes, no problem, just wanted to let you know 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants