summaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-18 11:13:31 -0500
committerGitHub <noreply@github.com>2021-02-18 11:13:31 -0500
commitb2bb05d598452f7653e5b9311e3bd844b767cb26 (patch)
tree9a86f5fd20924b275ecc45c3b8480804e6b5258b /pkg/api
parentc3419d2168415cb3e6f1349afaa9c04c29cbb933 (diff)
parente022c19753182cfb85f8f49354d493ee3a3147a3 (diff)
downloadpodman-b2bb05d598452f7653e5b9311e3bd844b767cb26.tar.gz
podman-b2bb05d598452f7653e5b9311e3bd844b767cb26.tar.bz2
podman-b2bb05d598452f7653e5b9311e3bd844b767cb26.zip
Merge pull request #9414 from edigaryev/fix-wait-api-condition
API: fix libpod's container wait endpoint condition conversion
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/handlers/decoder.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/api/handlers/decoder.go b/pkg/api/handlers/decoder.go
index 54087168a..123d325aa 100644
--- a/pkg/api/handlers/decoder.go
+++ b/pkg/api/handlers/decoder.go
@@ -6,6 +6,7 @@ import (
"syscall"
"time"
+ "github.com/containers/podman/v2/libpod/define"
"github.com/containers/podman/v2/pkg/util"
"github.com/gorilla/schema"
"github.com/sirupsen/logrus"
@@ -19,6 +20,7 @@ func NewAPIDecoder() *schema.Decoder {
d.IgnoreUnknownKeys(true)
d.RegisterConverter(map[string][]string{}, convertURLValuesString)
d.RegisterConverter(time.Time{}, convertTimeString)
+ d.RegisterConverter(define.ContainerStatus(0), convertContainerStatusString)
var Signal syscall.Signal
d.RegisterConverter(Signal, convertSignal)
@@ -46,6 +48,19 @@ func convertURLValuesString(query string) reflect.Value {
return reflect.ValueOf(f)
}
+func convertContainerStatusString(query string) reflect.Value {
+ result, err := define.StringToContainerStatus(query)
+ if err != nil {
+ logrus.Infof("convertContainerStatusString: Failed to parse %s: %s", query, err.Error())
+
+ // We return nil here instead of result because reflect.ValueOf().IsValid() will be true
+ // in github.com/gorilla/schema's decoder, which means there's no parsing error
+ return reflect.ValueOf(nil)
+ }
+
+ return reflect.ValueOf(result)
+}
+
// isZero() can be used to determine if parsing failed.
func convertTimeString(query string) reflect.Value {
var (