enrichContractMaterialsV2 augments a V2 contract schema with the materials declared by its attached policy groups. The V2 schema is the one stored in the crafting state (and thus surfaced during `attestation status`/`add`) whenever it is present, so it must be enriched too. See issue #3222.
(ctx context.Context, schema *v1.CraftingSchemaV2, client pb.AttestationServiceClient, logger *zerolog.Logger)
| 385 | // the crafting state (and thus surfaced during `attestation status`/`add`) |
| 386 | // whenever it is present, so it must be enriched too. See issue #3222. |
| 387 | func enrichContractMaterialsV2(ctx context.Context, schema *v1.CraftingSchemaV2, client pb.AttestationServiceClient, logger *zerolog.Logger) error { |
| 388 | spec := schema.GetSpec() |
| 389 | if spec == nil { |
| 390 | return nil |
| 391 | } |
| 392 | |
| 393 | merged, err := mergePolicyGroupMaterials(ctx, spec.GetPolicyGroups(), spec.GetMaterials(), client, logger) |
| 394 | if err != nil { |
| 395 | return err |
| 396 | } |
| 397 | |
| 398 | spec.Materials = merged |
| 399 | |
| 400 | return nil |
| 401 | } |
| 402 | |
| 403 | // mergePolicyGroupMaterials returns the contract materials augmented with the |
| 404 | // materials contributed by the attached policy groups. Materials already |