(ctx context.Context, repoID string, param params.CreatePoolParams)
| 244 | } |
| 245 | |
| 246 | func (r *Runner) CreateRepoPool(ctx context.Context, repoID string, param params.CreatePoolParams) (params.Pool, error) { |
| 247 | if !auth.IsAdmin(ctx) { |
| 248 | return params.Pool{}, runnerErrors.ErrUnauthorized |
| 249 | } |
| 250 | |
| 251 | createPoolParams, err := r.appendTagsToCreatePoolParams(param) |
| 252 | if err != nil { |
| 253 | return params.Pool{}, fmt.Errorf("error appending tags to create pool params: %w", err) |
| 254 | } |
| 255 | |
| 256 | if createPoolParams.RunnerBootstrapTimeout == 0 { |
| 257 | createPoolParams.RunnerBootstrapTimeout = appdefaults.DefaultRunnerBootstrapTimeout |
| 258 | } |
| 259 | |
| 260 | entity, err := r.store.GetForgeEntity(ctx, params.ForgeEntityTypeRepository, repoID) |
| 261 | if err != nil { |
| 262 | return params.Pool{}, fmt.Errorf("failed to get repo: %w", err) |
| 263 | } |
| 264 | |
| 265 | template, err := r.findTemplate(ctx, entity, param.OSType, param.TemplateID) |
| 266 | if err != nil { |
| 267 | return params.Pool{}, fmt.Errorf("failed to find suitable template: %w", err) |
| 268 | } |
| 269 | |
| 270 | createPoolParams.TemplateID = &template.ID |
| 271 | pool, err := r.store.CreateEntityPool(ctx, entity, createPoolParams) |
| 272 | if err != nil { |
| 273 | return params.Pool{}, fmt.Errorf("error creating pool: %w", err) |
| 274 | } |
| 275 | |
| 276 | return pool, nil |
| 277 | } |
| 278 | |
| 279 | func (r *Runner) GetRepoPoolByID(ctx context.Context, repoID, poolID string) (params.Pool, error) { |
| 280 | if !auth.IsAdmin(ctx) { |
nothing calls this directly
no test coverage detected