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

Commit fbbff58

Browse files
committed
Add new option cacerts.
This way you can override the CAs, that are used for http communication.
1 parent 052c760 commit fbbff58

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tools/fast_puller_.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
parser = argparse.ArgumentParser(
4040
description='Pull images from a Docker Registry, faaaaast.')
4141

42+
parser.add_argument('--cacerts', help='A file, which contains all certs to use')
43+
4244
parser.add_argument('--name', action='store',
4345
help=('The name of the docker image to pull and save. '
4446
'Supports fully-qualified tag or digest references.'))
@@ -49,6 +51,14 @@
4951
_THREADS = 8
5052

5153

54+
def _apply_ca_certs(callable, ca_certs):
55+
"""Apply ca_certs attribute to default transport"""
56+
def _call_with_ca_certs(*args, **kwargs):
57+
kwargs['ca_certs'] = ca_certs
58+
return callable(*args, **kwargs)
59+
return _call_with_ca_certs
60+
61+
5262
def main():
5363
logging_setup.DefineCommandLineArgs(parser)
5464
args = parser.parse_args()
@@ -57,8 +67,13 @@ def main():
5767
if not args.name or not args.directory:
5868
raise Exception('--name and --directory are required arguments.')
5969

70+
if args.cacerts:
71+
logging.info('Adding CA certificates of %s', args.cacerts)
72+
transport_callable = _apply_ca_certs(
73+
httplib2.Http, args.cacerts)
74+
6075
retry_factory = retry.Factory()
61-
retry_factory = retry_factory.WithSourceTransportCallable(httplib2.Http)
76+
retry_factory = retry_factory.WithSourceTransportCallable(transport_callable)
6277
transport = transport_pool.Http(retry_factory.Build, size=_THREADS)
6378

6479
if '@' in args.name:

0 commit comments

Comments
 (0)