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

Moved parseRepositoryTag to the utils package

This commit is contained in:
Sam Alba 2013-07-09 08:06:10 -07:00
parent 3be7bc38e0
commit 019324015b
3 changed files with 16 additions and 16 deletions

View file

@ -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
}

View file

@ -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{}

View file

@ -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, ""
}