diff options
author | Joffrey F <joffrey@docker.com> | 2015-04-22 13:56:35 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2015-04-22 13:56:35 -0700 |
commit | b46e4a398b75ae23cb158f5b6d56efff78893f29 (patch) | |
tree | e7c2e6e40afb26f0198d71b09b3540f4d7e75961 | |
parent | 6dd45d7535c5825d95fc41b721d446d8eba3a5bd (diff) | |
download | docker-py-support_v2_private_registry.tar.gz |
Modify expand_registry_url to support v2 private registries.support_v2_private_registry
-rw-r--r-- | docker/auth/auth.py | 2 | ||||
-rw-r--r-- | docker/utils/__init__.py | 4 | ||||
-rw-r--r-- | docker/utils/utils.py | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/docker/auth/auth.py b/docker/auth/auth.py index d69c035..373df56 100644 --- a/docker/auth/auth.py +++ b/docker/auth/auth.py @@ -29,7 +29,7 @@ DOCKER_CONFIG_FILENAME = '.dockercfg' def expand_registry_url(hostname, insecure=False): if hostname.startswith('http:') or hostname.startswith('https:'): return hostname - if utils.ping('https://' + hostname + '/v1/_ping'): + if utils.ping_registry('https://' + hostname): return 'https://' + hostname elif insecure: return 'http://' + hostname diff --git a/docker/utils/__init__.py b/docker/utils/__init__.py index 0731362..0c5934f 100644 --- a/docker/utils/__init__.py +++ b/docker/utils/__init__.py @@ -1,6 +1,6 @@ from .utils import ( compare_version, convert_port_bindings, convert_volume_binds, - mkbuildcontext, ping, tar, parse_repository_tag, parse_host, + mkbuildcontext, tar, parse_repository_tag, parse_host, kwargs_from_env, convert_filters, create_host_config, - create_container_config, parse_bytes + create_container_config, parse_bytes, ping_registry ) # flake8: noqa diff --git a/docker/utils/utils.py b/docker/utils/utils.py index cccb970..5c729a0 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -118,6 +118,10 @@ def compare_version(v1, v2): return 1 +def ping_registry(url): + return ping(url + '/v2/_ping') or ping(url + '/v1/_ping') + + def ping(url): try: res = requests.get(url, timeout=3) |