LoadNodeAll loads all instances on this server.
(s *state.State, instanceType instancetype.Type)
| 361 | |
| 362 | // LoadNodeAll loads all instances on this server. |
| 363 | func LoadNodeAll(s *state.State, instanceType instancetype.Type) ([]Instance, error) { |
| 364 | var err error |
| 365 | var instances []Instance |
| 366 | |
| 367 | filter := cluster.InstanceFilter{Type: instanceType.Filter()} |
| 368 | if s.ServerName != "" { |
| 369 | filter.Node = &s.ServerName |
| 370 | } |
| 371 | |
| 372 | err = s.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error { |
| 373 | return tx.InstanceList(ctx, func(dbInst db.InstanceArgs, p api.Project) error { |
| 374 | inst, err := Load(s, dbInst, p) |
| 375 | if err != nil { |
| 376 | return fmt.Errorf("Failed loading instance %q in project %q: %w", dbInst.Name, dbInst.Project, err) |
| 377 | } |
| 378 | |
| 379 | instances = append(instances, inst) |
| 380 | |
| 381 | return nil |
| 382 | }, filter) |
| 383 | }) |
| 384 | if err != nil { |
| 385 | return nil, err |
| 386 | } |
| 387 | |
| 388 | return instances, nil |
| 389 | } |
| 390 | |
| 391 | // LoadFromBackup loads from a mounted instance's backup file. |
| 392 | // If applyProfiles is false, then the profiles property will be cleared to prevent profile enrichment from DB. |
no test coverage detected
searching dependent graphs…