Add verify docker prefix (#90)

* Add verify docker prefix

* Update args

* Fix the order
This commit is contained in:
Shiming Zhang
2022-03-07 16:56:08 +08:00
committed by GitHub
parent faa1091c40
commit 8ad93d5517
5 changed files with 36 additions and 4 deletions

26
hack/verify-docker-prefix.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
file=$1
cp ${file} ${file}.bak
cat ${file} | grep docker.io | grep library | sed 's#docker.io/library/#docker.io/#' >>${file}.bak
cat ${file} | grep -e "docker\.io/\w\+:\|docker\.io/\w\+$" | sed 's#docker.io/#docker.io/library/#' >>${file}.bak
$(dirname "${BASH_SOURCE}")/fmt.sh ${file}.bak
result=$(diff ${file} ${file}.bak)
if [[ "${result}" != "" ]]; then
echo "Usually docker.io/* and docker.io/library/* appear in pairs "
echo "Please run following command to fix the issue:"
echo "cat <<EOF >> ${file}"
echo "${result}" | grep "^>" | sed 's/^>\s\+//'
echo "EOF"
echo "./hack/fmt.sh ${file}"
exit 1
fi
rm ${file}.bak