Merge pull request #12663 from vrothberg/compat-normalization

compat: image normalization: handle sha256 prefix
This commit is contained in:
OpenShift Merge Robot
2021-12-21 16:00:22 +01:00
committed by GitHub
2 changed files with 2 additions and 1 deletions

View File

@ -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
}

View File

@ -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)