From 1705d832d0cf5318cf90e55afa21260262a5bbe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Chaves?= Date: Thu, 8 Feb 2024 14:55:12 +0100 Subject: [PATCH] Stop hardcoding the default Docker version (#445) --- shub/image/utils.py | 7 +++---- tests/image/test_utils.py | 4 +--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/shub/image/utils.py b/shub/image/utils.py index 50914ba3..f51e0571 100644 --- a/shub/image/utils.py +++ b/shub/image/utils.py @@ -22,7 +22,6 @@ from importlib import metadata -DEFAULT_DOCKER_API_VERSION = '1.21' STATUS_FILE_LOCATION = '.releases' _VALIDSPIDERNAME = re.compile('^[a-z0-9][-._a-z0-9]+$', re.I) @@ -39,10 +38,10 @@ docker version and check its output: it should contain Docker client and server versions and -should not contain any errors. The minimum API Version is: {} +should not contain any errors. You can learn about Docker at https://www.docker.com/. -""".format(DEFAULT_DOCKER_API_VERSION) +""" def is_verbose(): @@ -103,7 +102,7 @@ def get_docker_client(validate=True): verify=apply_path_fun('ca.pem'), assert_hostname=False) docker_host = docker_host.replace('tcp://', 'https://') - version = os.environ.get('DOCKER_API_VERSION', DEFAULT_DOCKER_API_VERSION) + version = os.environ.get('DOCKER_API_VERSION', 'auto') # If it returns an error, check if you have the old docker-py installed # together with the new docker lib, and uninstall docker-py. diff --git a/tests/image/test_utils.py b/tests/image/test_utils.py index be54e46d..a1a8aec6 100644 --- a/tests/image/test_utils.py +++ b/tests/image/test_utils.py @@ -15,7 +15,6 @@ load_status_url, store_status_url, STATUS_FILE_LOCATION, - DEFAULT_DOCKER_API_VERSION, ) from .utils import FakeProjectDirectory, add_sh_fake_config @@ -44,8 +43,7 @@ def version(self): mocked_docker.APIClient = DockerClientMock assert get_docker_client() - client_mock.assert_called_with( - base_url=None, tls=None, version=DEFAULT_DOCKER_API_VERSION) + client_mock.assert_called_with(base_url=None, tls=None, version='auto') # set basic test environment os.environ['DOCKER_HOST'] = 'http://127.0.0.1' os.environ['DOCKER_API_VERSION'] = '1.40'