From 52f4365aeb95a1c5c2d7affc5bf6f029012f3793 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Fri, 30 Oct 2026 23:23:47 -0600 Subject: [PATCH] Handle optional GitOps fields in scheduling preflight --- scripts/scheduling-preflight.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/scheduling-preflight.py b/scripts/scheduling-preflight.py index 3c8acad..38a5169 100644 --- a/scripts/scheduling-preflight.py +++ b/scripts/scheduling-preflight.py @@ -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"]