Skip to content

Commit

Permalink
Merge pull request containers#12663 from vrothberg/compat-normalization
Browse files Browse the repository at this point in the history
compat: image normalization: handle sha256 prefix
  • Loading branch information
openshift-merge-robot authored Dec 21, 2021
2 parents f3d6672 + b1f5e86 commit 253fddb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/api/handlers/utils/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NormalizeToDockerHub(r *http.Request, nameOrID string) (string, error) {
if errors.Cause(err) != storage.ErrImageUnknown {
return "", fmt.Errorf("normalizing name for compat API: %v", err)
}
} else if strings.HasPrefix(img.ID(), nameOrID) {
} else if strings.HasPrefix(img.ID(), strings.TrimPrefix(nameOrID, "sha256:")) {
return img.ID(), nil
}

Expand Down
1 change: 1 addition & 0 deletions test/python/docker/compat/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def test_list_images(self):
# Add more images
self.client.images.pull(constant.BB)
self.assertEqual(len(self.client.images.list()), 2)
self.assertEqual(len(self.client.images.list(all=True)), 2)

# List images with filter
self.assertEqual(len(self.client.images.list(filters={"reference": "alpine"})), 1)
Expand Down

0 comments on commit 253fddb

Please sign in to comment.