🔧(dns) make target zone for communes domains configurable

Add a configuration setting tied to an env var, so we can have
a separate zone for staging/preprod.
This commit is contained in:
Laurent Bossavit
2025-03-05 10:17:07 +01:00
committed by Laurent Bossavit
parent dc33493739
commit 2502ff0c99
5 changed files with 17 additions and 4 deletions

View File

@@ -181,7 +181,7 @@ class CommuneCreation(BaseOrganizationPlugin):
def zone_name(self, name: str) -> str:
"""Derive the zone name from the commune name"""
normalized = self.normalize_name(name)
return f"{normalized}.collectivite.fr"
return f"{normalized}.{settings.DNS_PROVISIONING_TARGET_ZONE}"
def complete_commune_creation(self, name: str) -> ApiCall:
"""Specify the tasks to be completed after a commune is created."""
@@ -193,7 +193,7 @@ class CommuneCreation(BaseOrganizationPlugin):
create_zone.url = "/domain/v2beta1/dns-zones"
create_zone.params = {
"project_id": settings.DNS_PROVISIONING_RESOURCE_ID,
"domain": "collectivite.fr",
"domain": settings.DNS_PROVISIONING_TARGET_ZONE,
"subdomain": inputs["name"],
}
create_zone.headers = {