Handle optional GitOps fields in scheduling preflight
Homelab Main / validate (push) Waiting to run Details
Homelab Main / running-update (push) Blocked by required conditions Details
Homelab Main / debian-ops (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-10-30 23:23:47 -06:00
parent 146a249468
commit 52f4365aeb
1 changed files with 4 additions and 4 deletions

View File

@ -502,7 +502,7 @@ def manifests_from_plan(args, plan, kubectl):
path.chmod(0o600)
command.extend(["--values", str(path)])
rendered = list(yaml.safe_load_all(run(command, timeout=180)))
for item in rendered:
for item in rendered or []:
if item:
metadata = item.setdefault("metadata", {})
metadata["namespace"] = metadata.get("namespace") or value["namespace"]
@ -513,10 +513,10 @@ def manifests_from_plan(args, plan, kubectl):
if not item:
raise CannotCheck(f"{resource['address']}: planned manifest is unknown")
if item.get("kind") == "Application":
source = item["spec"]["source"]
source = item.get("spec", {}).get("source") or {}
if not source.get("path") or any(source.get(key) for key in ("helm", "plugin", "directory")):
raise CannotCheck(f"{item['metadata']['name']}: only local Kustomize/plain-manifest Application sources are supported")
if set(source.get("kustomize", {})) - {"images"}:
if set(source.get("kustomize") or {}) - {"images"}:
raise CannotCheck(f"{item['metadata']['name']}: Argo-specific Kustomize placement overrides require separate rendering")
path = (Path(args.repo_root) / source["path"]).resolve()
if not path.is_relative_to(Path(args.repo_root).resolve()):
@ -547,7 +547,7 @@ def manifests_from_plan(args, plan, kubectl):
for manifest in sorted(path.iterdir()):
if manifest.is_file() and manifest.suffix in (".yaml", ".yml", ".json"):
rendered.extend(yaml.safe_load_all(manifest.read_text()))
for app_item in rendered:
for app_item in rendered or []:
if app_item:
metadata = app_item.setdefault("metadata", {})
metadata["namespace"] = metadata.get("namespace") or item["spec"]["destination"]["namespace"]