(ctx context.Context, client *scalingo.Client, databaseID string, check func(scalingo.DatabaseStatus) bool)
| 106 | } |
| 107 | |
| 108 | func waitForDatabaseStatus(ctx context.Context, client *scalingo.Client, databaseID string, check func(scalingo.DatabaseStatus) bool) error { |
| 109 | ticker := time.NewTicker(10 * time.Second) |
| 110 | defer ticker.Stop() |
| 111 | for range ticker.C { |
| 112 | db, err := client.Preview().DatabaseShow(ctx, databaseID) |
| 113 | if errors.Is(err, scalingo.ErrDatabaseNotFound) { |
| 114 | continue |
| 115 | } else if err != nil { |
| 116 | return errors.Wrapf(ctx, err, "get database %s status", databaseID) |
| 117 | } |
| 118 | if check(db.Database.Status) { |
| 119 | break |
| 120 | } |
| 121 | } |
| 122 | return nil |
| 123 | } |
no test coverage detected