(ctx context.Context, instance params.Instance)
| 1000 | } |
| 1001 | |
| 1002 | func (r *Runner) getPoolManagerFromInstance(ctx context.Context, instance params.Instance) (common.PoolManager, error) { |
| 1003 | pool, err := r.store.GetPoolByID(ctx, instance.PoolID) |
| 1004 | if err != nil { |
| 1005 | return nil, fmt.Errorf("error fetching pool: %w", err) |
| 1006 | } |
| 1007 | |
| 1008 | var poolMgr common.PoolManager |
| 1009 | |
| 1010 | switch { |
| 1011 | case pool.RepoID != "": |
| 1012 | repo, err := r.store.GetRepositoryByID(ctx, pool.RepoID) |
| 1013 | if err != nil { |
| 1014 | return nil, fmt.Errorf("error fetching repo: %w", err) |
| 1015 | } |
| 1016 | poolMgr, err = r.findRepoPoolManager(repo.Owner, repo.Name, repo.Endpoint.Name) |
| 1017 | if err != nil { |
| 1018 | return nil, fmt.Errorf("error fetching pool manager for repo %s: %w", pool.RepoName, err) |
| 1019 | } |
| 1020 | case pool.OrgID != "": |
| 1021 | org, err := r.store.GetOrganizationByID(ctx, pool.OrgID) |
| 1022 | if err != nil { |
| 1023 | return nil, fmt.Errorf("error fetching org: %w", err) |
| 1024 | } |
| 1025 | poolMgr, err = r.findOrgPoolManager(org.Name, org.Endpoint.Name) |
| 1026 | if err != nil { |
| 1027 | return nil, fmt.Errorf("error fetching pool manager for org %s: %w", pool.OrgName, err) |
| 1028 | } |
| 1029 | case pool.EnterpriseID != "": |
| 1030 | enterprise, err := r.store.GetEnterpriseByID(ctx, pool.EnterpriseID) |
| 1031 | if err != nil { |
| 1032 | return nil, fmt.Errorf("error fetching enterprise: %w", err) |
| 1033 | } |
| 1034 | poolMgr, err = r.findEnterprisePoolManager(enterprise.Name, enterprise.Endpoint.Name) |
| 1035 | if err != nil { |
| 1036 | return nil, fmt.Errorf("error fetching pool manager for enterprise %s: %w", pool.EnterpriseName, err) |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | return poolMgr, nil |
| 1041 | } |
| 1042 | |
| 1043 | // DeleteRunner removes a runner from a pool. If forceDelete is true, GARM will ignore any provider errors |
| 1044 | // that may occur, and attempt to remove the runner from GitHub and then the database, regardless of provider |
no test coverage detected