From 019324015b0c64733ae4f39708aa49a08134cb48 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Tue, 9 Jul 2013 08:06:10 -0700 Subject: [PATCH] Moved parseRepositoryTag to the utils package --- buildfile.go | 2 +- commands.go | 16 +--------------- utils/utils.go | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/buildfile.go b/buildfile.go index febcaca8e..6e117b19e 100644 --- a/buildfile.go +++ b/buildfile.go @@ -52,7 +52,7 @@ func (b *buildFile) CmdFrom(name string) error { image, err := b.runtime.repositories.LookupImage(name) if err != nil { if b.runtime.graph.IsNotExist(err) { - remote, tag := parseRepositoryTag(name) + remote, tag := utils.ParseRepositoryTag(name) if err := b.srv.ImagePull(remote, tag, b.out, utils.NewStreamFormatter(false), nil); err != nil { return err } diff --git a/commands.go b/commands.go index 3134011c0..ec8615995 100644 --- a/commands.go +++ b/commands.go @@ -754,20 +754,6 @@ func (cli *DockerCli) CmdPush(args ...string) error { return nil } -// Get a repos name and returns the right reposName + tag -// The tag can be confusing because of a port in a repository name. -// Ex: localhost.localdomain:5000/samalba/hipache:latest -func parseRepositoryTag(repos string) (string, string) { - n := strings.LastIndex(repos, ":") - if n < 0 { - return repos, "" - } - if tag := repos[n+1:]; !strings.Contains(tag, "/") { - return repos[:n], tag - } - return repos, "" -} - func (cli *DockerCli) CmdPull(args ...string) error { cmd := Subcmd("pull", "NAME", "Pull an image or a repository from the registry") tag := cmd.String("t", "", "Download tagged image in repository") @@ -780,7 +766,7 @@ func (cli *DockerCli) CmdPull(args ...string) error { return nil } - remote, parsedTag := parseRepositoryTag(cmd.Arg(0)) + remote, parsedTag := utils.ParseRepositoryTag(cmd.Arg(0)) *tag = parsedTag v := url.Values{} diff --git a/utils/utils.go b/utils/utils.go index eee6685c8..df615844a 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -686,3 +686,17 @@ func ParseHost(host string, port int, addr string) string { } return fmt.Sprintf("tcp://%s:%d", host, port) } + +// Get a repos name and returns the right reposName + tag +// The tag can be confusing because of a port in a repository name. +// Ex: localhost.localdomain:5000/samalba/hipache:latest +func ParseRepositoryTag(repos string) (string, string) { + n := strings.LastIndex(repos, ":") + if n < 0 { + return repos, "" + } + if tag := repos[n+1:]; !strings.Contains(tag, "/") { + return repos[:n], tag + } + return repos, "" +}