3939parser = 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+
4244parser .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.' ))
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+
5262def 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