Skip to content

Commit e0912aa

Browse files
committed
fix incorrect endpoints
1 parent 83ad84f commit e0912aa

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ GOVET=$(GOCMD) vet
1717
BINARY_NAME=sdc
1818
BINARY_PATH=./cmd/controller
1919
BUILD_DIR=build
20-
VERSION?=$(shell git describe --tags --always 2>/dev/null || echo "dev")
20+
VERSION=0.0.0-dev
2121
GIT_COMMIT?=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
2222
BUILD_TIME?=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)
2323

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ SDC will ensure `postgres` and `redis` start first (in parallel), wait for healt
164164
- Response: `{"message": "Operations are now unblocked"}`
165165

166166
### Job Status
167-
- `GET /job_status/{job_id}` - Get job status
168-
- Response: `{"status": "pending|running|completed|failed"}`
167+
- `GET /job_status/{job_id}` - Get job details and status
168+
- Response: Full job object with status, results, and timing information
169169
- Returns `{"status": "not_found"}` with HTTP 404 if job doesn't exist
170170

171171
### Health

cmd/controller/helper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func runHelper(cmd *cobra.Command, args []string) error {
5151

5252
// Create client
5353
apiClient := client.NewClient(helperConfig.ControllerURL, log)
54+
apiClient.SetUserAgent("sdc/" + Version)
5455

5556
// Wait for controller to become ready
5657
log.Info("Waiting for controller to become ready")

internal/api/handlers.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ func (s *Server) HandleGetJobStatus(w http.ResponseWriter, r *http.Request) {
170170
return
171171
}
172172

173-
s.writeJSON(w, http.StatusOK, map[string]string{
174-
"status": string(job.Status),
175-
})
173+
s.writeJSON(w, http.StatusOK, job)
176174
}
177175

178176
// HandleHealth handles GET /health

internal/client/client.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import (
1414

1515
// Client represents an HTTP client for communicating with the controller server
1616
type Client struct {
17-
baseURL string
17+
baseURL string
1818
httpClient *http.Client
19-
logger *logger.Logger
19+
logger *logger.Logger
20+
userAgent string
2021
}
2122

2223
// NewClient creates a new controller client
@@ -26,10 +27,16 @@ func NewClient(baseURL string, logger *logger.Logger) *Client {
2627
httpClient: &http.Client{
2728
Timeout: 30 * time.Second,
2829
},
29-
logger: logger,
30+
logger: logger,
31+
userAgent: "sdc-client/1.0",
3032
}
3133
}
3234

35+
// SetUserAgent sets a custom User-Agent header for requests
36+
func (c *Client) SetUserAgent(userAgent string) {
37+
c.userAgent = userAgent
38+
}
39+
3340
// JobRequest represents a request to start or stop containers
3441
type JobRequest struct {
3542
Timeout int `json:"timeout"`
@@ -38,7 +45,7 @@ type JobRequest struct {
3845

3946
// JobResponse represents a job creation response
4047
type JobResponse struct {
41-
ID string `json:"id"`
48+
ID string `json:"job_id"`
4249
Status string `json:"status"`
4350
}
4451

@@ -105,7 +112,7 @@ func (c *Client) StopContainers(ctx context.Context, timeout int, ignore []strin
105112
// GetJob retrieves job status and results
106113
func (c *Client) GetJob(ctx context.Context, jobID string) (*Job, error) {
107114
var job Job
108-
if err := c.get(ctx, fmt.Sprintf("/jobs/%s", jobID), &job); err != nil {
115+
if err := c.get(ctx, fmt.Sprintf("/job_status/%s", jobID), &job); err != nil {
109116
return nil, err
110117
}
111118

@@ -198,6 +205,7 @@ func (c *Client) post(ctx context.Context, path string, body any, result any) er
198205
}
199206

200207
req.Header.Set("Content-Type", "application/json")
208+
req.Header.Set("User-Agent", c.userAgent)
201209

202210
resp, err := c.httpClient.Do(req)
203211
if err != nil {
@@ -225,6 +233,8 @@ func (c *Client) get(ctx context.Context, path string, result any) error {
225233
return fmt.Errorf("failed to create request: %w", err)
226234
}
227235

236+
req.Header.Set("User-Agent", c.userAgent)
237+
228238
resp, err := c.httpClient.Do(req)
229239
if err != nil {
230240
return fmt.Errorf("request failed: %w", err)

internal/client/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestClient_GetJob(t *testing.T) {
8888
log, _ := logger.New(true)
8989

9090
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
91-
assert.Equal(t, "/jobs/test-job-id", r.URL.Path)
91+
assert.Equal(t, "/job_status/test-job-id", r.URL.Path)
9292
assert.Equal(t, "GET", r.Method)
9393

9494
job := Job{

0 commit comments

Comments
 (0)