(poolID string, instanceName string)
| 106 | } |
| 107 | |
| 108 | func (s *sqlDatabase) getPoolInstanceByName(poolID string, instanceName string) (Instance, error) { |
| 109 | pool, err := s.getPoolByID(s.conn, poolID) |
| 110 | if err != nil { |
| 111 | return Instance{}, fmt.Errorf("error fetching pool: %w", err) |
| 112 | } |
| 113 | |
| 114 | var instance Instance |
| 115 | q := s.conn.Model(&Instance{}). |
| 116 | Preload(clause.Associations). |
| 117 | Where("name = ? and pool_id = ?", instanceName, pool.ID). |
| 118 | First(&instance) |
| 119 | if q.Error != nil { |
| 120 | if errors.Is(q.Error, gorm.ErrRecordNotFound) { |
| 121 | return Instance{}, fmt.Errorf("error fetching pool instance by name: %w", runnerErrors.ErrNotFound) |
| 122 | } |
| 123 | return Instance{}, fmt.Errorf("error fetching pool instance by name: %w", q.Error) |
| 124 | } |
| 125 | |
| 126 | instance.Pool = pool |
| 127 | return instance, nil |
| 128 | } |
| 129 | |
| 130 | func (s *sqlDatabase) getInstance(_ context.Context, tx *gorm.DB, instanceNameOrID string, preload ...string) (Instance, error) { |
| 131 | var instance Instance |
no test coverage detected