1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #43235 from thaJeztah/api_wait_fixes

Assorted (documentation) fixes for `POST /containers/{id}/wait`
This commit is contained in:
Brian Goff 2022-02-23 15:13:18 -08:00 committed by GitHub
commit 7c764a29b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 167 additions and 24 deletions

View file

@ -336,12 +336,16 @@ func (s *containerRouter) postContainersWait(ctx context.Context, w http.Respons
if err := httputils.ParseForm(r); err != nil { if err := httputils.ParseForm(r); err != nil {
return err return err
} }
switch container.WaitCondition(r.Form.Get("condition")) { if v := r.Form.Get("condition"); v != "" {
case container.WaitConditionNextExit: switch container.WaitCondition(v) {
waitCondition = containerpkg.WaitConditionNextExit case container.WaitConditionNextExit:
case container.WaitConditionRemoved: waitCondition = containerpkg.WaitConditionNextExit
waitCondition = containerpkg.WaitConditionRemoved case container.WaitConditionRemoved:
legacyRemovalWaitPre134 = versions.LessThan(version, "1.34") waitCondition = containerpkg.WaitConditionRemoved
legacyRemovalWaitPre134 = versions.LessThan(version, "1.34")
default:
return errdefs.InvalidParameter(errors.Errorf("invalid condition: %q", v))
}
} }
} }

View file

@ -7018,6 +7018,10 @@ paths:
Message: Message:
description: "Details of an error" description: "Details of an error"
type: "string" type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -7038,9 +7042,14 @@ paths:
- name: "condition" - name: "condition"
in: "query" in: "query"
description: | description: |
Wait until a container state reaches the given condition, either Wait until a container state reaches the given condition.
'not-running' (default), 'next-exit', or 'removed'.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -33,7 +33,9 @@ func (cli *Client) ContainerWait(ctx context.Context, containerID string, condit
errC := make(chan error, 1) errC := make(chan error, 1)
query := url.Values{} query := url.Values{}
query.Set("condition", string(condition)) if condition != "" {
query.Set("condition", string(condition))
}
resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", query, nil, nil) resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", query, nil, nil)
if err != nil { if err != nil {

View file

@ -4389,6 +4389,10 @@ paths:
description: "Exit code of the container" description: "Exit code of the container"
type: "integer" type: "integer"
x-nullable: false x-nullable: false
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -4408,8 +4412,15 @@ paths:
type: "string" type: "string"
- name: "condition" - name: "condition"
in: "query" in: "query"
description: "Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'." description: |
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -4459,6 +4459,10 @@ paths:
description: "Exit code of the container" description: "Exit code of the container"
type: "integer" type: "integer"
x-nullable: false x-nullable: false
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -4478,8 +4482,15 @@ paths:
type: "string" type: "string"
- name: "condition" - name: "condition"
in: "query" in: "query"
description: "Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'." description: |
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -5696,6 +5696,10 @@ paths:
description: "Exit code of the container" description: "Exit code of the container"
type: "integer" type: "integer"
x-nullable: false x-nullable: false
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -5715,8 +5719,15 @@ paths:
type: "string" type: "string"
- name: "condition" - name: "condition"
in: "query" in: "query"
description: "Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'." description: |
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -5701,6 +5701,10 @@ paths:
description: "Exit code of the container" description: "Exit code of the container"
type: "integer" type: "integer"
x-nullable: false x-nullable: false
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -5720,8 +5724,15 @@ paths:
type: "string" type: "string"
- name: "condition" - name: "condition"
in: "query" in: "query"
description: "Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'." description: |
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -5737,6 +5737,10 @@ paths:
Message: Message:
description: "Details of an error" description: "Details of an error"
type: "string" type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -5756,8 +5760,15 @@ paths:
type: "string" type: "string"
- name: "condition" - name: "condition"
in: "query" in: "query"
description: "Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'." description: |
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -5724,6 +5724,10 @@ paths:
Message: Message:
description: "Details of an error" description: "Details of an error"
type: "string" type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -5743,8 +5747,15 @@ paths:
type: "string" type: "string"
- name: "condition" - name: "condition"
in: "query" in: "query"
description: "Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'." description: |
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -5748,6 +5748,10 @@ paths:
Message: Message:
description: "Details of an error" description: "Details of an error"
type: "string" type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -5767,8 +5771,15 @@ paths:
type: "string" type: "string"
- name: "condition" - name: "condition"
in: "query" in: "query"
description: "Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'." description: |
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -5775,6 +5775,10 @@ paths:
Message: Message:
description: "Details of an error" description: "Details of an error"
type: "string" type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -5794,8 +5798,15 @@ paths:
type: "string" type: "string"
- name: "condition" - name: "condition"
in: "query" in: "query"
description: "Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'." description: |
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -5836,6 +5836,10 @@ paths:
Message: Message:
description: "Details of an error" description: "Details of an error"
type: "string" type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -5855,8 +5859,15 @@ paths:
type: "string" type: "string"
- name: "condition" - name: "condition"
in: "query" in: "query"
description: "Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'." description: |
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -6552,6 +6552,10 @@ paths:
Message: Message:
description: "Details of an error" description: "Details of an error"
type: "string" type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -6572,9 +6576,14 @@ paths:
- name: "condition" - name: "condition"
in: "query" in: "query"
description: | description: |
Wait until a container state reaches the given condition, either Wait until a container state reaches the given condition.
'not-running' (default), 'next-exit', or 'removed'.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -6850,6 +6850,10 @@ paths:
Message: Message:
description: "Details of an error" description: "Details of an error"
type: "string" type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -6870,9 +6874,14 @@ paths:
- name: "condition" - name: "condition"
in: "query" in: "query"
description: | description: |
Wait until a container state reaches the given condition, either Wait until a container state reaches the given condition.
'not-running' (default), 'next-exit', or 'removed'.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -7018,6 +7018,10 @@ paths:
Message: Message:
description: "Details of an error" description: "Details of an error"
type: "string" type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404: 404:
description: "no such container" description: "no such container"
schema: schema:
@ -7038,9 +7042,14 @@ paths:
- name: "condition" - name: "condition"
in: "query" in: "query"
description: | description: |
Wait until a container state reaches the given condition, either Wait until a container state reaches the given condition.
'not-running' (default), 'next-exit', or 'removed'.
Defaults to `not-running` if omitted or empty.
type: "string" type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running" default: "not-running"
tags: ["Container"] tags: ["Container"]
/containers/{id}: /containers/{id}:

View file

@ -40,6 +40,8 @@ keywords: "API, Docker, rcli, REST, documentation"
was used and the architecture was ignored. If no `platform` option is set, the was used and the architecture was ignored. If no `platform` option is set, the
host's operating system and architecture as used as default. This change is not host's operating system and architecture as used as default. This change is not
versioned, and affects all API versions if the daemon has this patch. versioned, and affects all API versions if the daemon has this patch.
* The `POST /containers/{id}/wait` endpoint now returns a `400` status code if an
invalid `condition` is provided (on API 1.30 and up).
## v1.41 API changes ## v1.41 API changes