Skip to content

Commit 31f1ebc

Browse files
committed
Update architecture checks to be more defensive against server failures
We've had a recent rash of GitHub hiccups that cause bad updates like docker-library/official-images@3b308f8 -- hopefully this change helps make those into `update.sh` job failures instead of bad commits, by checking the HTTP status codes directly and only accepting the answer as authoritative for 200 and 404 explicitly.
1 parent c1c6e2e commit 31f1ebc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

generate-stackbrew-library.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ _tags() {
7676
return 0
7777
}
7878

79+
_spider() {
80+
local code
81+
code="$(curl --head --silent --location -o /dev/null --write-out '%{http_code}' "$@")"
82+
case "$code" in
83+
200) return 0 ;;
84+
404) return 1 ;;
85+
esac
86+
echo >&2 "error: unexpected status code $code while fetching: $*"
87+
exit 1
88+
}
89+
7990
for version; do
8091
export version
8192

@@ -110,7 +121,7 @@ for version; do
110121
variantArches=()
111122
for arch in "${arches[@]}"; do
112123
archCommit="${archCommits[$arch]}"
113-
if wget --quiet --spider -O /dev/null -o /dev/null "$rawGitUrl/$archCommit/$dir/$arch/rootfs.tar.gz"; then
124+
if _spider "$rawGitUrl/$archCommit/$dir/$arch/rootfs.tar.gz"; then
114125
variantArches+=( "$arch" )
115126
if [ -z "${archLatestDir[$arch]:-}" ]; then
116127
# record the first supported directory per architecture for "latest" and friends

0 commit comments

Comments
 (0)