mirror of https://github.com/docker/docs.git
Harmonize / across all name-related commands/Validate images names
Docker-DCO-1.1-Signed-off-by: Djibril Koné <kone.djibril@gmail.com> (github: enokd)
This commit is contained in:
parent
e38e977a04
commit
43c3ee3ba1
|
@ -207,6 +207,15 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||||
}
|
}
|
||||||
// Upload the build context
|
// Upload the build context
|
||||||
v := &url.Values{}
|
v := &url.Values{}
|
||||||
|
|
||||||
|
//Check if the given image name can be resolved
|
||||||
|
if *tag != "" {
|
||||||
|
repository, _ := utils.ParseRepositoryTag(*tag)
|
||||||
|
if _, _, err := registry.ResolveRepositoryName(repository); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
v.Set("t", *tag)
|
v.Set("t", *tag)
|
||||||
|
|
||||||
if *suppressOutput {
|
if *suppressOutput {
|
||||||
|
@ -1002,6 +1011,12 @@ func (cli *DockerCli) CmdImport(args ...string) error {
|
||||||
repository, tag = utils.ParseRepositoryTag(cmd.Arg(1))
|
repository, tag = utils.ParseRepositoryTag(cmd.Arg(1))
|
||||||
}
|
}
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
|
|
||||||
|
//Check if the given image name can be resolved
|
||||||
|
if _, _, err := registry.ResolveRepositoryName(repository); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
v.Set("repo", repository)
|
v.Set("repo", repository)
|
||||||
v.Set("tag", tag)
|
v.Set("tag", tag)
|
||||||
v.Set("fromSrc", src)
|
v.Set("fromSrc", src)
|
||||||
|
@ -1452,9 +1467,9 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
re := regexp.MustCompile("/{2}")
|
//Check if the given image name can be resolved
|
||||||
if re.MatchString(repository) {
|
if _, _, err := registry.ResolveRepositoryName(repository); err != nil {
|
||||||
return fmt.Errorf("Error: Bad image name. Please rename your image in the format <user>/<repo>")
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
|
@ -1745,6 +1760,11 @@ func (cli *DockerCli) CmdTag(args ...string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
|
|
||||||
|
//Check if the given image name can be resolved
|
||||||
|
if _, _, err := registry.ResolveRepositoryName(repository); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
v.Set("repo", repository)
|
v.Set("repo", repository)
|
||||||
v.Set("tag", tag)
|
v.Set("tag", tag)
|
||||||
|
|
||||||
|
|
|
@ -206,4 +206,8 @@ func TestValidRepositoryName(t *testing.T) {
|
||||||
t.Log("Repository name should be invalid")
|
t.Log("Repository name should be invalid")
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
if err := validateRepositoryName("docker///docker"); err == nil {
|
||||||
|
t.Log("Repository name should be invalid")
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue