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 {
return err
}
switch container.WaitCondition(r.Form.Get("condition")) {
case container.WaitConditionNextExit:
waitCondition = containerpkg.WaitConditionNextExit
case container.WaitConditionRemoved:
waitCondition = containerpkg.WaitConditionRemoved
legacyRemovalWaitPre134 = versions.LessThan(version, "1.34")
if v := r.Form.Get("condition"); v != "" {
switch container.WaitCondition(v) {
case container.WaitConditionNextExit:
waitCondition = containerpkg.WaitConditionNextExit
case container.WaitConditionRemoved:
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:
description: "Details of an error"
type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -7038,9 +7042,14 @@ paths:
- name: "condition"
in: "query"
description: |
Wait until a container state reaches the given condition, either
'not-running' (default), 'next-exit', or 'removed'.
Wait until a container state reaches the given condition.
Defaults to `not-running` if omitted or empty.
type: "string"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

@ -33,7 +33,9 @@ func (cli *Client) ContainerWait(ctx context.Context, containerID string, condit
errC := make(chan error, 1)
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)
if err != nil {

View file

@ -4389,6 +4389,10 @@ paths:
description: "Exit code of the container"
type: "integer"
x-nullable: false
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -4408,8 +4412,15 @@ paths:
type: "string"
- name: "condition"
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"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

@ -4459,6 +4459,10 @@ paths:
description: "Exit code of the container"
type: "integer"
x-nullable: false
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -4478,8 +4482,15 @@ paths:
type: "string"
- name: "condition"
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"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

@ -5696,6 +5696,10 @@ paths:
description: "Exit code of the container"
type: "integer"
x-nullable: false
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -5715,8 +5719,15 @@ paths:
type: "string"
- name: "condition"
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"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

@ -5701,6 +5701,10 @@ paths:
description: "Exit code of the container"
type: "integer"
x-nullable: false
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -5720,8 +5724,15 @@ paths:
type: "string"
- name: "condition"
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"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

@ -5737,6 +5737,10 @@ paths:
Message:
description: "Details of an error"
type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -5756,8 +5760,15 @@ paths:
type: "string"
- name: "condition"
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"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

@ -5724,6 +5724,10 @@ paths:
Message:
description: "Details of an error"
type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -5743,8 +5747,15 @@ paths:
type: "string"
- name: "condition"
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"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

@ -5748,6 +5748,10 @@ paths:
Message:
description: "Details of an error"
type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -5767,8 +5771,15 @@ paths:
type: "string"
- name: "condition"
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"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

@ -5775,6 +5775,10 @@ paths:
Message:
description: "Details of an error"
type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -5794,8 +5798,15 @@ paths:
type: "string"
- name: "condition"
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"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

@ -5836,6 +5836,10 @@ paths:
Message:
description: "Details of an error"
type: "string"
400:
description: "bad parameter"
schema:
$ref: "#/definitions/ErrorResponse"
404:
description: "no such container"
schema:
@ -5855,8 +5859,15 @@ paths:
type: "string"
- name: "condition"
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"
enum:
- "not-running"
- "next-exit"
- "removed"
default: "not-running"
tags: ["Container"]
/containers/{id}:

View file

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

View file

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

View file

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