mirror of
https://github.com/containers/podman
synced 2024-10-20 01:03:51 +00:00
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 <mvasek@redhat.com>
This commit is contained in:
parent
353f04b53c
commit
92e858914d
|
@ -98,7 +98,7 @@ type BuildResult struct {
|
|||
|
||||
type ContainerWaitOKBody struct {
|
||||
StatusCode int
|
||||
Error struct {
|
||||
Error *struct {
|
||||
Message string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
responseData := handlers.ContainerWaitOKBody{
|
||||
StatusCode: int(exitCode),
|
||||
Error: struct {
|
||||
errStruct = &struct {
|
||||
Message string
|
||||
}{
|
||||
Message: msg,
|
||||
},
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
responseData := handlers.ContainerWaitOKBody{
|
||||
StatusCode: int(exitCode),
|
||||
Error: errStruct,
|
||||
}
|
||||
enc := json.NewEncoder(w)
|
||||
enc.SetEscapeHTML(true)
|
||||
|
|
|
@ -21,7 +21,9 @@ t POST "containers/${CTR}/wait?condition=non-existent-cond" 400
|
|||
|
||||
t POST "containers/${CTR}/wait?condition=not-running" 200
|
||||
|
||||
t POST "containers/${CTR}/wait?condition=next-exit" 200 &
|
||||
t POST "containers/${CTR}/wait?condition=next-exit" 200 \
|
||||
.StatusCode=0 \
|
||||
.Error=null &
|
||||
child_pid=$!
|
||||
podman start "${CTR}"
|
||||
wait "${child_pid}"
|
||||
|
|
|
@ -99,7 +99,7 @@ class ContainerTestCase(APITestCase):
|
|||
r = requests.post(self.podman_url + f"/v1.40/containers/{create['Id']}/wait")
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
wait = r.json()
|
||||
self.assertEqual(wait["StatusCode"], 0, wait["Error"]["Message"])
|
||||
self.assertEqual(wait["StatusCode"], 0, wait["Error"])
|
||||
|
||||
prune = requests.post(self.podman_url + "/v1.40/containers/prune")
|
||||
self.assertEqual(prune.status_code, 200, prune.status_code)
|
||||
|
|
Loading…
Reference in a new issue