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

Method FindByOrgAndID

app/controlplane/pkg/data/group.go:308–324  ·  view source on GitHub ↗

FindByOrgAndID retrieves a group by its ID and org, ensuring it is not deleted.

(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID)

Source from the content-addressed store, hash-verified

306
307// FindByOrgAndID retrieves a group by its ID and org, ensuring it is not deleted.
308func (g GroupRepo) FindByOrgAndID(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID) (*biz.Group, error) {
309 ctx, span := otelx.Start(ctx, groupRepoTracer, "GroupRepo.FindByOrgAndID")
310 defer span.End()
311
312 entGroup, err := g.data.DB.Group.Query().
313 Where(group.DeletedAtIsNil(), group.ID(groupID), group.OrganizationID(orgID)).
314 WithOrganization().
315 Only(ctx)
316 if err != nil {
317 if ent.IsNotFound(err) {
318 return nil, biz.NewErrNotFound("group")
319 }
320 return nil, err
321 }
322
323 return entGroupToBiz(entGroup), nil
324}
325
326func (g GroupRepo) FindByOrgAndName(ctx context.Context, orgID uuid.UUID, name string) (*biz.Group, error) {
327 ctx, span := otelx.Start(ctx, groupRepoTracer, "GroupRepo.FindByOrgAndName")

Callers 2

CreateMethod · 0.95
UpdateMethod · 0.95

Implementers 1

GroupRepoapp/controlplane/pkg/data/group.go

Calls 11

StartFunction · 0.92
DeletedAtIsNilFunction · 0.92
IDFunction · 0.92
OrganizationIDFunction · 0.92
IsNotFoundFunction · 0.92
NewErrNotFoundFunction · 0.92
entGroupToBizFunction · 0.85
OnlyMethod · 0.45
WithOrganizationMethod · 0.45
WhereMethod · 0.45
QueryMethod · 0.45

Tested by

no test coverage detected