(ctx context.Context, entity params.ForgeEntity, rgName string)
| 418 | } |
| 419 | |
| 420 | func (g *githubClient) getEnterpriseRunnerGroupIDByName(ctx context.Context, entity params.ForgeEntity, rgName string) (int64, error) { |
| 421 | opts := github.ListEnterpriseRunnerGroupOptions{ |
| 422 | ListOptions: github.ListOptions{ |
| 423 | PerPage: 100, |
| 424 | }, |
| 425 | } |
| 426 | |
| 427 | for { |
| 428 | metrics.GithubOperationCount.WithLabelValues( |
| 429 | "ListRunnerGroups", // label: operation |
| 430 | entity.LabelScope(), // label: scope |
| 431 | ).Inc() |
| 432 | runnerGroups, ghResp, err := g.enterprise.ListRunnerGroups(ctx, entity.Owner, &opts) |
| 433 | if err != nil { |
| 434 | metrics.GithubOperationFailedCount.WithLabelValues( |
| 435 | "ListRunnerGroups", // label: operation |
| 436 | entity.LabelScope(), // label: scope |
| 437 | ).Inc() |
| 438 | if ghResp != nil && ghResp.StatusCode == http.StatusUnauthorized { |
| 439 | return 0, fmt.Errorf("error fetching runners: %w", runnerErrors.ErrUnauthorized) |
| 440 | } |
| 441 | return 0, fmt.Errorf("error fetching runners: %w", err) |
| 442 | } |
| 443 | if ghResp != nil { |
| 444 | g.recordLimits(ghResp.Rate) |
| 445 | } |
| 446 | for _, runnerGroup := range runnerGroups.RunnerGroups { |
| 447 | if runnerGroup.Name != nil && *runnerGroup.Name == rgName { |
| 448 | return *runnerGroup.ID, nil |
| 449 | } |
| 450 | } |
| 451 | if ghResp.NextPage == 0 { |
| 452 | break |
| 453 | } |
| 454 | opts.Page = ghResp.NextPage |
| 455 | } |
| 456 | return 0, runnerErrors.NewNotFoundError("runner group not found") |
| 457 | } |
| 458 | |
| 459 | func (g *githubClient) GetEntityRunnerGroupIDByName(ctx context.Context, runnerGroupName string) (int64, error) { |
| 460 | var rgID int64 = 1 |
no test coverage detected