From b9b52d59b87cce8953837505b6797048cafe5b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Thu, 7 Aug 2025 20:45:41 +0200 Subject: [PATCH] download-frozen-image-v2: Use curl -L MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passing the Auth to the redirected location was fixed in curl 7.58: https://curl.se/changes.html#7_58_0 so we no longer need the extra handling and can just use `-L` to let curl handle redirects. Signed-off-by: Paweł Gronowski --- contrib/download-frozen-image-v2.sh | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/contrib/download-frozen-image-v2.sh b/contrib/download-frozen-image-v2.sh index 330ad2e607..4cf6790304 100755 --- a/contrib/download-frozen-image-v2.sh +++ b/contrib/download-frozen-image-v2.sh @@ -72,30 +72,11 @@ fetch_blob() { shift local curlArgs=("$@") - local curlHeaders - curlHeaders="$( - curl -S "${curlArgs[@]}" \ - -H "Authorization: Bearer $token" \ - "$registryBase/v2/$image/blobs/$digest" \ - -o "$targetFile" \ - -D- - )" - curlHeaders="$(echo "$curlHeaders" | tr -d '\r')" - if grep -qE "^HTTP/[0-9](.[0-9])* 3" <<< "$curlHeaders"; then - rm -f "$targetFile" - - local blobRedirect - blobRedirect="$(echo "$curlHeaders" | awk -F ': ' 'tolower($1) == "location" { print $2; exit }')" - if [ -z "$blobRedirect" ]; then - echo >&2 "error: failed fetching '$image' blob '$digest'" - echo "$curlHeaders" | head -1 >&2 - return 1 - fi - - curl -fSL "${curlArgs[@]}" \ - "$blobRedirect" \ - -o "$targetFile" - fi + curl -L -S "${curlArgs[@]}" \ + -H "Authorization: Bearer $token" \ + "$registryBase/v2/$image/blobs/$digest" \ + -o "$targetFile" \ + -D- } # handle 'application/vnd.docker.distribution.manifest.v2+json' manifest