Skip to content

Commit 431fdaa

Browse files
committed
Merge pull request #490 from LuminosoInsight/insecure-pull
Allow pulls from an insecure registry
2 parents ed12f25 + 3408e0d commit 431fdaa

5 files changed

Lines changed: 25 additions & 7 deletions

File tree

fig/cli/main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,17 @@ def pull(self, project, options):
213213
"""
214214
Pulls images for services.
215215
216-
Usage: pull [SERVICE...]
216+
Usage: pull [options] [SERVICE...]
217+
218+
Options:
219+
--allow-insecure-ssl Allow insecure connections to the docker
220+
registry
217221
"""
218-
project.pull(service_names=options['SERVICE'])
222+
insecure_registry = options['--allow-insecure-ssl']
223+
project.pull(
224+
service_names=options['SERVICE'],
225+
insecure_registry=insecure_registry
226+
)
219227

220228
def rm(self, project, options):
221229
"""

fig/project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ def up(self, service_names=None, start_links=True, recreate=True):
180180

181181
return running_containers
182182

183-
def pull(self, service_names=None):
183+
def pull(self, service_names=None, insecure_registry=False):
184184
for service in self.get_services(service_names, include_links=True):
185-
service.pull()
185+
service.pull(insecure_registry=insecure_registry)
186186

187187
def remove_stopped(self, service_names=None, **options):
188188
for service in self.get_services(service_names):

fig/service.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,13 @@ def can_be_scaled(self):
423423
return False
424424
return True
425425

426-
def pull(self):
426+
def pull(self, insecure_registry=False):
427427
if 'image' in self.options:
428428
log.info('Pulling %s (%s)...' % (self.name, self.options.get('image')))
429-
self.client.pull(self.options.get('image'))
429+
self.client.pull(
430+
self.options.get('image'),
431+
insecure_registry=insecure_registry
432+
)
430433

431434

432435
NAME_RE = re.compile(r'^([^_]+)_([^_]+)_(run_)?(\d+)$')

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def find_version(*file_paths):
3131
'texttable >= 0.8.1, < 0.9',
3232
'websocket-client >= 0.11.0, < 0.12',
3333
'dockerpty >= 0.2.3, < 0.3',
34-
'docker-py >= 0.3.2, < 0.6',
34+
'docker-py >= 0.5, < 0.6',
3535
'six >= 1.3.0, < 2',
3636
]
3737

tests/unit/service_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ def test_get_container(self, mock_container_class):
167167
mock_container_class.from_ps.assert_called_once_with(
168168
mock_client, container_dict)
169169

170+
@mock.patch('fig.service.log', autospec=True)
171+
def test_pull_image(self, mock_log):
172+
service = Service('foo', client=self.mock_client, image='someimage:sometag')
173+
service.pull(insecure_registry=True)
174+
self.mock_client.pull.assert_called_once_with('someimage:sometag', insecure_registry=True)
175+
mock_log.info.assert_called_once_with('Pulling foo (someimage:sometag)...')
176+
170177

171178
class ServiceVolumesTest(unittest.TestCase):
172179

0 commit comments

Comments
 (0)