(att *v1.Attestation, onlyOutput bool)
| 474 | } |
| 475 | |
| 476 | func 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 |
| 512 | func (p *ProvenancePredicateV02) GetMaterials() []*NormalizedMaterial { |
no test coverage detected