# Check raw Kubernetes manifests: schema-valid, no floating `latest` image
# tag, and every container declares resource requests/limits.
# Usage: check_manifests.sh <manifests-dir-or-file>
files=$(find "$TARGET" -name '*.yaml' -o -name '*.yml' 2>/dev/null)
if [[ -z "$files" ]]; then
echo "⚠️ no manifest files found under $TARGET"
if command -v kubeconform >/dev/null 2>&1; then
if cat $files | kubeconform -strict -summary -ignore-missing-schemas; then
echo "✅ kubeconform -strict clean"
echo "❌ kubeconform found schema violations"
echo "⚠️ kubeconform not on PATH — skipped schema check"
if grep -rniE 'image:\s*.*:latest' $files 2>/dev/null; then
echo "❌ found an image pinned to :latest — use a pinned digest or version tag"
echo "✅ no :latest image tags found"
if grep -q '^kind:\s*Deployment\|^kind:\s*StatefulSet' "$f" 2>/dev/null || grep -qE '^\s*kind:\s*(Deployment|StatefulSet)' "$f"; then
if grep -q 'resources:' "$f"; then
echo "✅ $f: declares resources"
echo "❌ $f: Deployment/StatefulSet with no resources: block — set requests/limits"