Skip to content

Commit ea5bed5

Browse files
authored
use dohead method to fetch blob metadata for Docker tags (#12712)
* use `dohead` method to fetch blob metadata for Docker tags * change stub from get to head
1 parent 9bcdfbd commit ea5bed5

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

docker/lib/dependabot/docker/update_checker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def get_tag_publication_details(tag)
224224

225225
blob_info = with_retries(max_attempts: 3, errors: transient_docker_errors) do
226226
client = docker_registry_client
227-
client.blob(docker_repo_name, first_digest)
227+
client.dohead "v2/#{docker_repo_name}/blobs/#{first_digest}"
228228
end
229229

230230
last_modified = blob_info.headers[:last_modified]

docker/spec/dependabot/docker/update_checker_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,9 +1489,8 @@ def stub_tag_with_no_digest(tag)
14891489
blob_headers =
14901490
fixture("docker", "image_blobs_headers", "ubuntu_17.10_38d6c1.json")
14911491

1492-
stub_request(:get, repo_url + "blobs/sha256:9c4bf7dbb981591d4a1169138471afe4bf5ff5418841d00e30a7ba372e38d6c1")
1493-
.and_return(status: 200, body: fixture("docker", "image_blobs", "ubuntu_17.10_38d6c1.json"),
1494-
headers: JSON.parse(blob_headers))
1492+
stub_request(:head, repo_url + "blobs/sha256:9c4bf7dbb981591d4a1169138471afe4bf5ff5418841d00e30a7ba372e38d6c1")
1493+
.and_return(status: 200, headers: JSON.parse(blob_headers))
14951494
end
14961495

14971496
it { is_expected.to eq("17.10") }

0 commit comments

Comments
 (0)