| 1439 | } |
| 1440 | |
| 1441 | func isCoderRunning(ctx context.Context, baseURL string) bool { |
| 1442 | ctx, cancel := context.WithTimeout(ctx, 2*time.Second) |
| 1443 | defer cancel() |
| 1444 | req, err := http.NewRequestWithContext(ctx, "GET", baseURL+"/api/v2/buildinfo", nil) |
| 1445 | if err != nil { |
| 1446 | return false |
| 1447 | } |
| 1448 | resp, err := http.DefaultClient.Do(req) |
| 1449 | if err != nil { |
| 1450 | return false |
| 1451 | } |
| 1452 | defer resp.Body.Close() |
| 1453 | var info struct{ Version string } |
| 1454 | if err := json.NewDecoder(resp.Body).Decode(&info); err != nil { |
| 1455 | return false |
| 1456 | } |
| 1457 | return info.Version != "" |
| 1458 | } |
| 1459 | |
| 1460 | // shellBool returns "1" for true and "0" for false (shell convention). |
| 1461 | func shellBool(b bool) string { //nolint:revive // trivial bool-to-string helper |