1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

add --all-tags to pull & pull latest by default

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
unclejack 2014-08-27 15:38:12 +03:00
parent 58dc474e65
commit 9c08364a41

View file

@ -1192,7 +1192,7 @@ func (cli *DockerCli) CmdPush(args ...string) error {
func (cli *DockerCli) CmdPull(args ...string) error { func (cli *DockerCli) CmdPull(args ...string) error {
cmd := cli.Subcmd("pull", "NAME[:TAG]", "Pull an image or a repository from the registry") cmd := cli.Subcmd("pull", "NAME[:TAG]", "Pull an image or a repository from the registry")
tag := cmd.String([]string{"#t", "#-tag"}, "", "Download tagged image in a repository") allTags := cmd.Bool([]string{"a", "-all-tags"}, false, "Download all tagged images in the repository")
if err := cmd.Parse(args); err != nil { if err := cmd.Parse(args); err != nil {
return nil return nil
} }
@ -1202,19 +1202,22 @@ func (cli *DockerCli) CmdPull(args ...string) error {
return nil return nil
} }
var ( var (
v = url.Values{} v = url.Values{}
remote = cmd.Arg(0) remote = cmd.Arg(0)
newRemote = remote
) )
taglessRemote, tag := parsers.ParseRepositoryTag(remote)
v.Set("fromImage", remote) if tag == "" && !*allTags {
newRemote = taglessRemote + ":latest"
if *tag == "" { }
v.Set("tag", *tag) if tag != "" && *allTags {
return fmt.Errorf("tag can't be used with --all-tags/-a")
} }
remote, _ = parsers.ParseRepositoryTag(remote) v.Set("fromImage", newRemote)
// Resolve the Repository name from fqn to hostname + name // Resolve the Repository name from fqn to hostname + name
hostname, _, err := registry.ResolveRepositoryName(remote) hostname, _, err := registry.ResolveRepositoryName(taglessRemote)
if err != nil { if err != nil {
return err return err
} }