Baseline modular DNS sync

This commit is contained in:
Lyncoln
2026-09-19 15:03:45 -04:00
commit 47850e3ce5
21 changed files with 957 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import importlib
def _load(kind: str, name: str, config):
if not name or not name.replace("_", "").replace("-", "").isalnum():
raise RuntimeError(f"Invalid {kind} plugin name: {name!r}")
module_name = name.replace("-", "_")
path = f"dns_sync.plugins.{kind}.{module_name}"
try:
module = importlib.import_module(path)
except ModuleNotFoundError as exc:
if exc.name == path:
raise RuntimeError(f"Unknown {kind[:-1]} plugin: {name}") from exc
raise
plugin_class = getattr(module, "Plugin", None)
if plugin_class is None:
raise RuntimeError(f"Plugin module {path} does not export Plugin")
return plugin_class(config)
def load_source(name: str, config):
return _load("sources", name, config)
def load_provider(name: str, config):
return _load("providers", name, config)