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

Function outputMaterials

pkg/attestation/renderer/chainloop/v02.go:476–509  ·  view source on GitHub ↗
(att *v1.Attestation, onlyOutput bool)

Source from the content-addressed store, hash-verified

474}
475
476func outputMaterials(att *v1.Attestation, onlyOutput bool) ([]*intoto.ResourceDescriptor, error) {
477 // Sort material keys to stabilize output
478 keys := make([]string, 0, len(att.GetMaterials()))
479 for k := range att.GetMaterials() {
480 keys = append(keys, k)
481 }
482
483 sort.Strings(keys)
484
485 res := []*intoto.ResourceDescriptor{}
486 materials := att.GetMaterials()
487 for _, mdefName := range keys {
488 mdef := materials[mdefName]
489
490 nMaterial, err := mdef.NormalizedOutput()
491 if err != nil {
492 return nil, fmt.Errorf("error normalizing material: %w", err)
493 }
494
495 // Skip if we are expecting to show only the materials marked as output
496 if onlyOutput && !nMaterial.IsOutput {
497 continue
498 }
499
500 material, err := mdef.CraftingStateToIntotoDescriptor(mdefName)
501 if err != nil {
502 return nil, fmt.Errorf("rendering material: %w", err)
503 }
504
505 res = append(res, material)
506 }
507
508 return res, nil
509}
510
511// Implement NormalizablePredicate interface
512func (p *ProvenancePredicateV02) GetMaterials() []*NormalizedMaterial {

Callers 2

subjectMethod · 0.85
predicateMethod · 0.85

Calls 4

StringsMethod · 0.80
NormalizedOutputMethod · 0.80
GetMaterialsMethod · 0.65

Tested by

no test coverage detected