Merge pull request #88 from infosiftr/docker-push-on-index

Fix fetchRegistryImageIds (which is only used for "docker push" no-op) to no longer return members of an index/manifest list
This commit is contained in:
Tianon Gravi 2023-12-01 10:57:06 -08:00 committed by GitHub
commit 36b3473420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -28,6 +28,12 @@ func fetchRegistryImageIds(image string) []string {
return ids
}
ids := []string{}
if img.IsImageIndex() {
ids = append(ids, digest)
return ids // see note above -- this function is used for "docker push" which does not and cannot (currently) support a manifest list / image index
}
manifests, err := img.Manifests(ctx)
if err != nil {
if debugFlag {
@ -36,10 +42,8 @@ func fetchRegistryImageIds(image string) []string {
return nil
}
ids := []string{}
if img.IsImageIndex() {
ids = append(ids, digest)
}
// TODO balk if manifests has more than one entry in it
for _, manifestDesc := range manifests {
ids = append(ids, manifestDesc.Digest.String())
manifest, err := img.At(manifestDesc).Manifest(ctx)