Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit fec140a

Browse files
committed
Fixed endpoints list in response headers for standalone mirrors
1 parent 4cbfb4e commit fec140a

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

docker_registry/index.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,8 @@
2222
entities. This module mimics the Index.
2323
"""
2424

25-
26-
def get_endpoints(cfg=None):
27-
if not cfg:
28-
cfg = config.load()
29-
registry_endpoints = cfg.registry_endpoints
30-
if not registry_endpoints:
31-
#registry_endpoints = socket.gethostname()
32-
registry_endpoints = flask.request.environ['HTTP_HOST']
33-
return registry_endpoints
34-
35-
3625
def generate_headers(namespace, repository, access):
37-
registry_endpoints = get_endpoints()
26+
registry_endpoints = toolkit.get_endpoints()
3827
# The token generated will be invalid against a real Index behind.
3928
token = 'Token signature={0},repository="{1}/{2}",access={3}'.format(
4029
toolkit.gen_random_string(), namespace, repository, access)

docker_registry/lib/mirroring.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def wrapper(*args, **kwargs):
136136
headers = source_resp.headers
137137
if 'Content-Encoding' in headers:
138138
del headers['Content-Encoding']
139+
if index_route and 'X-Docker-Endpoints' in headers:
140+
headers['X-Docker-Endpoints'] = toolkit.get_endpoints()
139141

140142
if not stream:
141143
logger.debug('JSON data found on source, writing response')

docker_registry/toolkit.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,13 @@ def get_repository():
302302
if len(parts) < 2:
303303
return ('library', parts[0])
304304
return (parts[0], parts[1])
305+
306+
307+
def get_endpoints(cfg=None):
308+
if not cfg:
309+
cfg = config.load()
310+
registry_endpoints = cfg.registry_endpoints
311+
if not registry_endpoints:
312+
#registry_endpoints = socket.gethostname()
313+
registry_endpoints = flask.request.environ['HTTP_HOST']
314+
return registry_endpoints

0 commit comments

Comments
 (0)