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

Add new option cacerts. #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
Copy link

@chrischdi chrischdi Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be an if clause?
otherwise transport_callable does not exist

if args.cacerts:
  retry_factory = retry_factory.WithSourceTransportCallable(transport_callable)
else:
  retry_factory = retry_factory.WithSourceTransportCallable(httplib2.Http)

transport = transport_pool.Http(retry_factory.Build, size=_THREADS)

if '@' in args.name:
Expand Down