compat: image normalization: handle sha256 prefix
When normalizing image names on the compat API, make sure to take the `sha256:` prefix into account when matching against the image ID. Otherwise, the name will mistakingly be subject to docker.io normalization. Signed-off-by: Valentin Rothberg <rothberg@redhat.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
76d32a1eb9
commit
b1f5e861b0
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ class TestImages(unittest.TestCase):
|
|||
# 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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue