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

Function pushToControlPlane

app/cli/pkg/action/attestation_push.go:306–323  ·  view source on GitHub ↗
(ctx context.Context, conn *grpc.ClientConn, bundle *protobundle.Bundle, workflowRunID string, markVersionAsReleased bool)

Source from the content-addressed store, hash-verified

304}
305
306func pushToControlPlane(ctx context.Context, conn *grpc.ClientConn, bundle *protobundle.Bundle, workflowRunID string, markVersionAsReleased bool) (string, error) {
307 encodedBundle, err := encodeBundle(bundle)
308 if err != nil {
309 return "", fmt.Errorf("encoding attestation: %w", err)
310 }
311
312 client := pb.NewAttestationServiceClient(conn)
313 resp, err := client.Store(ctx, &pb.AttestationServiceStoreRequest{
314 AttestationBundle: encodedBundle,
315 WorkflowRunId: workflowRunID,
316 MarkVersionAsReleased: &markVersionAsReleased,
317 })
318 if err != nil {
319 return "", fmt.Errorf("storing attestation: %w", err)
320 }
321
322 return resp.Result.Digest, nil
323}
324
325func encodeBundle(b *protobundle.Bundle) ([]byte, error) {
326 return protojson.Marshal(b)

Callers 1

RunMethod · 0.85

Calls 2

StoreMethod · 0.95
encodeBundleFunction · 0.85

Tested by

no test coverage detected