From d86eaa704e51de33c7cd82dd4ca802c5737c7b0d Mon Sep 17 00:00:00 2001 From: Laurent Luce Date: Mon, 16 Sep 2024 16:29:10 -0400 Subject: [PATCH] feat: Add health error response (#224) Required by https://github.com/kurtosis-tech/kardinal-kontrol/pull/26 --- flake.lock | 6 +- .../api/golang/client/client.gen.go | 8 +++ .../api/golang/server/server.gen.go | 63 +++++++++++-------- .../api/typescript/client/types.d.ts | 1 + libs/cli-kontrol-api/specs/api.yaml | 2 + 5 files changed, 50 insertions(+), 30 deletions(-) diff --git a/flake.lock b/flake.lock index d56e2ec4..02d88662 100644 --- a/flake.lock +++ b/flake.lock @@ -43,11 +43,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1723556749, - "narHash": "sha256-+CHVZnTnIYRLYsARInHYoWkujzcRkLY/gXm3s5bE52o=", + "lastModified": 1726320982, + "narHash": "sha256-RuVXUwcYwaUeks6h3OLrEmg14z9aFXdWppTWPMTwdQw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4a92571f9207810b559c9eac203d1f4d79830073", + "rev": "8f7492cce28977fbf8bd12c72af08b1f6c7c3e49", "type": "github" }, "original": { diff --git a/libs/cli-kontrol-api/api/golang/client/client.gen.go b/libs/cli-kontrol-api/api/golang/client/client.gen.go index a8102b72..af1911b1 100644 --- a/libs/cli-kontrol-api/api/golang/client/client.gen.go +++ b/libs/cli-kontrol-api/api/golang/client/client.gen.go @@ -755,6 +755,7 @@ type GetHealthResponse struct { Body []byte HTTPResponse *http.Response JSON200 *string + JSON500 *Error } // Status returns HTTPResponse.Status @@ -1122,6 +1123,13 @@ func ParseGetHealthResponse(rsp *http.Response) (*GetHealthResponse, error) { } response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + } return response, nil diff --git a/libs/cli-kontrol-api/api/golang/server/server.gen.go b/libs/cli-kontrol-api/api/golang/server/server.gen.go index 6dc8d632..ab28f5f1 100644 --- a/libs/cli-kontrol-api/api/golang/server/server.gen.go +++ b/libs/cli-kontrol-api/api/golang/server/server.gen.go @@ -304,6 +304,15 @@ func (response GetHealth200JSONResponse) VisitGetHealthResponse(w http.ResponseW return json.NewEncoder(w).Encode(response) } +type GetHealth500JSONResponse struct{ ErrorJSONResponse } + +func (response GetHealth500JSONResponse) VisitGetHealthResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(500) + + return json.NewEncoder(w).Encode(response) +} + type PostTenantUuidDeployRequestObject struct { Uuid Uuid `json:"uuid"` Body *PostTenantUuidDeployJSONRequestBody @@ -951,33 +960,33 @@ func (sh *strictHandler) GetTenantUuidTopology(ctx echo.Context, uuid Uuid) erro // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/8xZ3W7buBJ+FYLnXMpWck4XWPium7S7RtMi2CQXi6IoGGkss5FIlqScGIHffUFSov4o", - "W95sU18EcKT5n48fZ+xnnPBCcAZMK7x4xoJIUoAGaf9b5fxxRlPzMQWVSCo05Qwv8PucPyKaAtN0RUHi", - "CFPzWBC9xhFmpAC88NoRlvC9pBJSvNCyhAirZA0FMWb1VhhRpSVlGd7tIqyhEDnRMHNW+p7NU8RXSK8B", - "1aJh911DxwVRlqGs7+6Wl7VvCYqXMhnxbfWPcbkzwkpwpsBW/p2UXJoPCWcamDYfiRA5TYgJJv6mTETP", - "LYtCcgFSU6cPtX43A2sWWedRP4YIFyobUylAKZIFtHbtLD9Xfr94MX7/DRLtEgzYNV4/cf2elyx9Qbah", - "Zv1ZNQgtL0O51v2buTej2uFa9bLuGotMPFNK4J0wrtHK1sAIuSxtYhd5qTTIWy54zrNtoM9pVpVAQ2E/", - "/FfCCi/wf+LmYMeVxfhdmoFJvoqMSEm25n/G0yOsfOJpwEqvJM5kVAU4rEaEbTCDhHJyD/mwH1fmMVoZ", - "8K4BGaPzUFerMzlQv11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ty8Vlh67tDZlY49b", + "Y4OV0zLlRwUHGSIob/JfK8oK1PiWIC4cN5dr9Ej1EhHUM38Mtfv+qOr22Y+2G8ftJbgi7hfvhX3fL1/z", + "d5n/w/JN9so1E7er9G6Knp7G11DgAxvBEeBqXd12A/aBVC+hgBfU7qRZ0hXxqME6bkKuCKMLcCy85Yct", + "qhCwXHDKNJKga8kUImVpO7EP9T1IBhpU+CU8jKn+EkTa/2qJKEOcAarqUtNZEG88aFuPZFcZfGwcfo1K", + "eJqtSVX+mG7q56Y2waquKiLXhvo98AHiHBaU2U7c5IC0kP/19uNVF3dNCuX6ZgM3TnAojy+R2mmutokH", + "+DaIH/EhDuPuhIN8RZW2I0kTWCh9M/sx5FH8Fcc6uHRgsxVy9Ks6rim52d6Kh6aHwWN3Sny9Tqatn7F3", + "zdpREH9bIc+9L6QHNTehXJqHT+4b68/pc/pfcqd1OwHzY+h2dOf73QS+bKR/DV3uqvLh98hYsbe3/oLL", + "ylp5DdA3m78DAAD//44ZfanMIAAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/libs/cli-kontrol-api/api/typescript/client/types.d.ts b/libs/cli-kontrol-api/api/typescript/client/types.d.ts index e917462e..063176e0 100644 --- a/libs/cli-kontrol-api/api/typescript/client/types.d.ts +++ b/libs/cli-kontrol-api/api/typescript/client/types.d.ts @@ -14,6 +14,7 @@ export interface paths { "application/json": string; }; }; + 500: components["responses"]["Error"]; }; }; }; diff --git a/libs/cli-kontrol-api/specs/api.yaml b/libs/cli-kontrol-api/specs/api.yaml index ce81d07c..8fdb849e 100644 --- a/libs/cli-kontrol-api/specs/api.yaml +++ b/libs/cli-kontrol-api/specs/api.yaml @@ -9,6 +9,8 @@ paths: description: For health check control get: responses: + "500": + $ref: "#/components/responses/Error" "200": description: Successful response content: