1
0
mirror of https://github.com/moby/moby.git synced 2025-12-07 19:42:23 +03:00

check tag's validity before building.

When user passes an invalid tag to `docker build`
(i.e.  `docker build -t abcd:A0123456789B0123456789C0123456789 .`), check the
tag first and terminate-early so user can specify the tag again

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)
This commit is contained in:
Daniel, Dao Quang Minh
2014-09-29 05:52:13 -04:00
parent d142b18aab
commit 8833d800bf
4 changed files with 24 additions and 5 deletions

View File

@@ -2237,3 +2237,16 @@ func TestBuildOnBuildOutput(t *testing.T) {
logDone("build - onbuild output")
}
func TestBuildInvalidTag(t *testing.T) {
name := "abcd:A0123456789B0123456789C0123456789"
defer deleteImages(name)
_, out, err := buildImageWithOut(name, "FROM scratch\nMAINTAINER quux\n", true)
// if the error doesnt check for illegal tag name, or the image is built
// then this should fail
if !strings.Contains(err.Error(), "Illegal tag name") ||
strings.Contains(out, "Sending build context to Docker daemon") {
t.Fatalf("failed to stop before building. Error: %s, Output: %s", err, out)
}
logDone("build - invalid tag")
}