Skip to content

Commit

Permalink
remove duplicate domains in frontend-certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Jan 8, 2025
1 parent 95dc11c commit 39cc1b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions filter_plugins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def filters(self):
"join_w_excludes": self.join_w_excludes,
"waf_coraza_apps": self.waf_coraza_apps,
"all_route_backends_exist": self.all_route_backends_exist,
"domains_not_routed": self.domains_not_routed,
}

@staticmethod
Expand Down Expand Up @@ -206,3 +207,15 @@ def all_route_backends_exist(cls, cnf: dict) -> bool:
return False

return True

@classmethod
def domains_not_routed(cls, fe_domains: list, routes: dict) -> list:
be_domains = []

for cnf in routes.values():
if 'domains' not in cnf:
continue

be_domains.extend(cls.ensure_list(cnf['domains']))

return [d for d in cls.ensure_list(fe_domains) if d not in be_domains]
2 changes: 1 addition & 1 deletion templates/etc/dehydrated/domains.txt.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% set fe_cnf = defaults_frontend | combine(fe_cnf_user, recursive=true) %}
# FRONTEND: {{ fe_name }}
{% if fe_cnf.acme.domains | default([]) | ensure_list | length > 0 %}
{{ fe_cnf.acme.domains | default([]) | ensure_list | join(' ') }} > {{ fe_name | safe_key }}
{{ fe_cnf.acme.domains | default([]) | domains_not_routed(fe_cnf.routes) | join(' ') }} > {{ fe_name | safe_key }}
{% endif %}
{% for be_name, be_cnf_user in fe_cnf.routes.items() %}
{% set be_cnf = defaults_backend | combine(be_cnf_user, recursive=true) %}
Expand Down

0 comments on commit 39cc1b3

Please sign in to comment.