MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / cmdValidate

Function cmdValidate

cmd/e2a-prober/serve.go:137–157  ·  view source on GitHub ↗

cmdValidate is a pre-flight: config parses, DB reachable, migrations applied, probe identity present. No round-trip.

(ctx context.Context, cfg config)

Source from the content-addressed store, hash-verified

135// cmdValidate is a pre-flight: config parses, DB reachable, migrations applied,
136// probe identity present. No round-trip.
137func 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
159func (p *prober) mux() *http.ServeMux {
160 mux := http.NewServeMux()

Callers 2

TestCmdValidate_FailuresFunction · 0.85
mainFunction · 0.85

Calls 5

NewStoreFunction · 0.92
openPoolFunction · 0.85
migrationsAppliedFunction · 0.85
GetAgentByIDMethod · 0.80
CloseMethod · 0.45

Tested by 1

TestCmdValidate_FailuresFunction · 0.68