This commit is contained in:
Shiming Zhang
2021-09-13 22:49:23 +08:00
parent 3e8963cad4
commit 02538b3185
2 changed files with 11 additions and 10 deletions

View File

@@ -100,7 +100,7 @@ function list-tags() {
local raw="$(skopeo list-tags --tls-verify=false "docker://${image}" | jq -r '.Tags[]' | sort)"
if [[ "${EXCLUDED}" != "" ]]; then
raw="$(echo "${raw}" | grep -v -E "${EXCLUDED}")"
raw="$(echo "${raw}" | grep -v -E "${EXCLUDED}" || :)"
fi
echo "${raw}"
}
@@ -134,11 +134,11 @@ function diff-image() {
local tags1="$(list-tags ${image1})"
local tags2="$(list-tags ${image2})"
local diff_raw="$(diff --unified <(echo "${tags1}") <(echo "${tags2}") | grep -v -E '^---' | grep -v -E '^\+\+\+')"
local diff_data="$(echo "${diff_raw}" | grep -v -E '^ ')"
local diff_raw="$(diff --unified <(echo "${tags1}") <(echo "${tags2}") | grep -v -E '^---' | grep -v -E '^\+\+\+' || :)"
local diff_data="$(echo "${diff_raw}" | grep -v -E '^ ' || :)"
if [[ "${INCREMENTAL}" == "true" ]]; then
diff_data="$(echo "${diff_data}" | grep -v -E '^\+')"
diff_data="$(echo "${diff_data}" | grep -v -E '^\+' || :)"
fi
if [[ "${diff_data}" != "" ]]; then
@@ -151,15 +151,15 @@ function diff-image() {
echo "DEBUG: diff:" >&2
echo "${diff_data}" >&2
fi
for tag in $(echo "$(echo "${diff_raw}" | grep -E '^-')"); do
for tag in $(echo "${diff_raw}" | grep -E '^-' || :); do
tag="${tag#-}"
echo "${SELF}: UNSYNC: ${image1}:${tag} and ${image2}:${tag} are not in synchronized, ${image2}:${tag} is empty" >&2
done
for tag in $(echo "$(echo "${diff_raw}" | grep -E '^\+')"); do
for tag in $(echo "${diff_raw}" | grep -E '^\+' || :); do
tag="${tag#+}"
echo "${SELF}: UNSYNC: ${image1}:${tag} and ${image2}:${tag} are not in synchronized, ${image1}:${tag} is empty" >&2
done
echo "$(echo "${diff_raw}" | grep -E '^ ' | tr -d ' ')"
echo "$(echo "${diff_raw}" | grep -E '^ ' | tr -d ' ' || :)"
return 1
fi
echo "${SELF}: SYNC-TAGS: ${image1} and ${image2} are in synchronized" >&2