Skip to content

Commit 6b8a773

Browse files
committed
Simplify signature retrieval by refactoring to use getOCIDescriptorContents
Signed-off-by: Ayato Tokubi <[email protected]>
1 parent d5221fe commit 6b8a773

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

image/oci/layout/oci_src.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"go.podman.io/image/v5/internal/private"
2121
"go.podman.io/image/v5/internal/signature"
2222
"go.podman.io/image/v5/manifest"
23-
"go.podman.io/image/v5/pkg/blobinfocache/none"
2423
"go.podman.io/image/v5/pkg/tlsclientconfig"
2524
"go.podman.io/image/v5/types"
2625
"go.podman.io/storage/pkg/fileutils"
@@ -256,26 +255,10 @@ func (s *ociImageSource) GetSignaturesWithFormat(ctx context.Context, instanceDi
256255

257256
signatures := make([]signature.Signature, 0, len(ociManifest.Layers))
258257
for _, layer := range ociManifest.Layers {
259-
layerBlob, _, err := s.GetBlob(ctx, types.BlobInfo{Digest: layer.Digest}, none.NoCache)
258+
payload, err := s.ref.getOCIDescriptorContents(layer.Digest, iolimits.MaxSignatureBodySize, s.sharedBlobDir)
260259
if err != nil {
261260
return nil, err
262261
}
263-
defer layerBlob.Close()
264-
payload, err := iolimits.ReadAtMost(layerBlob, iolimits.MaxSignatureBodySize)
265-
if err != nil {
266-
return nil, fmt.Errorf("reading blob %s in %s: %w", layer.Digest.String(), instanceDigest, err)
267-
}
268-
if err := layer.Digest.Validate(); err != nil {
269-
return nil, fmt.Errorf("invalid digest %q: %w", layer.Digest, err)
270-
}
271-
digestAlgorithm := layer.Digest.Algorithm()
272-
if !digestAlgorithm.Available() {
273-
return nil, fmt.Errorf("invalid digest %q: unsupported digest algorithm %q", layer.Digest.String(), digestAlgorithm.String())
274-
}
275-
actualDigest := digestAlgorithm.FromBytes(payload)
276-
if actualDigest != layer.Digest {
277-
return nil, fmt.Errorf("digest mismatch, expected %q, got %q", layer.Digest.String(), actualDigest.String())
278-
}
279262
signatures = append(signatures, signature.SigstoreFromComponents(layer.MediaType, payload, layer.Annotations))
280263
}
281264
return signatures, nil

0 commit comments

Comments
 (0)