Use distribution's ValidateRepositoryName for remote name validation.

Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
This commit is contained in:
Shishir Mahajan
2015-06-17 15:15:16 -04:00
parent 85d3b75dfd
commit b8301005ff
3 changed files with 15 additions and 41 deletions
+3 -3
View File
@@ -111,20 +111,20 @@ func (s *DockerSuite) TestTagExistedNameWithForce(c *check.C) {
}
}
func (s *DockerSuite) TestTagWithSuffixHyphen(c *check.C) {
func (s *DockerSuite) TestTagWithPrefixHyphen(c *check.C) {
if err := pullImageIfNotExist("busybox:latest"); err != nil {
c.Fatal("couldn't find the busybox:latest image locally and failed to pull it")
}
// test repository name begin with '-'
tagCmd := exec.Command(dockerBinary, "tag", "busybox:latest", "-busybox:test")
out, _, err := runCommandWithOutput(tagCmd)
if err == nil || !strings.Contains(out, "Invalid repository name (-busybox). Cannot begin or end with a hyphen") {
if err == nil || !strings.Contains(out, "repository name component must match") {
c.Fatal("tag a name begin with '-' should failed")
}
// test namespace name begin with '-'
tagCmd = exec.Command(dockerBinary, "tag", "busybox:latest", "-test/busybox:test")
out, _, err = runCommandWithOutput(tagCmd)
if err == nil || !strings.Contains(out, "Invalid namespace name (-test). Cannot begin or end with a hyphen") {
if err == nil || !strings.Contains(out, "repository name component must match") {
c.Fatal("tag a name begin with '-' should failed")
}
// test index name begin wiht '-'