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

Method findByID

app/controlplane/pkg/data/casmapping.go:182–201  ·  view source on GitHub ↗

FindByID finds a CAS Mapping by ID If not found, returns nil and no error

(ctx context.Context, id uuid.UUID)

Source from the content-addressed store, hash-verified

180// FindByID finds a CAS Mapping by ID
181// If not found, returns nil and no error
182func (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
203func (r *CASMappingRepo) IsPublic(ctx context.Context, client *ent.Client, runID uuid.UUID) (bool, error) {
204 ctx, span := otelx.Start(ctx, casMappingRepoTracer, "CASMappingRepo.IsPublic")

Callers 1

CreateMethod · 0.95

Implementers 3

CASMappingRepoapp/controlplane/pkg/biz/mocks/CASMapp
CASMappingRepo_Expecterapp/controlplane/pkg/biz/mocks/CASMapp
CASMappingRepoapp/controlplane/pkg/data/casmapping.g

Calls 9

IsPublicMethod · 0.95
IDFunction · 0.92
IsNotFoundFunction · 0.92
NewErrNotFoundFunction · 0.92
entCASMappingToBizFunction · 0.85
WithCasBackendMethod · 0.80
OnlyMethod · 0.45
WhereMethod · 0.45
QueryMethod · 0.45

Tested by

no test coverage detected