Allow dependent image pull from insecure registry

PR #490 Provides the ability to pull from an insecure registry by passing --allow-insecure-ssl. This commit extends the work done in #490 and adds the ability to pass --allow-insecure-ssl to the up and run commands which will attempt to pull dependent images if they do not exist.

Signed-off-by: Tyler Rivera <riverat2@email.chop.edu>
This commit is contained in:
Tyler Rivera 2014-10-22 10:57:43 -04:00
commit 491181ec31
4 changed files with 54 additions and 22 deletions

View file

@ -6,6 +6,7 @@ from .. import unittest
import mock
import docker
from requests import Response
from fig import Service
from fig.container import Container
@ -14,6 +15,7 @@ from fig.service import (
split_port,
parse_volume_spec,
build_volume_binding,
APIError,
)
@ -174,6 +176,21 @@ class ServiceTest(unittest.TestCase):
self.mock_client.pull.assert_called_once_with('someimage:sometag', insecure_registry=True)
mock_log.info.assert_called_once_with('Pulling foo (someimage:sometag)...')
@mock.patch('fig.service.log', autospec=True)
def test_create_container_from_insecure_registry(self, mock_log):
service = Service('foo', client=self.mock_client, image='someimage:sometag')
mock_response = mock.Mock(Response)
mock_response.status_code = 404
mock_response.reason = "Not Found"
Container.create = mock.Mock()
Container.create.side_effect = APIError('Mock error', mock_response, "No such image")
try:
service.create_container(insecure_registry=True)
except APIError: # We expect the APIError because our service requires a non-existent image.
pass
self.mock_client.pull.assert_called_once_with('someimage:sometag', insecure_registry=True, stream=True)
mock_log.info.assert_called_once_with('Pulling image someimage:sometag...')
class ServiceVolumesTest(unittest.TestCase):