(ctx context.Context, digest string, casBackendID uuid.UUID, opts *biz.CASMappingCreateOpts)
| 49 | } |
| 50 | |
| 51 | func (r *CASMappingRepo) Create(ctx context.Context, digest string, casBackendID uuid.UUID, opts *biz.CASMappingCreateOpts) (*biz.CASMapping, error) { |
| 52 | ctx, span := otelx.Start(ctx, casMappingRepoTracer, "CASMappingRepo.Create") |
| 53 | defer span.End() |
| 54 | |
| 55 | casBackend, err := r.casBackendrepo.FindByID(ctx, casBackendID) |
| 56 | if err != nil { |
| 57 | return nil, fmt.Errorf("failed to find cas backend: %w", err) |
| 58 | } else if casBackend == nil { |
| 59 | return nil, fmt.Errorf("cas backend not found") |
| 60 | } |
| 61 | |
| 62 | query := r.data.DB.CASMapping.Create(). |
| 63 | SetDigest(digest). |
| 64 | SetCasBackendID(casBackendID). |
| 65 | SetOrganizationID(casBackend.OrganizationID) |
| 66 | |
| 67 | if opts != nil { |
| 68 | query.SetNillableProjectID(opts.ProjectID).SetNillableWorkflowRunID(opts.WorkflowRunID) |
| 69 | } |
| 70 | |
| 71 | mapping, err := query.Save(ctx) |
| 72 | if err != nil { |
| 73 | return nil, fmt.Errorf("failed to create casMapping: %w", err) |
| 74 | } |
| 75 | |
| 76 | // reload to get the edges |
| 77 | return r.findByID(ctx, mapping.ID) |
| 78 | } |
| 79 | |
| 80 | // FindByDigestInOrgs returns a single CAS mapping for the digest that is reachable through one of |
| 81 | // the given organizations, honouring project-level RBAC when projectIDs is provided for an org. The |
nothing calls this directly
no test coverage detected