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

Method CreateRepoPool

runner/repositories.go:246–277  ·  view source on GitHub ↗
(ctx context.Context, repoID string, param params.CreatePoolParams)

Source from the content-addressed store, hash-verified

244}
245
246func (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
279func (r *Runner) GetRepoPoolByID(ctx context.Context, repoID, poolID string) (params.Pool, error) {
280 if !auth.IsAdmin(ctx) {

Callers

nothing calls this directly

Calls 5

findTemplateMethod · 0.95
IsAdminFunction · 0.92
GetForgeEntityMethod · 0.65
CreateEntityPoolMethod · 0.65

Tested by

no test coverage detected