瀏覽代碼

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

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
unclejack 11 年之前
父節點
當前提交
9c08364a41
共有 1 個文件被更改,包括 13 次插入10 次删除
  1. 13 10
      api/client/commands.go

+ 13 - 10
api/client/commands.go

@@ -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{}
-		remote = cmd.Arg(0)
+		v         = url.Values{}
+		remote    = cmd.Arg(0)
+		newRemote = remote
 	)
 	)
-
-	v.Set("fromImage", remote)
-
-	if *tag == "" {
-		v.Set("tag", *tag)
+	taglessRemote, tag := parsers.ParseRepositoryTag(remote)
+	if tag == "" && !*allTags {
+		newRemote = taglessRemote + ":latest"
+	}
+	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
 	}
 	}