Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/cli/internal/action/attestation_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ func populateContractMaterials(inputSchemaMaterials []*pbc.CraftingSchema_Materi
if err := setMaterialValue(cm, materialResult); err != nil {
return fmt.Errorf("setting material value: %w", err)
}

// Update the expected annotations of the material stated on the contract with the ones in the attestation
updateMaterialAnnotations(cm, materialResult)
}

res.Materials = append(res.Materials, *materialResult)
Expand All @@ -277,6 +280,22 @@ func populateContractMaterials(inputSchemaMaterials []*pbc.CraftingSchema_Materi
return nil
}

// updateMaterialAnnotations iterates through all expected annotations for the material
// and attempts to find their corresponding values in the incoming attestation result.
func updateMaterialAnnotations(cm *v1.Attestation_Material, attsMaterial *AttestationStatusMaterial) {
// Loop through the expected annotations in the attestation material
for k := range cm.Annotations {
// Check if the annotation exists in the provided attestation material
for _, a := range attsMaterial.Annotations {
// If the annotation name matches, update its value
if a.Name == k {
a.Value = cm.Annotations[k]
break
}
}
}
}

// populateAdditionalMaterials populates the materials that are not defined in the contract schema
func populateAdditionalMaterials(attsMaterials map[string]*v1.Attestation_Material, res *AttestationStatusResult, visitedMaterials map[string]struct{}) error {
for name, m := range attsMaterials {
Expand Down
Loading