Bump minimum docker-py version
With version 6.0.0 of the docker python module, their implementation of versioning has changed, making our check for old versions fail. Since version 3.0.0 is from 2018, we should be safe to assume that as a minimum version though, so we can just get rid of the special handling of older versions. Change-Id: I077b7b5acf2c1f9beb6da06d3555e2ebe30831d1
This commit is contained in:
parent
3e5369db54
commit
0fc8712cac
@ -28,7 +28,6 @@ import tempfile
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from distutils.version import StrictVersion
|
|
||||||
import docker
|
import docker
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import git
|
import git
|
||||||
@ -264,12 +263,6 @@ class PushTask(DockerTask):
|
|||||||
def push_image(self, image):
|
def push_image(self, image):
|
||||||
kwargs = dict(stream=True, decode=True)
|
kwargs = dict(stream=True, decode=True)
|
||||||
|
|
||||||
# Since docker 3.0.0, the argument of 'insecure_registry' is removed.
|
|
||||||
# To be compatible, set 'insecure_registry=True' for old releases.
|
|
||||||
dc_running_ver = StrictVersion(docker.version)
|
|
||||||
if dc_running_ver < StrictVersion('3.0.0'):
|
|
||||||
kwargs['insecure_registry'] = True
|
|
||||||
|
|
||||||
for response in self.dc.push(image.canonical_name, **kwargs):
|
for response in self.dc.push(image.canonical_name, **kwargs):
|
||||||
if 'stream' in response:
|
if 'stream' in response:
|
||||||
self.logger.info(response['stream'])
|
self.logger.info(response['stream'])
|
||||||
|
@ -59,18 +59,6 @@ class TasksTest(base.TestCase):
|
|||||||
self.imageChild.parent = self.image
|
self.imageChild.parent = self.image
|
||||||
self.imageChild.path = self.useFixture(fixtures.TempDir()).path
|
self.imageChild.path = self.useFixture(fixtures.TempDir()).path
|
||||||
|
|
||||||
@mock.patch('docker.version', '2.7.0')
|
|
||||||
@mock.patch.dict(os.environ, clear=True)
|
|
||||||
@mock.patch('docker.APIClient')
|
|
||||||
def test_push_image_before_v3_0_0(self, mock_client):
|
|
||||||
self.dc = mock_client
|
|
||||||
pusher = build.PushTask(self.conf, self.image)
|
|
||||||
pusher.run()
|
|
||||||
mock_client().push.assert_called_once_with(
|
|
||||||
self.image.canonical_name, decode=True,
|
|
||||||
stream=True, insecure_registry=True)
|
|
||||||
|
|
||||||
@mock.patch('docker.version', '3.0.0')
|
|
||||||
@mock.patch.dict(os.environ, clear=True)
|
@mock.patch.dict(os.environ, clear=True)
|
||||||
@mock.patch('docker.APIClient')
|
@mock.patch('docker.APIClient')
|
||||||
def test_push_image(self, mock_client):
|
def test_push_image(self, mock_client):
|
||||||
@ -81,7 +69,6 @@ class TasksTest(base.TestCase):
|
|||||||
self.image.canonical_name, decode=True, stream=True)
|
self.image.canonical_name, decode=True, stream=True)
|
||||||
self.assertTrue(pusher.success)
|
self.assertTrue(pusher.success)
|
||||||
|
|
||||||
@mock.patch('docker.version', '3.0.0')
|
|
||||||
@mock.patch.dict(os.environ, clear=True)
|
@mock.patch.dict(os.environ, clear=True)
|
||||||
@mock.patch('docker.APIClient')
|
@mock.patch('docker.APIClient')
|
||||||
def test_push_image_failure(self, mock_client):
|
def test_push_image_failure(self, mock_client):
|
||||||
@ -95,7 +82,6 @@ class TasksTest(base.TestCase):
|
|||||||
self.assertFalse(pusher.success)
|
self.assertFalse(pusher.success)
|
||||||
self.assertEqual(build.Status.PUSH_ERROR, self.image.status)
|
self.assertEqual(build.Status.PUSH_ERROR, self.image.status)
|
||||||
|
|
||||||
@mock.patch('docker.version', '3.0.0')
|
|
||||||
@mock.patch.dict(os.environ, clear=True)
|
@mock.patch.dict(os.environ, clear=True)
|
||||||
@mock.patch('docker.APIClient')
|
@mock.patch('docker.APIClient')
|
||||||
def test_push_image_failure_retry(self, mock_client):
|
def test_push_image_failure_retry(self, mock_client):
|
||||||
@ -116,7 +102,6 @@ class TasksTest(base.TestCase):
|
|||||||
self.assertTrue(pusher.success)
|
self.assertTrue(pusher.success)
|
||||||
self.assertEqual(build.Status.BUILT, self.image.status)
|
self.assertEqual(build.Status.BUILT, self.image.status)
|
||||||
|
|
||||||
@mock.patch('docker.version', '3.0.0')
|
|
||||||
@mock.patch.dict(os.environ, clear=True)
|
@mock.patch.dict(os.environ, clear=True)
|
||||||
@mock.patch('docker.APIClient')
|
@mock.patch('docker.APIClient')
|
||||||
def test_push_image_failure_error(self, mock_client):
|
def test_push_image_failure_error(self, mock_client):
|
||||||
@ -131,7 +116,6 @@ class TasksTest(base.TestCase):
|
|||||||
self.assertFalse(pusher.success)
|
self.assertFalse(pusher.success)
|
||||||
self.assertEqual(build.Status.PUSH_ERROR, self.image.status)
|
self.assertEqual(build.Status.PUSH_ERROR, self.image.status)
|
||||||
|
|
||||||
@mock.patch('docker.version', '3.0.0')
|
|
||||||
@mock.patch.dict(os.environ, clear=True)
|
@mock.patch.dict(os.environ, clear=True)
|
||||||
@mock.patch('docker.APIClient')
|
@mock.patch('docker.APIClient')
|
||||||
def test_push_image_failure_error_retry(self, mock_client):
|
def test_push_image_failure_error_retry(self, mock_client):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||||
docker>=2.4.2 # Apache-2.0
|
docker>=3.0.0 # Apache-2.0
|
||||||
Jinja2>=3.0.1 # BSD License (3 clause)
|
Jinja2>=3.0.1 # BSD License (3 clause)
|
||||||
GitPython>=1.0.1 # BSD License (3 clause)
|
GitPython>=1.0.1 # BSD License (3 clause)
|
||||||
oslo.config>=5.1.0 # Apache-2.0
|
oslo.config>=5.1.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user