(ctx context.Context, entity params.ForgeEntity, rgName string)
| 378 | } |
| 379 | |
| 380 | func (g *githubClient) getOrganizationRunnerGroupIDByName(ctx context.Context, entity params.ForgeEntity, rgName string) (int64, error) { |
| 381 | opts := github.ListOrgRunnerGroupOptions{ |
| 382 | ListOptions: github.ListOptions{ |
| 383 | PerPage: 100, |
| 384 | }, |
| 385 | } |
| 386 | |
| 387 | for { |
| 388 | metrics.GithubOperationCount.WithLabelValues( |
| 389 | "ListOrganizationRunnerGroups", // label: operation |
| 390 | entity.LabelScope(), // label: scope |
| 391 | ).Inc() |
| 392 | runnerGroups, ghResp, err := g.ListOrganizationRunnerGroups(ctx, entity.Owner, &opts) |
| 393 | if err != nil { |
| 394 | metrics.GithubOperationFailedCount.WithLabelValues( |
| 395 | "ListOrganizationRunnerGroups", // label: operation |
| 396 | entity.LabelScope(), // label: scope |
| 397 | ).Inc() |
| 398 | if ghResp != nil && ghResp.StatusCode == http.StatusUnauthorized { |
| 399 | return 0, fmt.Errorf("error fetching runners: %w", runnerErrors.ErrUnauthorized) |
| 400 | } |
| 401 | return 0, fmt.Errorf("error fetching runners: %w", err) |
| 402 | } |
| 403 | if ghResp != nil { |
| 404 | g.recordLimits(ghResp.Rate) |
| 405 | } |
| 406 | |
| 407 | for _, runnerGroup := range runnerGroups.RunnerGroups { |
| 408 | if runnerGroup.Name != nil && *runnerGroup.Name == rgName { |
| 409 | return *runnerGroup.ID, nil |
| 410 | } |
| 411 | } |
| 412 | if ghResp.NextPage == 0 { |
| 413 | break |
| 414 | } |
| 415 | opts.Page = ghResp.NextPage |
| 416 | } |
| 417 | return 0, runnerErrors.NewNotFoundError("runner group %s not found", rgName) |
| 418 | } |
| 419 | |
| 420 | func (g *githubClient) getEnterpriseRunnerGroupIDByName(ctx context.Context, entity params.ForgeEntity, rgName string) (int64, error) { |
| 421 | opts := github.ListEnterpriseRunnerGroupOptions{ |
no test coverage detected