@@ -32,9 +32,8 @@ import (
3232 "github.com/goharbor/harbor/src/pkg/registry"
3333)
3434
35- // Attestation manifests are stored inside the index next to the platform images
36- // they describe, linked by these annotations rather than by a distinct manifest
37- // media type. See
35+ // Attestations are linked to the images they describe by these annotations
36+ // rather than by a distinct manifest media type.
3837// https://github.com/moby/buildkit/blob/master/docs/attestations/attestation-storage.md
3938const (
4039 referenceTypeAnnotation = "vnd.docker.reference.type"
@@ -57,25 +56,22 @@ type inTotoSubject struct {
5756 Digest map [string ]string `json:"digest"`
5857}
5958
60- // InTotoAttestationClassifier classifies in-toto attestation manifests carried
61- // inside an index as accessories of the platform image they attest. BuildKit,
62- // Buildah and Podman all emit this layout, so the classifier is named after the
63- // attestation format rather than after any single producer.
59+ // InTotoAttestationClassifier classifies in-toto attestation manifests as
60+ // accessories of the image they attest. Named after the attestation format, not
61+ // its producer: BuildKit, Buildah and Podman all emit this layout.
6462type InTotoAttestationClassifier struct {
6563 artMgr artifact.Manager
6664 regCli registry.Client
6765}
6866
69- // NewInTotoAttestationClassifier returns a classifier for in-toto attestation
70- // manifests.
67+ // NewInTotoAttestationClassifier returns a classifier for in-toto attestations.
7168func NewInTotoAttestationClassifier (artMgr artifact.Manager , regCli registry.Client ) * InTotoAttestationClassifier {
7269 return & InTotoAttestationClassifier {
7370 artMgr : artMgr ,
7471 regCli : regCli ,
7572 }
7673}
7774
78- // Classify implements ChildClassifier.
7975func (c * InTotoAttestationClassifier ) Classify (ctx context.Context , repository string , descriptor v1.Descriptor , siblings []v1.Descriptor ) (* artifact.AccessoryCandidate , error ) {
8076 if ! isAttestationDescriptor (descriptor ) {
8177 //nolint:nilnil // descriptor is not an attestation
@@ -223,11 +219,9 @@ func digestInIndex(siblings []v1.Descriptor, digestRef string) bool {
223219 return false
224220}
225221
226- // uniqueDigestInIndex returns the one sibling digest the subject matches. A
227- // subject names a single artifact under several algorithms, so matching more
228- // than one sibling means the payload disagrees with the index and is not safe
229- // to attach. Rejecting the ambiguity also keeps the result independent of the
230- // map iteration order behind subjectDigests.
222+ // A subject names one artifact under several algorithms, so matching more than
223+ // one sibling means the payload disagrees with the index. Rejecting that also
224+ // keeps the result independent of subjectDigests' map iteration order.
231225func uniqueDigestInIndex (siblings []v1.Descriptor , digestRefs []string ) string {
232226 match := ""
233227 for _ , digestRef := range digestRefs {
0 commit comments