Merge pull request #237 from gabriel-samfira/fix-jit-config-empty-group
Fix JIT config with empty runner group name
This commit is contained in:
commit
bb67ae5afe
2 changed files with 15 additions and 13 deletions
|
|
@ -96,7 +96,7 @@ type urls struct {
|
|||
}
|
||||
|
||||
func NewEntityPoolManager(ctx context.Context, entity params.GithubEntity, cfgInternal params.Internal, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) {
|
||||
ctx = garmUtil.WithContext(ctx, slog.Any("pool_mgr", entity), slog.Any("pool_type", params.GithubEntityTypeRepository))
|
||||
ctx = garmUtil.WithContext(ctx, slog.Any("pool_mgr", entity.String()), slog.Any("pool_type", params.GithubEntityTypeRepository))
|
||||
ghc, err := garmUtil.GithubClient(ctx, entity, cfgInternal.GithubCredentialsDetails)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting github client")
|
||||
|
|
|
|||
26
util/util.go
26
util/util.go
|
|
@ -320,7 +320,7 @@ func (g *githubClient) getOrganizationRunnerGroupIDByName(ctx context.Context, e
|
|||
}
|
||||
opts.Page = ghResp.NextPage
|
||||
}
|
||||
return 0, runnerErrors.NewNotFoundError("runner group not found")
|
||||
return 0, runnerErrors.NewNotFoundError("runner group %s not found", rgName)
|
||||
}
|
||||
|
||||
func (g *githubClient) getEnterpriseRunnerGroupIDByName(ctx context.Context, entity params.GithubEntity, rgName string) (int64, error) {
|
||||
|
|
@ -360,19 +360,21 @@ func (g *githubClient) getEnterpriseRunnerGroupIDByName(ctx context.Context, ent
|
|||
}
|
||||
|
||||
func (g *githubClient) GetEntityJITConfig(ctx context.Context, instance string, pool params.Pool, labels []string) (jitConfigMap map[string]string, runner *github.Runner, err error) {
|
||||
var rgID int64
|
||||
// If no runner group is set, use the default runner group ID. This is also the default for
|
||||
// repository level runners.
|
||||
var rgID int64 = 1
|
||||
|
||||
switch g.entity.EntityType {
|
||||
case params.GithubEntityTypeRepository:
|
||||
rgID = 1
|
||||
case params.GithubEntityTypeOrganization:
|
||||
rgID, err = g.getOrganizationRunnerGroupIDByName(ctx, g.entity, pool.GitHubRunnerGroup)
|
||||
case params.GithubEntityTypeEnterprise:
|
||||
rgID, err = g.getEnterpriseRunnerGroupIDByName(ctx, g.entity, pool.GitHubRunnerGroup)
|
||||
}
|
||||
if pool.GitHubRunnerGroup != "" {
|
||||
switch g.entity.EntityType {
|
||||
case params.GithubEntityTypeOrganization:
|
||||
rgID, err = g.getOrganizationRunnerGroupIDByName(ctx, g.entity, pool.GitHubRunnerGroup)
|
||||
case params.GithubEntityTypeEnterprise:
|
||||
rgID, err = g.getEnterpriseRunnerGroupIDByName(ctx, g.entity, pool.GitHubRunnerGroup)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("getting runner group ID: %w", err)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("getting runner group ID: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
req := github.GenerateJITConfigRequest{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue