From 1c5194e2ec8944ee698d1bbc182bdc7808bf94a3 Mon Sep 17 00:00:00 2001 From: Jason Bernardino Alonso Date: Thu, 18 Sep 2014 15:37:52 -0400 Subject: [PATCH 1/3] Allow pulls from an insecure registry Signed-off-by: Jason Bernardino Alonso --- fig/cli/main.py | 12 ++++++++++-- fig/project.py | 4 ++-- fig/service.py | 7 +++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fig/cli/main.py b/fig/cli/main.py index 36ae62524..ed44e5c31 100644 --- a/fig/cli/main.py +++ b/fig/cli/main.py @@ -213,9 +213,17 @@ class TopLevelCommand(Command): """ Pulls images for services. - Usage: pull [SERVICE...] + Usage: pull [options] [SERVICE...] + + Options: + --allow-insecure-ssl Allow insecure connections to the docker + registry """ - project.pull(service_names=options['SERVICE']) + insecure_registry = options['--allow-insecure-ssl'] + project.pull( + service_names=options['SERVICE'], + insecure_registry=insecure_registry + ) def rm(self, project, options): """ diff --git a/fig/project.py b/fig/project.py index 6ef6a7c52..38b9f46fc 100644 --- a/fig/project.py +++ b/fig/project.py @@ -180,9 +180,9 @@ class Project(object): return running_containers - def pull(self, service_names=None): + def pull(self, service_names=None, insecure_registry=False): for service in self.get_services(service_names, include_links=True): - service.pull() + service.pull(insecure_registry=insecure_registry) def remove_stopped(self, service_names=None, **options): for service in self.get_services(service_names): diff --git a/fig/service.py b/fig/service.py index e0b34591e..aebcff388 100644 --- a/fig/service.py +++ b/fig/service.py @@ -413,10 +413,13 @@ class Service(object): return False return True - def pull(self): + def pull(self, insecure_registry=False): if 'image' in self.options: log.info('Pulling %s (%s)...' % (self.name, self.options.get('image'))) - self.client.pull(self.options.get('image')) + self.client.pull( + self.options.get('image'), + insecure_registry=insecure_registry + ) NAME_RE = re.compile(r'^([^_]+)_([^_]+)_(run_)?(\d+)$') From c270e9d6221759773a2bb643e582fc82734b473f Mon Sep 17 00:00:00 2001 From: Jason Bernardino Alonso Date: Wed, 24 Sep 2014 20:11:19 -0400 Subject: [PATCH 2/3] Require docker-py 0.5 or later for insecure_registry kwarg Signed-off-by: Jason Bernardino Alonso --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1043cba8e..72c314768 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ install_requires = [ 'texttable >= 0.8.1, < 0.9', 'websocket-client >= 0.11.0, < 0.12', 'dockerpty >= 0.2.3, < 0.3', - 'docker-py >= 0.3.2, < 0.6', + 'docker-py >= 0.5, < 0.6', 'six >= 1.3.0, < 2', ] From 3408e0d4636e7818c90616ed03e4b91ff490f25f Mon Sep 17 00:00:00 2001 From: Moss Collum Date: Wed, 1 Oct 2014 11:09:19 -0400 Subject: [PATCH 3/3] Add unit test for Service.pull Signed-off-by: Moss Collum --- tests/unit/service_test.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unit/service_test.py b/tests/unit/service_test.py index 650afa5a6..e9034ccc4 100644 --- a/tests/unit/service_test.py +++ b/tests/unit/service_test.py @@ -128,6 +128,13 @@ class ServiceTest(unittest.TestCase): mock_container_class.from_ps.assert_called_once_with( mock_client, container_dict) + @mock.patch('fig.service.log', autospec=True) + def test_pull_image(self, mock_log): + service = Service('foo', client=self.mock_client, image='someimage:sometag') + service.pull(insecure_registry=True) + self.mock_client.pull.assert_called_once_with('someimage:sometag', insecure_registry=True) + mock_log.info.assert_called_once_with('Pulling foo (someimage:sometag)...') + class ServiceVolumesTest(unittest.TestCase):