mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-17 12:28:55 +00:00
Docker SDK for Python 7+: make sure that ssl_version is not passed, and error out if it was explicitly set (#715) (#720)
* Do not accept ssl_version for Docker SDK for Python 7.0.0+.
* Add changelog fragment.
* Generally avoid sending None values to TLSConfig. Potentially prevents similar errors in the future, assuming the users do not pass values in.
* Python 2.6 compatibility.
(cherry picked from commit 3aa1ddcca0)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
1e286852b2
commit
fe771e5615
2
changelogs/fragments/715-docker-7.yml
Normal file
2
changelogs/fragments/715-docker-7.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "modules and plugins using the Docker SDK for Python - remove ``ssl_version`` from the parameters passed to Docker SDK for Python 7.0.0+. Explicitly fail with a nicer error message if it was explicitly set in this case (https://github.com/ansible-collections/community.docker/pull/715)."
|
||||||
@ -73,6 +73,8 @@ options:
|
|||||||
- Provide a valid SSL version number. Default value determined by ssl.py module.
|
- Provide a valid SSL version number. Default value determined by ssl.py module.
|
||||||
- If the value is not specified in the task, the value of environment variable C(DOCKER_SSL_VERSION) will be
|
- If the value is not specified in the task, the value of environment variable C(DOCKER_SSL_VERSION) will be
|
||||||
used instead.
|
used instead.
|
||||||
|
- B(Note:) this option is no longer supported for Docker SDK for Python 7.0.0+. Specifying it with Docker SDK for
|
||||||
|
Python 7.0.0 or newer will lead to an error.
|
||||||
type: str
|
type: str
|
||||||
tls:
|
tls:
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -121,6 +121,20 @@ if not HAS_DOCKER_PY:
|
|||||||
|
|
||||||
|
|
||||||
def _get_tls_config(fail_function, **kwargs):
|
def _get_tls_config(fail_function, **kwargs):
|
||||||
|
if 'ssl_version' in kwargs and LooseVersion(docker_version) >= LooseVersion('7.0.0b1'):
|
||||||
|
ssl_version = kwargs.pop('ssl_version')
|
||||||
|
if ssl_version is not None:
|
||||||
|
fail_function(
|
||||||
|
"ssl_version is not compatible with Docker SDK for Python 7.0.0+. You are using"
|
||||||
|
" Docker SDK for Python {docker_py_version}. The ssl_version option (value: {ssl_version})"
|
||||||
|
" has either been set directly or with the environment variable DOCKER_SSL_VERSION."
|
||||||
|
" Make sure it is not set, or switch to an older version of Docker SDK for Python.".format(
|
||||||
|
docker_py_version=docker_version,
|
||||||
|
ssl_version=ssl_version,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
# Filter out all None parameters
|
||||||
|
kwargs = dict((k, v) for k, v in kwargs.items() if v is not None)
|
||||||
try:
|
try:
|
||||||
tls_config = TLSConfig(**kwargs)
|
tls_config = TLSConfig(**kwargs)
|
||||||
return tls_config
|
return tls_config
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user