Remove the unsupported 'insecure_registry' for >=docker 3.0.0
The argument of 'insecure_registry' for image push has been removed
by this commit (in docker 3.0.0):
b180b8770a
Actually this argument was marked as deprecated and unfunctional
before this removing.
This commit is to remove this parameter at invoking the push() function
when docker version >= 3.0.0.
Change-Id: Ifa7d304d08a4073dcb1dff751d5a443c112cd377
Closes-Bug: #1746703
This commit is contained in:
parent
27557d2e77
commit
ad80bfd069
@ -29,6 +29,7 @@ import tempfile
|
||||
import threading
|
||||
import time
|
||||
|
||||
from distutils.version import StrictVersion
|
||||
import docker
|
||||
import git
|
||||
import jinja2
|
||||
@ -328,9 +329,15 @@ class PushTask(DockerTask):
|
||||
self.success = False
|
||||
|
||||
def push_image(self, image):
|
||||
for response in self.dc.push(image.canonical_name,
|
||||
stream=True,
|
||||
insecure_registry=True):
|
||||
kwargs = dict(stream=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):
|
||||
stream = json.loads(response)
|
||||
if 'stream' in stream:
|
||||
self.logger.info(stream['stream'])
|
||||
|
@ -57,6 +57,17 @@ class TasksTest(base.TestCase):
|
||||
self.imageChild.parent = self.image
|
||||
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, stream=True, insecure_registry=True)
|
||||
|
||||
@mock.patch('docker.version', '3.0.0')
|
||||
@mock.patch.dict(os.environ, clear=True)
|
||||
@mock.patch('docker.APIClient')
|
||||
def test_push_image(self, mock_client):
|
||||
@ -64,7 +75,7 @@ class TasksTest(base.TestCase):
|
||||
pusher = build.PushTask(self.conf, self.image)
|
||||
pusher.run()
|
||||
mock_client().push.assert_called_once_with(
|
||||
self.image.canonical_name, stream=True, insecure_registry=True)
|
||||
self.image.canonical_name, stream=True)
|
||||
|
||||
@mock.patch.dict(os.environ, clear=True)
|
||||
@mock.patch('docker.APIClient')
|
||||
|
Loading…
Reference in New Issue
Block a user