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

Function entWrToBizWr

app/controlplane/pkg/data/workflowrun.go:568–616  ·  view source on GitHub ↗
(ctx context.Context, wr *ent.WorkflowRun)

Source from the content-addressed store, hash-verified

566}
567
568func entWrToBizWr(ctx context.Context, wr *ent.WorkflowRun) (*biz.WorkflowRun, error) {
569 r := &biz.WorkflowRun{
570 ID: wr.ID,
571 CreatedAt: toTimePtr(wr.CreatedAt),
572 FinishedAt: toTimePtr(wr.FinishedAt),
573 State: string(wr.State),
574 Reason: wr.Reason,
575 RunURL: wr.RunURL,
576 RunnerType: wr.RunnerType,
577 CASBackends: make([]*biz.CASBackend, 0),
578 ContractRevisionUsed: wr.ContractRevisionUsed,
579 ContractRevisionLatest: wr.ContractRevisionLatest,
580 HasPolicyViolations: wr.HasPolicyViolations,
581 PolicyStatus: entWrPolicySummary(wr),
582 Attestation: &biz.Attestation{
583 Digest: wr.AttestationDigest,
584 },
585 }
586
587 if wr.Attestation != nil {
588 r.Attestation.Envelope = wr.Attestation
589 }
590
591 if cv := wr.Edges.ContractVersion; cv != nil {
592 r.ContractVersionID = cv.ID
593 }
594
595 if wf := wr.Edges.Workflow; wf != nil {
596 w, err := entWFToBizWF(ctx, wf)
597 if err != nil {
598 return nil, fmt.Errorf("failed to convert workflow: %w", err)
599 }
600
601 r.Workflow = w
602 }
603
604 // Load version preloaded or otherwise query it
605 if wr.Edges.Version != nil {
606 r.ProjectVersion = entProjectVersionToBiz(wr.Edges.Version)
607 }
608
609 if backends := wr.Edges.CasBackends; backends != nil {
610 for _, b := range backends {
611 r.CASBackends = append(r.CASBackends, entCASBackendToBiz(b))
612 }
613 }
614
615 return r, nil
616}
617
618// entWrPolicySummary builds the domain summary from the materialized columns.
619// Returns nil when the row predates the materialization change (all columns

Callers 7

entWFToBizWFFunction · 0.85
CreateMethod · 0.85
FindByIDMethod · 0.85
FindByIDInOrgMethod · 0.85
ListMethod · 0.85

Calls 5

entWrPolicySummaryFunction · 0.85
entWFToBizWFFunction · 0.85
entProjectVersionToBizFunction · 0.85
entCASBackendToBizFunction · 0.85
toTimePtrFunction · 0.70

Tested by

no test coverage detected