(ctx context.Context, entity params.ForgeEntity, poolID string, param params.UpdatePoolParams)
| 403 | } |
| 404 | |
| 405 | func (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 | |
| 435 | func (s *sqlDatabase) ListEntityPools(_ context.Context, entity params.ForgeEntity) ([]params.Pool, error) { |
| 436 | pools, err := s.listEntityPools(s.conn, entity.EntityType, entity.ID, "Tags") |
no test coverage detected