#/bin/bash
#set -e
file="origin/test/extended/util/image/zz_generated.txt"
release=$1

pushd origin; git fetch origin; git checkout $release; popd

test_dir="image-scan-"$release
rm -rf $test_dir; mkdir $test_dir

while read line; do
   [[ $line =~ ^#.* ]] && continue

   image_src=$(echo $line | cut -d ' ' -f1)
   image_dst=$(echo $line | cut -d ' ' -f2)
   rm -f $test_dir/src.txt $test_dir/dst.txt

   podman manifest inspect $image_src > $test_dir/src.txt
   podman manifest inspect $image_dst > $test_dir/dst.txt

   result=0   
   diff $test_dir/src.txt $test_dir/dst.txt || result=$?
   case $result in
   1) echo "BAD IMAGE: $line" ;;
   0) echo "GOOD IMAGE: $line" ;;
   *) echo "ERROR: diff failed for $line"
   esac
done < $file

rm -r $test_dir
