(ctx context.Context, orgID, poolID string)
| 256 | } |
| 257 | |
| 258 | func (r *Runner) DeleteOrgPool(ctx context.Context, orgID, poolID string) error { |
| 259 | if !auth.IsAdmin(ctx) { |
| 260 | return runnerErrors.ErrUnauthorized |
| 261 | } |
| 262 | |
| 263 | entity := params.ForgeEntity{ |
| 264 | ID: orgID, |
| 265 | EntityType: params.ForgeEntityTypeOrganization, |
| 266 | } |
| 267 | |
| 268 | pool, err := r.store.GetEntityPool(ctx, entity, poolID) |
| 269 | if err != nil { |
| 270 | if !errors.Is(err, runnerErrors.ErrNotFound) { |
| 271 | return fmt.Errorf("error fetching pool: %w", err) |
| 272 | } |
| 273 | return nil |
| 274 | } |
| 275 | |
| 276 | // nolint:golangci-lint,godox |
| 277 | // TODO: implement a count function |
| 278 | if len(pool.Instances) > 0 { |
| 279 | runnerIDs := []string{} |
| 280 | for _, run := range pool.Instances { |
| 281 | runnerIDs = append(runnerIDs, run.ID) |
| 282 | } |
| 283 | return runnerErrors.NewBadRequestError("pool has runners: %s", strings.Join(runnerIDs, ", ")) |
| 284 | } |
| 285 | |
| 286 | if err := r.store.DeleteEntityPool(ctx, entity, poolID); err != nil { |
| 287 | return fmt.Errorf("error deleting pool: %w", err) |
| 288 | } |
| 289 | return nil |
| 290 | } |
| 291 | |
| 292 | func (r *Runner) ListOrgPools(ctx context.Context, orgID string) ([]params.Pool, error) { |
| 293 | if !auth.IsAdmin(ctx) { |
nothing calls this directly
no test coverage detected