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

Method ListPoolInstances

database/sql/instances.go:526–543  ·  view source on GitHub ↗
(_ context.Context, poolID string, outdatedOnly bool)

Source from the content-addressed store, hash-verified

524}
525
526func (s *sqlDatabase) ListPoolInstances(_ context.Context, poolID string, outdatedOnly bool) ([]params.Instance, error) {
527 u, err := uuid.Parse(poolID)
528 if err != nil {
529 return nil, fmt.Errorf("error parsing id: %w", runnerErrors.ErrBadRequest)
530 }
531
532 ret, err := s.listInstancesBatched(func(query *gorm.DB) *gorm.DB {
533 q := query.Where("pool_id = ?", u)
534 if outdatedOnly {
535 q = q.Where("instances.generation < (SELECT pools.generation FROM pools WHERE pools.id = instances.pool_id)")
536 }
537 return q
538 })
539 if err != nil {
540 return nil, fmt.Errorf("failed to list pool instances: %w", err)
541 }
542 return ret, nil
543}
544
545func (s *sqlDatabase) ListAllInstances(_ context.Context) ([]params.Instance, error) {
546 ret, err := s.listInstancesBatched(nil)

Callers

nothing calls this directly

Calls 1

listInstancesBatchedMethod · 0.95

Tested by

no test coverage detected