def _get_query():
registry = args.registry
if not registry:
parser.error("No registry provided, neither as a command argument nor through the environment variable "
"REGISTRY.")
if registry.startswith('http'):
base_url = registry
else:
base_url = 'https://{0}'.format(registry)
kwargs = {}
if args.user:
if args.digest_auth:
kwargs['auth'] = HTTPDigestAuth(args.user, args.password)
else:
kwargs['auth'] = HTTPBasicAuth(args.user, args.password)
elif os.path.isfile(DOCKER_CONFIG_FILE):
config_auth = _get_auth_config(registry)
if config_auth:
kwargs['auth'] = HTTPBase64Auth(config_auth)
if args.verify is not None:
kwargs['verify'] = value_or_false(args.verify)
if args.client_cert:
if args.client_key:
kwargs['cert'] = (args.client_cert, args.client_key)
else:
kwargs['cert'] = args.client_cert
if args.use_get_manifest:
kwargs['use_get_manifest'] = True
client = DockerRegistryClient(base_url, **kwargs)
query = DockerRegistryQuery(client)
cache_fn = _get_cache_name(registry)
if cache_fn and os.path.isfile(cache_fn) and not args.refresh:
with open(cache_fn) as f:
query.load(f)
return query
评论列表
文章目录