Allow API version specification via env var

Hard-coding the API version to '1.18' with the docker-py constructor will
cause the docker-py logic at
https://github.com/docker/docker-py/blob/master/docker/client.py#L143-L146
to always fail, which will cause authentication issues if you're using a
remote daemon using API version 1.19 - regardless of the API version of
the registry.

Allow the user to set the API version via an environment variable. If
the variable is not present, it will still default to '1.18' like it
does today.

Signed-off-by: Reilly Herrewig-Pope <reilly.herrewigpope@mandiant.com>
This commit is contained in:
Reilly Herrewig-Pope 2015-07-28 14:12:20 -04:00
parent 487eae3b7b
commit fc203d643a
1 changed files with 3 additions and 1 deletions

View File

@ -14,6 +14,8 @@ def docker_client():
cert_path = os.path.join(os.environ.get('HOME', ''), '.docker')
base_url = os.environ.get('DOCKER_HOST')
api_version = os.environ.get('COMPOSE_API_VERSION', '1.18')
tls_config = None
if os.environ.get('DOCKER_TLS_VERIFY', '') != '':
@ -32,4 +34,4 @@ def docker_client():
)
timeout = int(os.environ.get('DOCKER_CLIENT_TIMEOUT', 60))
return Client(base_url=base_url, tls=tls_config, version='1.18', timeout=timeout)
return Client(base_url=base_url, tls=tls_config, version=api_version, timeout=timeout)