Skip to content

Commit

Permalink
Merge pull request #35790 from thaJeztah/image-shortid
Browse files Browse the repository at this point in the history
Remove support for referencing images by 'repository:shortid'
  • Loading branch information
thaJeztah committed Dec 15, 2017
2 parents a59061d + a942c92 commit 6796e74
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 47 deletions.
16 changes: 0 additions & 16 deletions daemon/image.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions integration-cli/docker_cli_create_test.go
Expand Up @@ -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))
Expand All @@ -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)
}
Expand Down
29 changes: 0 additions & 29 deletions integration-cli/docker_cli_tag_test.go
@@ -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"
)

Expand Down Expand Up @@ -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)
}

0 comments on commit 6796e74

Please sign in to comment.