diff options
Diffstat (limited to 'pkg/api')
-rw-r--r-- | pkg/api/handlers/decoder.go | 15 | ||||
-rw-r--r-- | pkg/api/server/register_containers.go | 22 |
2 files changed, 28 insertions, 9 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 ( diff --git a/pkg/api/server/register_containers.go b/pkg/api/server/register_containers.go index ff1781d1e..2b8330d4c 100644 --- a/pkg/api/server/register_containers.go +++ b/pkg/api/server/register_containers.go @@ -1176,15 +1176,19 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // description: the name or ID of the container // - in: query // name: condition - // type: string - // description: | - // wait until container is to a given condition. default is stopped. valid conditions are: - // - configured - // - created - // - exited - // - paused - // - running - // - stopped + // type: array + // items: + // type: string + // enum: + // - configured + // - created + // - running + // - stopped + // - paused + // - exited + // - removing + // - stopping + // description: "Conditions to wait for. If no condition provided the 'exited' condition is assumed." // produces: // - application/json // responses: |