diff --git a/scripts/run_platform.sh b/scripts/run_platform.sh index a51a59b..a27889f 100755 --- a/scripts/run_platform.sh +++ b/scripts/run_platform.sh @@ -533,7 +533,7 @@ if command -v kj >/dev/null 2>&1; then if [ -f "$TF_DIR/tfplan" ]; then terraform -chdir="$TF_DIR" show -json tfplan > "$WORK/tfshow.json" 2>/dev/null || true if [ -s "$WORK/tfshow.json" ]; then - python3 - <<'PY' > "$WORK/kj-pcr.json" 2>"$WORK/kj.err" || echo "[]" + python3 - "$WORK/tfshow.json" "$CONTRACT_ID" <<'PY' > "$WORK/kj-pcr.json" 2>"$WORK/kj.err" || echo "[]" import json, sys from pathlib import Path sys.path.insert(0, ".") @@ -541,10 +541,11 @@ import importlib.util _spec = importlib.util.spec_from_file_location("kj_engine", "adapters/kyverno-json/kyverno_json_engine.py") _mod = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(_mod) +_payload_path, _contract_id = sys.argv[1], sys.argv[2] eng = _mod.KyvernoJsonEngine() if not eng.is_configured(): print("[]"); sys.exit(0) -out = eng.evaluate(json.load(open("$WORK/tfshow.json")), Path("adapters/kyverno-json/policies/plan-json"), "$CONTRACT_ID") +out = eng.evaluate(json.load(open(_payload_path)), Path("adapters/kyverno-json/policies/plan-json"), _contract_id) print(json.dumps(out)) PY if [ -s "$WORK/kj-pcr.json" ]; then