FindByID finds a CAS Mapping by ID If not found, returns nil and no error
(ctx context.Context, id uuid.UUID)
| 180 | // FindByID finds a CAS Mapping by ID |
| 181 | // If not found, returns nil and no error |
| 182 | func (r *CASMappingRepo) findByID(ctx context.Context, id uuid.UUID) (*biz.CASMapping, error) { |
| 183 | backend, err := r.data.DB.CASMapping.Query().WithCasBackend(). |
| 184 | Where(casmapping.ID(id)).Only(ctx) |
| 185 | if err != nil && !ent.IsNotFound(err) { |
| 186 | return nil, err |
| 187 | } else if backend == nil { |
| 188 | return nil, nil |
| 189 | } |
| 190 | |
| 191 | public, err := r.IsPublic(ctx, r.data.DB, backend.WorkflowRunID) |
| 192 | if err != nil { |
| 193 | if ent.IsNotFound(err) { |
| 194 | return nil, biz.NewErrNotFound("cas mapping") |
| 195 | } |
| 196 | |
| 197 | return nil, fmt.Errorf("failed to check if workflow is public: %w", err) |
| 198 | } |
| 199 | |
| 200 | return entCASMappingToBiz(backend, public) |
| 201 | } |
| 202 | |
| 203 | func (r *CASMappingRepo) IsPublic(ctx context.Context, client *ent.Client, runID uuid.UUID) (bool, error) { |
| 204 | ctx, span := otelx.Start(ctx, casMappingRepoTracer, "CASMappingRepo.IsPublic") |
no test coverage detected