summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/utils
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2021-05-17 23:16:55 +0200
committerMatej Vasek <mvasek@redhat.com>2021-05-18 20:52:09 +0200
commit92e858914d1a3515ffa1017c5adaad3ef5d89f5b (patch)
treee6b00078d02aa5b4673699e0d2bb090d9f40106f /pkg/api/handlers/utils
parent353f04b53cd0a7c89ac8b2eb836eeb9c0dfa7b6a (diff)
downloadpodman-92e858914d1a3515ffa1017c5adaad3ef5d89f5b.tar.gz
podman-92e858914d1a3515ffa1017c5adaad3ef5d89f5b.tar.bz2
podman-92e858914d1a3515ffa1017c5adaad3ef5d89f5b.zip
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>
Diffstat (limited to 'pkg/api/handlers/utils')
-rw-r--r--pkg/api/handlers/utils/containers.go15
1 files changed, 8 insertions, 7 deletions
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)