MCPcopy Create free account
hub / github.com/cloudbase/garm / GetEntityRunnerGroupIDByName

Method GetEntityRunnerGroupIDByName

util/github/client.go:459–489  ·  view source on GitHub ↗
(ctx context.Context, runnerGroupName string)

Source from the content-addressed store, hash-verified

457}
458
459func (g *githubClient) GetEntityRunnerGroupIDByName(ctx context.Context, runnerGroupName string) (int64, error) {
460 var rgID int64 = 1
461
462 if g.entity.EntityType == params.ForgeEntityTypeRepository {
463 // This is a repository. Runner groups are supported at the org and
464 // enterprise levels. Return the default runner group id, early.
465 return rgID, nil
466 }
467
468 var ok bool
469 var err error
470 // attempt to get the runner group ID from cache. Cache will invalidate after 1 hour.
471 if runnerGroupName != "" && !strings.EqualFold(runnerGroupName, "default") {
472 rgID, ok = cache.GetEntityRunnerGroup(g.entity.ID, runnerGroupName)
473 if !ok || rgID == 0 {
474 switch g.entity.EntityType {
475 case params.ForgeEntityTypeOrganization:
476 rgID, err = g.getOrganizationRunnerGroupIDByName(ctx, g.entity, runnerGroupName)
477 case params.ForgeEntityTypeEnterprise:
478 rgID, err = g.getEnterpriseRunnerGroupIDByName(ctx, g.entity, runnerGroupName)
479 }
480
481 if err != nil {
482 return 0, fmt.Errorf("getting runner group ID: %w", err)
483 }
484 }
485 // set cache. Avoid getting the same runner group for more than once an hour.
486 cache.SetEntityRunnerGroup(g.entity.ID, runnerGroupName, rgID)
487 }
488 return rgID, nil
489}
490
491func (g *githubClient) GetEntityJITConfig(ctx context.Context, instance string, pool params.Pool, labels []string) (jitConfigMap map[string]string, runner *github.Runner, err error) {
492 rgID, err := g.GetEntityRunnerGroupIDByName(ctx, pool.GitHubRunnerGroup)

Callers 1

GetEntityJITConfigMethod · 0.95

Tested by

no test coverage detected