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

Method FindByID

app/controlplane/pkg/data/apitoken.go:73–85  ·  view source on GitHub ↗
(ctx context.Context, id uuid.UUID)

Source from the content-addressed store, hash-verified

71}
72
73func (r *APITokenRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.APIToken, error) {
74 ctx, span := otelx.Start(ctx, apiTokenRepoTracer, "APITokenRepo.FindByID")
75 defer span.End()
76
77 token, err := r.data.DB.APIToken.Query().Where(apitoken.ID(id)).WithOrganization().WithProject().WithWorkflow().Only(ctx)
78 if err != nil && !ent.IsNotFound(err) {
79 return nil, fmt.Errorf("getting APIToken: %w", err)
80 } else if token == nil {
81 return nil, nil
82 }
83
84 return entAPITokenToBiz(token), nil
85}
86
87func (r *APITokenRepo) FindByIDInOrg(ctx context.Context, orgID uuid.UUID, id uuid.UUID) (*biz.APIToken, error) {
88 ctx, span := otelx.Start(ctx, apiTokenRepoTracer, "APITokenRepo.FindByIDInOrg")

Callers 1

CreateMethod · 0.95

Implementers 3

APITokenRepoapp/controlplane/pkg/biz/mocks/APIToke
APITokenRepo_Expecterapp/controlplane/pkg/biz/mocks/APIToke
APITokenRepoapp/controlplane/pkg/data/apitoken.go

Calls 10

StartFunction · 0.92
IDFunction · 0.92
IsNotFoundFunction · 0.92
entAPITokenToBizFunction · 0.85
OnlyMethod · 0.45
WithWorkflowMethod · 0.45
WithProjectMethod · 0.45
WithOrganizationMethod · 0.45
WhereMethod · 0.45
QueryMethod · 0.45

Tested by

no test coverage detected