From 92e858914d1a3515ffa1017c5adaad3ef5d89f5b Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Mon, 17 May 2021 23:16:55 +0200 Subject: fix: response body of containers wait endpoint The `Error` part of response must be nil (or omitted) if no error occurred. Before this commit a zero value for the struct was returned. Signed-off-by: Matej Vasek --- pkg/api/handlers/types.go | 2 +- pkg/api/handlers/utils/containers.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'pkg/api/handlers') diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index 52d7633af..2ffd9b0cb 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -98,7 +98,7 @@ type BuildResult struct { type ContainerWaitOKBody struct { StatusCode int - Error struct { + Error *struct { Message string } } diff --git a/pkg/api/handlers/utils/containers.go b/pkg/api/handlers/utils/containers.go index 6c708f74e..fb1f8b7c1 100644 --- a/pkg/api/handlers/utils/containers.go +++ b/pkg/api/handlers/utils/containers.go @@ -75,18 +75,19 @@ func WaitContainerDocker(w http.ResponseWriter, r *http.Request) { } exitCode, err := waitDockerCondition(ctx, name, interval, condition) - msg := "" + var errStruct *struct{ Message string } if err != nil { logrus.Errorf("error while waiting on condition: %q", err) - msg = err.Error() + errStruct = &struct { + Message string + }{ + Message: err.Error(), + } } + responseData := handlers.ContainerWaitOKBody{ StatusCode: int(exitCode), - Error: struct { - Message string - }{ - Message: msg, - }, + Error: errStruct, } enc := json.NewEncoder(w) enc.SetEscapeHTML(true) -- cgit v1.2.3-54-g00ecf