Add zone validation

This commit is contained in:
2025-09-28 15:46:12 +02:00
parent b48c8084cc
commit d41efd93d2
2 changed files with 9 additions and 10 deletions

View File

@@ -70,15 +70,6 @@ def extract_domain_from_path(path: str) -> str|None:
return None
def validate_zone(zone_name, content) -> bool:
try:
dns.zone.from_text(content, zone_name, relativize=False)
logging.info(f"Zone {zone_name} parsed successfully")
return True
except Exception as e:
logging.error(f"Parse failed for zone {zone_name}")
return False
def export_single_zone(trigger_path: str) -> list[Path]:
logging.info(f"Starting export of single zone for trigger path {trigger_path})")
ensure_git_repo()

View File

@@ -2,10 +2,18 @@ import logging
import requests
from config import *
from helpers import validate_zone
session = requests.Session()
def validate_zone(zone_name, content) -> bool:
try:
dns.zone.from_text(content, zone_name, relativize=False)
logging.info(f"Zone {zone_name} parsed successfully")
return True
except Exception as e:
logging.error(f"Parse failed for zone {zone_name}")
return False
def list_zones() -> list[dict]:
url = f"{TECHNITIUM_API_BASE.rstrip('/')}{LIST_ZONES_ENDPOINT}?token={API_TOKEN}"
logging.debug(f"Listing zones from {url}")