Signed-off-by: Vincent Demeester <vincent@sbr.pm>
| ... | ... |
@@ -63,10 +63,10 @@ func (cli *DockerCli) CmdPull(args ...string) error {
|
| 63 | 63 |
return cli.trustedPull(repoInfo, registryRef, authConfig, requestPrivilege) |
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 |
- return cli.imagePullPrivileged(authConfig, distributionRef.String(), requestPrivilege) |
|
| 66 |
+ return cli.imagePullPrivileged(authConfig, distributionRef.String(), requestPrivilege, *allTags) |
|
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 |
-func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc) error {
|
|
| 69 |
+func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc, all bool) error {
|
|
| 70 | 70 |
|
| 71 | 71 |
encodedAuth, err := encodeAuthToBase64(authConfig) |
| 72 | 72 |
if err != nil {
|
| ... | ... |
@@ -75,6 +75,7 @@ func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, ref strin |
| 75 | 75 |
options := types.ImagePullOptions{
|
| 76 | 76 |
RegistryAuth: encodedAuth, |
| 77 | 77 |
PrivilegeFunc: requestPrivilege, |
| 78 |
+ All: all, |
|
| 78 | 79 |
} |
| 79 | 80 |
|
| 80 | 81 |
responseBody, err := cli.client.ImagePull(context.Background(), ref, options) |
| ... | ... |
@@ -377,7 +377,7 @@ func (cli *DockerCli) trustedPull(repoInfo *registry.RepositoryInfo, ref registr |
| 377 | 377 |
if err != nil {
|
| 378 | 378 |
return err |
| 379 | 379 |
} |
| 380 |
- if err := cli.imagePullPrivileged(authConfig, ref.String(), requestPrivilege); err != nil {
|
|
| 380 |
+ if err := cli.imagePullPrivileged(authConfig, ref.String(), requestPrivilege, false); err != nil {
|
|
| 381 | 381 |
return err |
| 382 | 382 |
} |
| 383 | 383 |
|
| ... | ... |
@@ -237,6 +237,20 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) {
|
| 237 | 237 |
c.Assert(splitLatest, checker.DeepEquals, splitCurrent, check.Commentf("busybox:latest was changed after pulling all tags"))
|
| 238 | 238 |
} |
| 239 | 239 |
|
| 240 |
+// TestRunImplicitPullWithNoTagOnlyPullDefaultTag should pull implicitely only the default tag (latest) |
|
| 241 |
+func (s *DockerHubPullSuite) TestRunImplicitPullWithNoTagOnlyPullDefaultTag(c *check.C) {
|
|
| 242 |
+ // run with an image we don't have |
|
| 243 |
+ testRequires(c, DaemonIsLinux) |
|
| 244 |
+ out := s.Cmd(c, "run", "busybox") |
|
| 245 |
+ |
|
| 246 |
+ c.Assert(out, checker.Contains, "Unable to find image 'busybox:latest' locally") |
|
| 247 |
+ |
|
| 248 |
+ // There should be only one line for busybox, the one with busybox:latest |
|
| 249 |
+ outImageCmd := s.Cmd(c, "images", "busybox") |
|
| 250 |
+ splitOutImageCmd := strings.Split(strings.TrimSpace(outImageCmd), "\n") |
|
| 251 |
+ c.Assert(splitOutImageCmd, checker.HasLen, 2) |
|
| 252 |
+} |
|
| 253 |
+ |
|
| 240 | 254 |
// TestPullClientDisconnect kills the client during a pull operation and verifies that the operation |
| 241 | 255 |
// gets cancelled. |
| 242 | 256 |
// |