(ctx context.Context, wr *ent.WorkflowRun)
| 566 | } |
| 567 | |
| 568 | func 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 |
no test coverage detected