Merge branch 'multiple_domains' into 'master'
add support for multiple domains See merge request !4
This commit is contained in:
commit
b292625c71
@ -21,7 +21,7 @@ def analyse_proxy_data(data):
|
||||
"""Extracts the data for the proxy configuration (envrionment variable
|
||||
'PROXY_DATA' and converts it to a dictionary."""
|
||||
proxy_data = {}
|
||||
for proxy_var in data['PROXY_DATA'].split(','):
|
||||
for proxy_var in data.split(','):
|
||||
t = proxy_var.split(":", 1)
|
||||
proxy_data[t[0]] = t[1]
|
||||
return proxy_data
|
||||
@ -31,11 +31,18 @@ def analyse_env_vars(inspect_data):
|
||||
"""Extracts the environment variables from the given result of an 'inspect
|
||||
container' call."""
|
||||
env_data = {}
|
||||
counter = 0
|
||||
if not 'Env' in inspect_data['Config'] or inspect_data['Config']['Env'] is None:
|
||||
return env_data
|
||||
for env_var in inspect_data['Config']['Env']:
|
||||
t = env_var.split("=")
|
||||
env_data[t[0]] = t[1]
|
||||
key = t[0]
|
||||
value = t[1]
|
||||
if key == 'PROXY_DATA':
|
||||
if key in env_data:
|
||||
key = "{key}{postfix}".format(key=key, postfix=counter)
|
||||
counter+=1
|
||||
env_data[key] = value
|
||||
return env_data
|
||||
|
||||
|
||||
@ -45,11 +52,13 @@ def handle_container(docker_client, id):
|
||||
written to the directory of temporary nginx files"""
|
||||
inspect_data = docker_client.inspect_container(id)
|
||||
env_vars = analyse_env_vars(inspect_data)
|
||||
if 'PROXY_DATA' in env_vars:
|
||||
proxy_data = analyse_proxy_data(env_vars)
|
||||
names = get_if_available(proxy_data, 'server_names', '').split(';')
|
||||
return names
|
||||
return []
|
||||
names = []
|
||||
for key in env_vars:
|
||||
value = env_vars[key]
|
||||
proxy_data = analyse_proxy_data(value)
|
||||
names += get_if_available(proxy_data, 'server_names', '').split(';')
|
||||
logging.info('list of domains on: %s', str(names))
|
||||
return names
|
||||
|
||||
|
||||
def get_resolving_domains_from_containers(docker_client):
|
||||
|
Loading…
Reference in New Issue
Block a user