Skip to content

Commit 9c08364

Browse files
committed
add --all-tags to pull & pull latest by default
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <[email protected]> (github: unclejack)
1 parent 58dc474 commit 9c08364

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

api/client/commands.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ func (cli *DockerCli) CmdPush(args ...string) error {
11921192

11931193
func (cli *DockerCli) CmdPull(args ...string) error {
11941194
cmd := cli.Subcmd("pull", "NAME[:TAG]", "Pull an image or a repository from the registry")
1195-
tag := cmd.String([]string{"#t", "#-tag"}, "", "Download tagged image in a repository")
1195+
allTags := cmd.Bool([]string{"a", "-all-tags"}, false, "Download all tagged images in the repository")
11961196
if err := cmd.Parse(args); err != nil {
11971197
return nil
11981198
}
@@ -1202,19 +1202,22 @@ func (cli *DockerCli) CmdPull(args ...string) error {
12021202
return nil
12031203
}
12041204
var (
1205-
v = url.Values{}
1206-
remote = cmd.Arg(0)
1205+
v = url.Values{}
1206+
remote = cmd.Arg(0)
1207+
newRemote = remote
12071208
)
1208-
1209-
v.Set("fromImage", remote)
1210-
1211-
if *tag == "" {
1212-
v.Set("tag", *tag)
1209+
taglessRemote, tag := parsers.ParseRepositoryTag(remote)
1210+
if tag == "" && !*allTags {
1211+
newRemote = taglessRemote + ":latest"
1212+
}
1213+
if tag != "" && *allTags {
1214+
return fmt.Errorf("tag can't be used with --all-tags/-a")
12131215
}
12141216

1215-
remote, _ = parsers.ParseRepositoryTag(remote)
1217+
v.Set("fromImage", newRemote)
1218+
12161219
// Resolve the Repository name from fqn to hostname + name
1217-
hostname, _, err := registry.ResolveRepositoryName(remote)
1220+
hostname, _, err := registry.ResolveRepositoryName(taglessRemote)
12181221
if err != nil {
12191222
return err
12201223
}

0 commit comments

Comments
 (0)