1
0
Fork 0

support multi containers

This commit is contained in:
zhipeng 2022-03-25 18:23:05 +08:00
parent 21069ec18b
commit d41364f1af
6 changed files with 58 additions and 13 deletions

View file

@ -45,7 +45,11 @@ class HaproxyConfigGenerator:
# static?
if len(lineList) > 0:
self.mapping["easymapping"] = self.__parse(lineList)
else:
for d in self.mapping["easymapping"]:
for name, hosts in d.get('hosts', {}).items():
if type(hosts) != list:
d['hosts'][name] = [hosts]
# still 'None' -> default to [] for jinja2
if self.mapping["easymapping"] is None:
self.mapping["easymapping"] = []
@ -119,7 +123,8 @@ class HaproxyConfigGenerator:
""
)
easymapping[key]["hosts"][d[host_label]] = "{}:{}".format(container, ct_port)
easymapping[key]["hosts"].setdefault(d[host_label], [])
easymapping[key]["hosts"][d[host_label]] += ["{}:{}".format(container, ct_port)]
# handle SSL
ssl_label = self.label.create(["sslcert", definition])