Improve reference parse errors

Fixes #18093

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2015-12-09 23:31:38 -08:00
Родитель c1040b222c
Коммит 15d84a3a48
5 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -4614,7 +4614,7 @@ func (s *DockerSuite) TestBuildInvalidTag(c *check.C) {
_, out, err := buildImageWithOut(name, "FROM scratch\nMAINTAINER quux\n", true)
// if the error doesn't check for illegal tag name, or the image is built
// then this should fail
if !strings.Contains(out, "invalid reference format") || strings.Contains(out, "Sending build context to Docker daemon") {
if !strings.Contains(out, "Error parsing reference") || strings.Contains(out, "Sending build context to Docker daemon") {
c.Fatalf("failed to stop before building. Error: %s, Output: %s", err, out)
}
}

Просмотреть файл

@ -265,7 +265,7 @@ func (s *DockerSuite) TestCreateByImageID(c *check.C) {
c.Fatalf("expected non-zero exit code; received %d", exit)
}
if expected := "invalid reference format"; !strings.Contains(out, expected) {
if expected := "Error parsing reference"; !strings.Contains(out, expected) {
c.Fatalf(`Expected %q in output; got: %s`, expected, out)
}

Просмотреть файл

@ -3758,8 +3758,8 @@ func (s *DockerSuite) TestRunInvalidReference(c *check.C) {
c.Fatalf("expected non-zero exist code; received %d", exit)
}
if !strings.Contains(out, "invalid reference format") {
c.Fatalf(`Expected "invalid reference format" in output; got: %s`, out)
if !strings.Contains(out, "Error parsing reference") {
c.Fatalf(`Expected "Error parsing reference" in output; got: %s`, out)
}
}

Просмотреть файл

@ -99,17 +99,17 @@ func (s *DockerSuite) TestTagWithPrefixHyphen(c *check.C) {
// test repository name begin with '-'
out, _, err := dockerCmdWithError("tag", "busybox:latest", "-busybox:test")
c.Assert(err, checker.NotNil, check.Commentf(out))
c.Assert(out, checker.Contains, "invalid reference format", check.Commentf("tag a name begin with '-' should failed"))
c.Assert(out, checker.Contains, "Error parsing reference", check.Commentf("tag a name begin with '-' should failed"))
// test namespace name begin with '-'
out, _, err = dockerCmdWithError("tag", "busybox:latest", "-test/busybox:test")
c.Assert(err, checker.NotNil, check.Commentf(out))
c.Assert(out, checker.Contains, "invalid reference format", check.Commentf("tag a name begin with '-' should failed"))
c.Assert(out, checker.Contains, "Error parsing reference", check.Commentf("tag a name begin with '-' should failed"))
// test index name begin with '-'
out, _, err = dockerCmdWithError("tag", "busybox:latest", "-index:5000/busybox:test")
c.Assert(err, checker.NotNil, check.Commentf(out))
c.Assert(out, checker.Contains, "invalid reference format", check.Commentf("tag a name begin with '-' should failed"))
c.Assert(out, checker.Contains, "Error parsing reference", check.Commentf("tag a name begin with '-' should failed"))
}
// ensure tagging using official names works

Просмотреть файл

@ -54,7 +54,7 @@ type Canonical interface {
func ParseNamed(s string) (Named, error) {
named, err := distreference.ParseNamed(s)
if err != nil {
return nil, err
return nil, fmt.Errorf("Error parsing reference: %q is not a valid repository/tag", s)
}
r, err := WithName(named.Name())
if err != nil {