feat: distribution is a dict and nodes and cluster are top level (#1288)
* feat: distribution is a dict and nodes and cluster are top level Signed-off-by: Devin Buhl <devin@buhl.casa> * chore: housekeeping Signed-off-by: Devin Buhl <devin@buhl.casa> --------- Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
1 parent
cba35dc66a
commit
89673cd17b
55 files changed
+330
-302
No files matched your search
@@ -10,7 +10,6 @@ GLOBAL_CLI_TOOLS = ["age", "cloudflared", "flux", "sops", "jq", "kubeconform", "
|
||||
TALOS_CLI_TOOLS = ["talosctl", "talhelper"]
|
||||
K0S_CLI_TOOLS = ["k0sctl"]
|
||||
|
||||
|
||||
def required(*keys: str):
|
||||
def wrapper_outter(func: Callable):
|
||||
@wraps(func)
|
||||
@@ -22,7 +21,6 @@ def required(*keys: str):
|
||||
return wrapper
|
||||
return wrapper_outter
|
||||
|
||||
|
||||
def _validate_network(network: str, family: int) -> str:
|
||||
try:
|
||||
network = netaddr.IPNetwork(network)
|
||||
@@ -40,9 +38,10 @@ def validate_python_version() -> None:
|
||||
|
||||
|
||||
@required("distribution")
|
||||
def validate_cli_tools(distribution: str, **_) -> None:
|
||||
if distribution not in DISTRIBUTIONS:
|
||||
raise ValueError(f"Invalid distribution {distribution}")
|
||||
def validate_cli_tools(distribution: dict, **_) -> None:
|
||||
distro = distribution.get("type")
|
||||
if distro not in DISTRIBUTIONS:
|
||||
raise ValueError(f"Invalid distribution {distro}")
|
||||
for tool in GLOBAL_CLI_TOOLS:
|
||||
if not which(tool):
|
||||
raise ValueError(f"Missing required CLI tool {tool}")
|
||||
@@ -55,9 +54,10 @@ def validate_cli_tools(distribution: str, **_) -> None:
|
||||
|
||||
|
||||
@required("distribution")
|
||||
def validate_distribution(distribution: str, **_) -> None:
|
||||
if distribution not in DISTRIBUTIONS:
|
||||
raise ValueError(f"Invalid distribution {distribution}")
|
||||
def validate_distribution(distribution: dict, **_) -> None:
|
||||
distro = distribution.get("type")
|
||||
if distro not in DISTRIBUTIONS:
|
||||
raise ValueError(f"Invalid distribution {distro}")
|
||||
|
||||
|
||||
@required("timezone")
|
||||
@@ -98,6 +98,9 @@ def validate_cluster_networks(cluster: dict, feature_gates: dict, **_) -> None:
|
||||
|
||||
|
||||
def massage_config(data: dict) -> dict:
|
||||
data["distribution"] = data.get("distribution", {})
|
||||
data["nodes"] = data.get("nodes", [])
|
||||
data["cluster"] = data.get("cluster", {})
|
||||
data["flux"] = data.get("flux", {})
|
||||
data["cloudflare"] = data.get("cloudflare", {})
|
||||
data["feature_gates"] = data.get("feature_gates", {})
|
||||
|
||||
Reference in new issue
Block a user