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

Method UpdateEntityPool

database/sql/pools.go:405–433  ·  view source on GitHub ↗
(ctx context.Context, entity params.ForgeEntity, poolID string, param params.UpdatePoolParams)

Source from the content-addressed store, hash-verified

403}
404
405func (s *sqlDatabase) UpdateEntityPool(ctx context.Context, entity params.ForgeEntity, poolID string, param params.UpdatePoolParams) (updatedPool params.Pool, err error) {
406 var rowsAffected int64
407 defer func() {
408 if err == nil && rowsAffected > 0 {
409 s.sendNotify(common.PoolEntityType, common.UpdateOperation, updatedPool)
410 }
411 }()
412 err = s.conn.Transaction(func(tx *gorm.DB) error {
413 pool, err := s.getEntityPool(tx, entity.EntityType, entity.ID, poolID, "Tags", "Instances")
414 if err != nil {
415 return fmt.Errorf("error fetching pool: %w", err)
416 }
417
418 updatedPool, rowsAffected, err = s.updatePool(tx, pool, param)
419 if err != nil {
420 return fmt.Errorf("error updating pool: %w", err)
421 }
422 return nil
423 })
424 if err != nil {
425 return params.Pool{}, err
426 }
427
428 updatedPool, err = s.GetPoolByID(ctx, poolID)
429 if err != nil {
430 return params.Pool{}, err
431 }
432 return updatedPool, nil
433}
434
435func (s *sqlDatabase) ListEntityPools(_ context.Context, entity params.ForgeEntity) ([]params.Pool, error) {
436 pools, err := s.listEntityPools(s.conn, entity.EntityType, entity.ID, "Tags")

Callers 1

ensureTemplatesMethod · 0.95

Calls 4

sendNotifyMethod · 0.95
getEntityPoolMethod · 0.95
updatePoolMethod · 0.95
GetPoolByIDMethod · 0.95

Tested by

no test coverage detected