Browse code

Moved parseRepositoryTag to the utils package

Sam Alba authored on 2013/07/10 00:06:10
Showing 3 changed files
... ...
@@ -52,7 +52,7 @@ func (b *buildFile) CmdFrom(name string) error {
52 52
 	image, err := b.runtime.repositories.LookupImage(name)
53 53
 	if err != nil {
54 54
 		if b.runtime.graph.IsNotExist(err) {
55
-			remote, tag := parseRepositoryTag(name)
55
+			remote, tag := utils.ParseRepositoryTag(name)
56 56
 			if err := b.srv.ImagePull(remote, tag, b.out, utils.NewStreamFormatter(false), nil); err != nil {
57 57
 				return err
58 58
 			}
... ...
@@ -754,20 +754,6 @@ func (cli *DockerCli) CmdPush(args ...string) error {
754 754
 	return nil
755 755
 }
756 756
 
757
-// Get a repos name and returns the right reposName + tag
758
-// The tag can be confusing because of a port in a repository name.
759
-//     Ex: localhost.localdomain:5000/samalba/hipache:latest
760
-func parseRepositoryTag(repos string) (string, string) {
761
-	n := strings.LastIndex(repos, ":")
762
-	if n < 0 {
763
-		return repos, ""
764
-	}
765
-	if tag := repos[n+1:]; !strings.Contains(tag, "/") {
766
-		return repos[:n], tag
767
-	}
768
-	return repos, ""
769
-}
770
-
771 757
 func (cli *DockerCli) CmdPull(args ...string) error {
772 758
 	cmd := Subcmd("pull", "NAME", "Pull an image or a repository from the registry")
773 759
 	tag := cmd.String("t", "", "Download tagged image in repository")
... ...
@@ -780,7 +766,7 @@ func (cli *DockerCli) CmdPull(args ...string) error {
780 780
 		return nil
781 781
 	}
782 782
 
783
-	remote, parsedTag := parseRepositoryTag(cmd.Arg(0))
783
+	remote, parsedTag := utils.ParseRepositoryTag(cmd.Arg(0))
784 784
 	*tag = parsedTag
785 785
 
786 786
 	v := url.Values{}
... ...
@@ -686,3 +686,17 @@ func ParseHost(host string, port int, addr string) string {
686 686
 	}
687 687
 	return fmt.Sprintf("tcp://%s:%d", host, port)
688 688
 }
689
+
690
+// Get a repos name and returns the right reposName + tag
691
+// The tag can be confusing because of a port in a repository name.
692
+//     Ex: localhost.localdomain:5000/samalba/hipache:latest
693
+func ParseRepositoryTag(repos string) (string, string) {
694
+	n := strings.LastIndex(repos, ":")
695
+	if n < 0 {
696
+		return repos, ""
697
+	}
698
+	if tag := repos[n+1:]; !strings.Contains(tag, "/") {
699
+		return repos[:n], tag
700
+	}
701
+	return repos, ""
702
+}