Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Add new option cacerts.
Browse files Browse the repository at this point in the history
This way you can override the CAs, that are used for http communication.
  • Loading branch information
abergmeier committed Jan 3, 2018
1 parent 052c760 commit fbbff58
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tools/fast_puller_.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
parser = argparse.ArgumentParser(
description='Pull images from a Docker Registry, faaaaast.')

parser.add_argument('--cacerts', help='A file, which contains all certs to use')

parser.add_argument('--name', action='store',
help=('The name of the docker image to pull and save. '
'Supports fully-qualified tag or digest references.'))
Expand All @@ -49,6 +51,14 @@
_THREADS = 8


def _apply_ca_certs(callable, ca_certs):
"""Apply ca_certs attribute to default transport"""
def _call_with_ca_certs(*args, **kwargs):
kwargs['ca_certs'] = ca_certs
return callable(*args, **kwargs)
return _call_with_ca_certs


def main():
logging_setup.DefineCommandLineArgs(parser)
args = parser.parse_args()
Expand All @@ -57,8 +67,13 @@ def main():
if not args.name or not args.directory:
raise Exception('--name and --directory are required arguments.')

if args.cacerts:
logging.info('Adding CA certificates of %s', args.cacerts)
transport_callable = _apply_ca_certs(
httplib2.Http, args.cacerts)

retry_factory = retry.Factory()
retry_factory = retry_factory.WithSourceTransportCallable(httplib2.Http)
retry_factory = retry_factory.WithSourceTransportCallable(transport_callable)
transport = transport_pool.Http(retry_factory.Build, size=_THREADS)

if '@' in args.name:
Expand Down

0 comments on commit fbbff58

Please sign in to comment.