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

Method getPoolByID

database/sql/util.go:691–713  ·  view source on GitHub ↗
(tx *gorm.DB, poolID string, preload ...string)

Source from the content-addressed store, hash-verified

689}
690
691func (s *sqlDatabase) getPoolByID(tx *gorm.DB, poolID string, preload ...string) (Pool, error) {
692 u, err := uuid.Parse(poolID)
693 if err != nil {
694 return Pool{}, fmt.Errorf("error parsing id: %w", runnerErrors.ErrBadRequest)
695 }
696 var pool Pool
697 q := tx.Model(&Pool{})
698 if len(preload) > 0 {
699 for _, item := range preload {
700 q = q.Preload(item)
701 }
702 }
703
704 q = q.Where("id = ?", u).First(&pool)
705
706 if q.Error != nil {
707 if errors.Is(q.Error, gorm.ErrRecordNotFound) {
708 return Pool{}, runnerErrors.ErrNotFound
709 }
710 return Pool{}, fmt.Errorf("error fetching org from database: %w", q.Error)
711 }
712 return pool, nil
713}
714
715func (s *sqlDatabase) getScaleSetByID(tx *gorm.DB, scaleSetID uint, preload ...string) (ScaleSet, error) {
716 var scaleSet ScaleSet

Callers 5

GetPoolByIDMethod · 0.95
DeletePoolByIDMethod · 0.95
CreateInstanceMethod · 0.95
getPoolInstanceByNameMethod · 0.95
PoolInstanceCountMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected