cmdValidate is a pre-flight: config parses, DB reachable, migrations applied, probe identity present. No round-trip.
(ctx context.Context, cfg config)
| 135 | // cmdValidate is a pre-flight: config parses, DB reachable, migrations applied, |
| 136 | // probe identity present. No round-trip. |
| 137 | func cmdValidate(ctx context.Context, cfg config) error { |
| 138 | if cfg.AgentEmail == "" { |
| 139 | return fmt.Errorf("E2A_PROBE_AGENT_EMAIL is required") |
| 140 | } |
| 141 | pool, err := openPool(ctx, cfg) |
| 142 | if err != nil { |
| 143 | return fmt.Errorf("db connect: %w", err) |
| 144 | } |
| 145 | defer pool.Close() |
| 146 | if err := pool.Ping(ctx); err != nil { |
| 147 | return fmt.Errorf("db ping: %w", err) |
| 148 | } |
| 149 | if err := migrationsApplied(ctx, pool); err != nil { |
| 150 | return fmt.Errorf("migrations: %w", err) |
| 151 | } |
| 152 | if _, err := identity.NewStore(pool).GetAgentByID(ctx, cfg.AgentEmail); err != nil { |
| 153 | return fmt.Errorf("probe agent %s not found (run `e2a-prober seed`): %w", cfg.AgentEmail, err) |
| 154 | } |
| 155 | fmt.Println("validate: ok (db reachable, migrations applied, probe identity present)") |
| 156 | return nil |
| 157 | } |
| 158 | |
| 159 | func (p *prober) mux() *http.ServeMux { |
| 160 | mux := http.NewServeMux() |