Add example detection script

This commit is contained in:
lawrencegripper
2025-01-14 12:13:15 +00:00
parent 7a88cb1d8b
commit c15fb5f6b2
3 changed files with 43 additions and 3 deletions

30
helpers/pinned-details-chech.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
toolset_files=$(find . -name 'toolset-*.json')
for toolset_file in $toolset_files; do
if [[ "$toolset_file" == *"toolset-schema.json" ]]; then
continue
fi
readarray -t pinned_details < <(jq --compact-output '.. | objects | select(has("review-at"))' "$toolset_file")
for pinned_detail in "${pinned_details[@]}"; do
review_date=$(jq -r '.["review-at"]' <<< "$pinned_detail")
reason=$(jq -r '.["reason"]' <<< "$pinned_detail")
if [ -n "$review_date" ]; then
if [ "$(date -d "$review_date" +%s)" -gt "$(date +%s)" ]; then
echo "ERROR: Overdue review date: $review_date for tool in $toolset_file"
echo " Pinned for '$reason'"
echo ""
fi
if [ "$(date -d "$review_date" +%s)" -le $(( $(date +%s) - 7*24*60*60 )) ]; then
echo "WARNING: Review date is coming up within the next 7 days: $review_date for tool in $toolset_file"
echo " Pinned for '$reason'"
echo ""
fi
fi
done
done