INNER CODE UNIT · Python
run_kube_score
valqore/valqore · benchmarks/run_benchmark.py:190
def run_kube_score() -> dict:
# kube-score is K8s-manifest-only; it ignores Terraform/Dockerfile. We point
# it at the YAML manifests in the corpus and count CRITICAL/WARNING checks.
if not shutil.which("kube-score"):
return {"available": False}
manifests = [str(p) for p in sorted(CORPUS.glob("*.yaml")) + sorted(CORPUS.glob("*.yml"))]
if not manifests:
return {"available": False}
data = _run_json(["kube-score", "score", "--output-format", "json", *manifests])
if not data:
return {"available": False}
failed = 0
try:
for obj in (data if isinstance(data, list) else []):
for check in obj.get("checks", []) or []:
# grade < 10 (kube-score's "OK") means a warning/critical finding
if check.get("grade", 10) < 10 and not check.get("skipped"):
failed += 1