feat: Do not rely on k0s file uploads - instead use curl (#1229)
* feat: Do not rely on k0s file uploads - instead use curl Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: add bootstrap_advanced_flags to validation Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: only skip tests for non-static config Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: only skip tests for non-static config Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: issues in k0s scripts Signed-off-by: Devin Buhl <devin@buhl.casa> * update: readme Signed-off-by: Devin Buhl <devin@buhl.casa> * update: taskfile Signed-off-by: Devin Buhl <devin@buhl.casa> * update: taskfile Signed-off-by: Devin Buhl <devin@buhl.casa> * update: k0s config and remove ansible hook Signed-off-by: Devin Buhl <devin@buhl.casa> --------- Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
1 parent
5ef0438529
commit
d9c7fd44ba
17 files changed
+121
-110
No files matched your search
@@ -100,14 +100,17 @@ def validate_distribution(distribution: str, **_) -> None:
|
||||
_validate_distribution(distribution)
|
||||
|
||||
|
||||
@required("bootstrap_github_username", "bootstrap_github_repository_name", "bootstrap_github_repository_branch")
|
||||
def validate_github(username: str, repository: str, branch: str, **_) -> None:
|
||||
@required("bootstrap_github_username", "bootstrap_github_repository_name", "bootstrap_advanced_flags")
|
||||
def validate_github(username: str, repository: str, advanced_flags: dict, **_) -> None:
|
||||
try:
|
||||
request = requests.get(f"https://api.github.com/repos/{username}/{repository}/branches/{branch}")
|
||||
request = requests.get(
|
||||
f"https://api.github.com/repos/{username}/{repository}/branches/{advanced_flags.get('github_repository_branch', 'main')}")
|
||||
if request.status_code != 200:
|
||||
raise ValueError(f"GitHub repository {username}/{repository} branch {branch} not found")
|
||||
raise ValueError(
|
||||
f"GitHub repository {username}/{repository} branch {advanced_flags.get('github_repository_branch', 'main')} not found")
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise ValueError(f"GitHub repository {username}/{repository} branch {branch} not found") from e
|
||||
raise ValueError(
|
||||
f"GitHub repository {username}/{repository} branch {advanced_flags.get('github_repository_branch', 'main')} not found") from e
|
||||
|
||||
|
||||
@required("bootstrap_age_public_key")
|
||||
@@ -240,18 +243,27 @@ def validate_nodes(node_cidr: str, nodes: dict[list], distribution: str, **_) ->
|
||||
_validate_node(node, node_cidr, distribution)
|
||||
|
||||
|
||||
def massage(data: dict) -> dict:
|
||||
data["bootstrap_advanced_flags"] = data.get("bootstrap_advanced_flags", {})
|
||||
return data
|
||||
|
||||
def validate(data: dict) -> None:
|
||||
user_data = massage(data)
|
||||
|
||||
validate_python_version()
|
||||
validate_cli_tools(data)
|
||||
validate_distribution(data)
|
||||
if not data.get("bootstrap_private_github_repo"):
|
||||
validate_github(data)
|
||||
validate_age(data)
|
||||
validate_timezone(data)
|
||||
validate_acme_email(data)
|
||||
validate_flux_github_webhook_token(data)
|
||||
validate_cloudflare(data)
|
||||
validate_host_network(data)
|
||||
validate_bootstrap_dns_server(data)
|
||||
validate_cluster_cidrs(data)
|
||||
validate_nodes(data)
|
||||
validate_cli_tools(user_data)
|
||||
validate_distribution(user_data)
|
||||
validate_age(user_data)
|
||||
validate_timezone(user_data)
|
||||
validate_bootstrap_dns_server(user_data)
|
||||
validate_cluster_cidrs(user_data)
|
||||
validate_flux_github_webhook_token(user_data)
|
||||
validate_host_network(user_data)
|
||||
validate_acme_email(user_data)
|
||||
|
||||
if not user_data.get("bootstrap_private_github_repo"):
|
||||
validate_github(user_data)
|
||||
|
||||
if not user_data.get("skip_tests", False):
|
||||
validate_cloudflare(user_data)
|
||||
validate_nodes(user_data)
|
||||
Reference in new issue
Block a user