aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/scripts/lint_manifests.py
diff options
context:
space:
mode:
Diffstat (limited to 'kubernetes/scripts/lint_manifests.py')
-rw-r--r--kubernetes/scripts/lint_manifests.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/kubernetes/scripts/lint_manifests.py b/kubernetes/scripts/lint_manifests.py
new file mode 100644
index 0000000..8660608
--- /dev/null
+++ b/kubernetes/scripts/lint_manifests.py
@@ -0,0 +1,28 @@
+import os
+import sys
+from pathlib import Path
+
+
+def get_all_manifests() -> list[str]:
+ """Return a list of file paths that look like k8s manifests."""
+ likely_manifests = []
+ for file in Path.cwd().glob("**/*.yaml"):
+ if file.name in ("secrets.yaml", "ghcr-pull-secrets.yaml"):
+ # Don't lint secret files as they're git-crypted
+ continue
+ if file.stem.startswith("_"):
+ # Ignore manifests that start with _
+ continue
+ if "apiVersion:" not in file.read_text():
+ # Probably not a manifest
+ continue
+ likely_manifests.append(str(file))
+ return likely_manifests
+
+
+if __name__ == "__main__":
+ if sys.argv[1] == "diff":
+ arg = " -f ".join([""] + get_all_manifests())
+ os.system("kubectl diff" + arg) # noqa: S605
+ elif sys.argv[1] == "find":
+ print("\n".join(get_all_manifests())) # noqa: T201