diff --git a/client/client_test.go b/client/client_test.go index c824172a2..70c28f21d 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -6489,24 +6489,22 @@ func testExportAttestations(t *testing.T, sb integration.Sandbox) { return nil, err } res.AddAttestation(pk, &result.InTotoAttestation{ - PredicateRefKey: "foo", - PredicatePath: "/attestation.json", - PredicateType: "https://example.com/attestations/v1.0", + PredicatePath: "/attestation.json", + PredicateType: "https://example.com/attestations/v1.0", Subjects: []result.InTotoSubject{ &result.InTotoSubjectSelf{}, }, - }, map[string]gateway.Reference{"foo": refAttest}) + }, refAttest) res.AddAttestation(pk, &result.InTotoAttestation{ - PredicateRefKey: "bar", - PredicatePath: "/attestation2.json", - PredicateType: "https://example.com/attestations2/v1.0", + PredicatePath: "/attestation2.json", + PredicateType: "https://example.com/attestations2/v1.0", Subjects: []result.InTotoSubject{ &result.InTotoSubjectRaw{ Name: "/attestation.json", Digest: []digest.Digest{successDigest}, }, }, - }, map[string]gateway.Reference{"bar": refAttest}) + }, refAttest) } dt, err := json.Marshal(expPlatforms) diff --git a/solver/result/result.go b/solver/result/result.go index 1fa6c2ff6..6c5158c5c 100644 --- a/solver/result/result.go +++ b/solver/result/result.go @@ -39,23 +39,19 @@ func (r *Result[T]) AddRef(k string, ref T) { r.mu.Unlock() } -func (r *Result[T]) AddAttestation(k string, v Attestation, refs map[string]T) { +func (r *Result[T]) AddAttestation(k string, v Attestation, ref T) { r.mu.Lock() if r.Attestations == nil { r.Attestations = map[string][]Attestation{} } - - // if the attestation refs aren't already internal, then insert them switch v := v.(type) { case *InTotoAttestation: if !strings.HasPrefix(v.PredicateRefKey, attestationRefPrefix) { - internalKey := attestationRefPrefix + identity.NewID() - r.Refs[internalKey] = refs[v.PredicateRefKey] - v.PredicateRefKey = internalKey + v.PredicateRefKey = "attestation:" + identity.NewID() + r.Refs[v.PredicateRefKey] = ref } } r.Attestations[k] = append(r.Attestations[k], v) - r.mu.Unlock() }