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

Remove support for referencing images by 'repository:shortid'

The `repository:shortid` syntax for referencing images is very little used,
collides with with tag references can be confused with digest references.

The `repository:shortid` notation was deprecated in Docker 1.13 through
5fc71599a0, and scheduled for removal
in Docker 17.12.

This patch removes the support for this notation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2017-12-13 14:00:01 -08:00
parent 1cea9d3bdb
commit a942c92dd7
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
3 changed files with 4 additions and 47 deletions

View file

@ -6,7 +6,6 @@ import (
"github.com/docker/distribution/reference"
"github.com/docker/docker/image"
"github.com/docker/docker/pkg/stringid"
)
// errImageDoesNotExist is error returned when no image can be found for a reference.
@ -59,21 +58,6 @@ func (daemon *Daemon) GetImageIDAndOS(refOrID string) (image.ID, string, error)
return id, imageOS, nil
}
// deprecated: repo:shortid https://github.com/docker/docker/pull/799
if tagged, ok := namedRef.(reference.Tagged); ok {
if tag := tagged.Tag(); stringid.IsShortID(stringid.TruncateID(tag)) {
for platform := range daemon.stores {
if id, err := daemon.stores[platform].imageStore.Search(tag); err == nil {
for _, storeRef := range daemon.referenceStore.References(id.Digest()) {
if storeRef.Name() == namedRef.Name() {
return id, platform, nil
}
}
}
}
}
}
// Search based on ID
for os := range daemon.stores {
if id, err := daemon.stores[os].imageStore.Search(refOrID); err == nil {

View file

@ -268,7 +268,6 @@ func (s *DockerSuite) TestCreateByImageID(c *check.C) {
dockerCmd(c, "create", imageID)
dockerCmd(c, "create", truncatedImageID)
dockerCmd(c, "create", fmt.Sprintf("%s:%s", imageName, truncatedImageID))
// Ensure this fails
out, exit, _ := dockerCmdWithError("create", fmt.Sprintf("%s:%s", imageName, imageID))
@ -280,7 +279,10 @@ func (s *DockerSuite) TestCreateByImageID(c *check.C) {
c.Fatalf(`Expected %q in output; got: %s`, expected, out)
}
out, exit, _ = dockerCmdWithError("create", fmt.Sprintf("%s:%s", "wrongimage", truncatedImageID))
if i := strings.IndexRune(imageID, ':'); i >= 0 {
imageID = imageID[i+1:]
}
out, exit, _ = dockerCmdWithError("create", fmt.Sprintf("%s:%s", "wrongimage", imageID))
if exit == 0 {
c.Fatalf("expected non-zero exit code; received %d", exit)
}

View file

@ -1,13 +1,10 @@
package main
import (
"fmt"
"strings"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/testutil"
"github.com/docker/docker/pkg/stringid"
"github.com/go-check/check"
)
@ -140,29 +137,3 @@ func (s *DockerSuite) TestTagInvalidRepoName(c *check.C) {
c.Fatal("tagging with image named \"sha256\" should have failed")
}
}
// ensure tags cannot create ambiguity with image ids
func (s *DockerSuite) TestTagTruncationAmbiguity(c *check.C) {
buildImageSuccessfully(c, "notbusybox:latest", build.WithDockerfile(`FROM busybox
MAINTAINER dockerio`))
imageID := getIDByName(c, "notbusybox:latest")
truncatedImageID := stringid.TruncateID(imageID)
truncatedTag := fmt.Sprintf("notbusybox:%s", truncatedImageID)
id := inspectField(c, truncatedTag, "Id")
// Ensure inspect by image id returns image for image id
c.Assert(id, checker.Equals, imageID)
c.Logf("Built image: %s", imageID)
// test setting tag fails
_, _, err := dockerCmdWithError("tag", "busybox:latest", truncatedTag)
if err != nil {
c.Fatalf("Error tagging with an image id: %s", err)
}
id = inspectField(c, truncatedTag, "Id")
// Ensure id is imageID and not busybox:latest
c.Assert(id, checker.Not(checker.Equals), imageID)
}