Merge pull request #490 from LuminosoInsight/insecure-pull

Allow pulls from an insecure registry
This commit is contained in:
Aanand Prasad 2014-10-01 10:52:54 -07:00
commit 431fdaa0f1
5 changed files with 25 additions and 7 deletions

View File

@ -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):
"""

View File

@ -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):

View File

@ -423,10 +423,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+)$')

View File

@ -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',
]

View File

@ -167,6 +167,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):