From 9eb05de722dc58a25b302359f1635b4d871e6a44 Mon Sep 17 00:00:00 2001 From: Jonathan Dowland <63694+jmtd@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:40:47 +0000 Subject: [PATCH] Overhaul instantiating docker API class (#57) * Overhaul instantiating docker API class Don't pin docker APIClient to version 1.22. Don't try to instantiate docker.Client before trying docker.APIClient: the former dates from the days the library was called "docker-py", the last release for which was November 2016. EPEL 7 and onwards provide the newer Python docker library, so I doubt there's anyone left using the older one. This now aligns with Cekit. Signed-off-by: Jonathan Dowland * Request a specific docker API version to match Cekit Signed-off-by: Jonathan Dowland --------- Signed-off-by: Jonathan Dowland --- steps/container.py | 8 ++++---- steps/image_steps.py | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/steps/container.py b/steps/container.py index 575c940..ca1d328 100644 --- a/steps/container.py +++ b/steps/container.py @@ -32,10 +32,10 @@ import time import multiprocessing as mp -try: - d = docker.Client(version="1.22") -except: - d = docker.APIClient(version="1.22") +# A future version of Cekit will expose this to us, for now we hard-code +DOCKER_API_VERSION = "1.35" + +d = docker.APIClient(version=DOCKER_API_VERSION) class ExecException(Exception): diff --git a/steps/image_steps.py b/steps/image_steps.py index 6b18ca7..01ff4a0 100644 --- a/steps/image_steps.py +++ b/steps/image_steps.py @@ -3,12 +3,10 @@ from behave import then +# A future version of Cekit will expose this to us, for now we hard-code +DOCKER_API_VERSION = "1.35" -try: - DOCKER_CLIENT = docker.Client(version="1.22") -except: - DOCKER_CLIENT = docker.APIClient(version="1.22") - +DOCKER_CLIENT = docker.APIClient(version=DOCKER_API_VERSION) @then(u'the image should contain label {label}') @then(u'the image should contain label {label} {check} value {value}')