Fix #22240 do not pull all the tags implicitely

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2016-05-01 14:46:04 +02:00
parent ba901bb062
commit 54ebe42de9
No known key found for this signature in database
GPG key ID: 083CC6FD6EB699A3
3 changed files with 18 additions and 3 deletions

View file

@ -63,10 +63,10 @@ func (cli *DockerCli) CmdPull(args ...string) error {
return cli.trustedPull(repoInfo, registryRef, authConfig, requestPrivilege)
}
return cli.imagePullPrivileged(authConfig, distributionRef.String(), requestPrivilege)
return cli.imagePullPrivileged(authConfig, distributionRef.String(), requestPrivilege, *allTags)
}
func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc) error {
func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc, all bool) error {
encodedAuth, err := encodeAuthToBase64(authConfig)
if err != nil {
@ -75,6 +75,7 @@ func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, ref strin
options := types.ImagePullOptions{
RegistryAuth: encodedAuth,
PrivilegeFunc: requestPrivilege,
All: all,
}
responseBody, err := cli.client.ImagePull(context.Background(), ref, options)

View file

@ -377,7 +377,7 @@ func (cli *DockerCli) trustedPull(repoInfo *registry.RepositoryInfo, ref registr
if err != nil {
return err
}
if err := cli.imagePullPrivileged(authConfig, ref.String(), requestPrivilege); err != nil {
if err := cli.imagePullPrivileged(authConfig, ref.String(), requestPrivilege, false); err != nil {
return err
}

View file

@ -237,6 +237,20 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) {
c.Assert(splitLatest, checker.DeepEquals, splitCurrent, check.Commentf("busybox:latest was changed after pulling all tags"))
}
// TestRunImplicitPullWithNoTagOnlyPullDefaultTag should pull implicitely only the default tag (latest)
func (s *DockerHubPullSuite) TestRunImplicitPullWithNoTagOnlyPullDefaultTag(c *check.C) {
// run with an image we don't have
testRequires(c, DaemonIsLinux)
out := s.Cmd(c, "run", "busybox")
c.Assert(out, checker.Contains, "Unable to find image 'busybox:latest' locally")
// There should be only one line for busybox, the one with busybox:latest
outImageCmd := s.Cmd(c, "images", "busybox")
splitOutImageCmd := strings.Split(strings.TrimSpace(outImageCmd), "\n")
c.Assert(splitOutImageCmd, checker.HasLen, 2)
}
// TestPullClientDisconnect kills the client during a pull operation and verifies that the operation
// gets cancelled.
//