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_a_certs (* args , ** kwargs ):
57+ return callable (* args , ca_certs = ca_certs , ** kwargs )
58+ return _call_with_a_certs
59+
60+
5261def main ():
5362 logging_setup .DefineCommandLineArgs (parser )
5463 args = parser .parse_args ()
@@ -57,8 +66,15 @@ def main():
5766 if not args .name or not args .directory :
5867 raise Exception ('--name and --directory are required arguments.' )
5968
69+ transport_callable = httplib2 .Http
70+
71+ if args .cacerts :
72+ logging .info ('Adding CA certificates of %s' , args .cacerts )
73+ transport_callable = _apply_ca_certs (
74+ transport_callable , args .cacerts )
75+
6076 retry_factory = retry .Factory ()
61- retry_factory = retry_factory .WithSourceTransportCallable (httplib2 . Http )
77+ retry_factory = retry_factory .WithSourceTransportCallable (transport_callable )
6278 transport = transport_pool .Http (retry_factory .Build , size = _THREADS )
6379
6480 if '@' in args .name :
0 commit comments