Merge pull request #878 from vrothberg/manifest-lookup
image lookup: apply checks for matching digest
This commit is contained in:
commit
7ed3a21c3c
|
|
@ -14,8 +14,9 @@ import (
|
||||||
func TestImageFunctions(t *testing.T) {
|
func TestImageFunctions(t *testing.T) {
|
||||||
// Note: this will resolve pull from the GCR registry (see
|
// Note: this will resolve pull from the GCR registry (see
|
||||||
// testdata/registries.conf).
|
// testdata/registries.conf).
|
||||||
busyboxLatest := "docker.io/library/busybox:latest"
|
busybox := "docker.io/library/busybox"
|
||||||
busyboxDigest := "docker.io/library/busybox@"
|
busyboxLatest := busybox + ":latest"
|
||||||
|
busyboxDigest := busybox + "@"
|
||||||
|
|
||||||
runtime, cleanup := testNewRuntime(t)
|
runtime, cleanup := testNewRuntime(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
@ -62,6 +63,14 @@ func TestImageFunctions(t *testing.T) {
|
||||||
require.Len(t, digests, 2)
|
require.Len(t, digests, 2)
|
||||||
require.Equal(t, origDigest.String(), digests[0].String(), "first recoreded digest should be the one of the image")
|
require.Equal(t, origDigest.String(), digests[0].String(), "first recoreded digest should be the one of the image")
|
||||||
|
|
||||||
|
// containers/podman/issues/12729: make sure manifest lookup returns
|
||||||
|
// the correct error for both digests.
|
||||||
|
for _, digest := range digests {
|
||||||
|
_, err := runtime.LookupManifestList(busybox + "@" + digest.String())
|
||||||
|
require.Error(t, err, "Manifest lookup should fail on an ordinary image")
|
||||||
|
require.Equal(t, ErrNotAManifestList, errors.Cause(err))
|
||||||
|
}
|
||||||
|
|
||||||
// Below mostly smoke tests.
|
// Below mostly smoke tests.
|
||||||
require.False(t, image.IsReadOnly())
|
require.False(t, image.IsReadOnly())
|
||||||
isDangling, err := image.IsDangling(ctx)
|
isDangling, err := image.IsDangling(ctx)
|
||||||
|
|
|
||||||
|
|
@ -406,9 +406,15 @@ func (r *Runtime) lookupImageInDigestsAndRepoTags(name string, options *LookupIm
|
||||||
digest := digested.Digest()
|
digest := digested.Digest()
|
||||||
for _, image := range allImages {
|
for _, image := range allImages {
|
||||||
for _, d := range image.Digests() {
|
for _, d := range image.Digests() {
|
||||||
if d == digest {
|
if d != digest {
|
||||||
return image, name, nil
|
continue
|
||||||
}
|
}
|
||||||
|
// Also make sure that the matching image fits all criteria (e.g., manifest list).
|
||||||
|
if _, err := r.lookupImageInLocalStorage(name, image.ID(), options); err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
return image, name, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, "", errors.Wrap(storage.ErrImageUnknown, name)
|
return nil, "", errors.Wrap(storage.ErrImageUnknown, name)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue