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

Function enrichContractMaterialsV2

app/cli/pkg/action/attestation_init.go:387–401  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
387func 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

Callers 2

RunMethod · 0.85

Calls 4

GetMaterialsMethod · 0.65
GetSpecMethod · 0.45
GetPolicyGroupsMethod · 0.45

Tested by 1