Merge pull request #2353 from mildlyincompetent/improve-healthcheck

Handle `str` in setter for test on HealthCheck
This commit is contained in:
Joffrey F 2019-05-31 10:42:29 -07:00 committed by GitHub
commit 0f368939de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -14,7 +14,7 @@ class Healthcheck(DictType):
- Empty list: Inherit healthcheck from parent image - Empty list: Inherit healthcheck from parent image
- ``["NONE"]``: Disable healthcheck - ``["NONE"]``: Disable healthcheck
- ``["CMD", args...]``: exec arguments directly. - ``["CMD", args...]``: exec arguments directly.
- ``["CMD-SHELL", command]``: RUn command in the system's - ``["CMD-SHELL", command]``: Run command in the system's
default shell. default shell.
If a string is provided, it will be used as a ``CMD-SHELL`` If a string is provided, it will be used as a ``CMD-SHELL``
@ -23,9 +23,9 @@ class Healthcheck(DictType):
should be 0 or at least 1000000 (1 ms). should be 0 or at least 1000000 (1 ms).
timeout (int): The time to wait before considering the check to timeout (int): The time to wait before considering the check to
have hung. It should be 0 or at least 1000000 (1 ms). have hung. It should be 0 or at least 1000000 (1 ms).
retries (integer): The number of consecutive failures needed to retries (int): The number of consecutive failures needed to
consider a container as unhealthy. consider a container as unhealthy.
start_period (integer): Start period for the container to start_period (int): Start period for the container to
initialize before starting health-retries countdown in initialize before starting health-retries countdown in
nanoseconds. It should be 0 or at least 1000000 (1 ms). nanoseconds. It should be 0 or at least 1000000 (1 ms).
""" """
@ -53,6 +53,8 @@ class Healthcheck(DictType):
@test.setter @test.setter
def test(self, value): def test(self, value):
if isinstance(value, six.string_types):
value = ["CMD-SHELL", value]
self['Test'] = value self['Test'] = value
@property @property