(ctx context.Context)
| 343 | } |
| 344 | |
| 345 | func (g *githubClient) CreateEntityRegistrationToken(ctx context.Context) (*github.RegistrationToken, *github.Response, error) { |
| 346 | var ret *github.RegistrationToken |
| 347 | var response *github.Response |
| 348 | var err error |
| 349 | |
| 350 | metrics.GithubOperationCount.WithLabelValues( |
| 351 | "CreateEntityRegistrationToken", // label: operation |
| 352 | g.entity.LabelScope(), // label: scope |
| 353 | ).Inc() |
| 354 | defer func() { |
| 355 | if err != nil { |
| 356 | metrics.GithubOperationFailedCount.WithLabelValues( |
| 357 | "CreateEntityRegistrationToken", // label: operation |
| 358 | g.entity.LabelScope(), // label: scope |
| 359 | ).Inc() |
| 360 | } |
| 361 | }() |
| 362 | |
| 363 | switch g.entity.EntityType { |
| 364 | case params.ForgeEntityTypeRepository: |
| 365 | ret, response, err = g.CreateRegistrationToken(ctx, g.entity.Owner, g.entity.Name) |
| 366 | case params.ForgeEntityTypeOrganization: |
| 367 | ret, response, err = g.CreateOrganizationRegistrationToken(ctx, g.entity.Owner) |
| 368 | case params.ForgeEntityTypeEnterprise: |
| 369 | ret, response, err = g.enterprise.CreateRegistrationToken(ctx, g.entity.Owner) |
| 370 | default: |
| 371 | return nil, nil, errors.New("invalid entity type") |
| 372 | } |
| 373 | if err == nil && response != nil { |
| 374 | g.recordLimits(response.Rate) |
| 375 | } |
| 376 | |
| 377 | return ret, response, err |
| 378 | } |
| 379 | |
| 380 | func (g *githubClient) getOrganizationRunnerGroupIDByName(ctx context.Context, entity params.ForgeEntity, rgName string) (int64, error) { |
| 381 | opts := github.ListOrgRunnerGroupOptions{ |
nothing calls this directly
no test coverage detected