MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / renderReference

Function renderReference

pkg/attestation/renderer/chainloop/v02.go:455–474  ·  view source on GitHub ↗
(ref *v1.PolicyEvaluation_Reference)

Source from the content-addressed store, hash-verified

453}
454
455func renderReference(ref *v1.PolicyEvaluation_Reference) (*intoto.ResourceDescriptor, error) {
456 // skip empty references
457 if ref == nil {
458 return nil, nil
459 }
460
461 annotations, err := structpb.NewStruct(map[string]interface{}{"name": ref.GetName(), "organization": ref.GetOrgName()})
462 if err != nil {
463 // Struct raise errors in some conditions (when a field is not UTF8, for example). We need to handle them, although it's a remote possibility
464 return nil, err
465 }
466 return &intoto.ResourceDescriptor{
467 Name: ref.GetName(),
468 Uri: ref.GetUri(),
469 Digest: map[string]string{
470 "sha256": strings.TrimPrefix(ref.GetDigest(), "sha256:"),
471 },
472 Annotations: annotations,
473 }, nil
474}
475
476func outputMaterials(att *v1.Attestation, onlyOutput bool) ([]*intoto.ResourceDescriptor, error) {
477 // Sort material keys to stabilize output

Callers 1

renderEvaluationFunction · 0.85

Calls 4

GetNameMethod · 0.65
GetOrgNameMethod · 0.45
GetUriMethod · 0.45
GetDigestMethod · 0.45

Tested by

no test coverage detected