Archived
Polish KarlDNS production UI and docs
This commit is contained in:
1 parent
ca92dc211a
commit
5beee0e5c6
61 files changed
+1566
-523
No files matched your search
@@ -6,7 +6,7 @@ import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from ..ddns_models import DdnsSettings, UpdateResult
|
||||
from .base import DnsProviderError
|
||||
from .base import DnsProviderError, DnsReconciliationError
|
||||
|
||||
|
||||
def publish_cloudflare(result: UpdateResult, settings: DdnsSettings) -> None:
|
||||
@@ -45,6 +45,7 @@ def _cloudflare_upsert_record(settings: DdnsSettings, hostname: str, record_type
|
||||
_cloudflare_request(settings, f"/dns_records/{record['id']}", method="PATCH", payload=payload)
|
||||
else:
|
||||
_cloudflare_request(settings, "/dns_records", method="POST", payload=payload)
|
||||
_cloudflare_reconcile_record(settings, hostname, record_type, value)
|
||||
|
||||
|
||||
def _cloudflare_find_record(settings: DdnsSettings, hostname: str, record_type: str) -> dict[str, str] | None:
|
||||
@@ -54,6 +55,14 @@ def _cloudflare_find_record(settings: DdnsSettings, hostname: str, record_type:
|
||||
return records[0] if records else None
|
||||
|
||||
|
||||
def _cloudflare_reconcile_record(settings: DdnsSettings, hostname: str, record_type: str, value: str) -> None:
|
||||
record = _cloudflare_find_record(settings, hostname, record_type)
|
||||
if not record:
|
||||
raise DnsReconciliationError(f"Cloudflare {record_type} record was not visible after publish")
|
||||
if record.get("content") != value:
|
||||
raise DnsReconciliationError(f"Cloudflare {record_type} record did not match requested content after publish")
|
||||
|
||||
|
||||
def _cloudflare_request(
|
||||
settings: DdnsSettings,
|
||||
path: str,
|
||||
|
||||
Reference in new issue
Block a user