Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Update docker_registry2" #7601

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Revert "Update docker_registry2"
  • Loading branch information
jurre authored Jul 20, 2023
commit b2a75c8dd75042907f03a29b73039d617aa10020
2 changes: 1 addition & 1 deletion common/dependabot-common.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "aws-sdk-ecr", "~> 1.5"
spec.add_dependency "bundler", ">= 1.16", "< 3.0.0"
spec.add_dependency "commonmarker", ">= 0.20.1", "< 0.24.0"
spec.add_dependency "docker_registry2", "~> 1.17.0"
spec.add_dependency "docker_registry2", "~> 1.14.0"
spec.add_dependency "excon", "~> 0.96", "< 0.100"
spec.add_dependency "faraday", "2.7.4"
spec.add_dependency "faraday-retry", "2.1.0"
Expand Down
3 changes: 1 addition & 2 deletions docker/lib/dependabot/docker/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ def digest_of(tag)
end

def fetch_digest_of(tag)
manifest = docker_registry_client.manifest(docker_repo_name, tag)
manifest.headers[:docker_content_digest]&.delete_prefix("sha256:")
docker_registry_client.digest(docker_repo_name, tag)&.delete_prefix("sha256:")
rescue *transient_docker_errors => e
attempt ||= 1
attempt += 1
Expand Down
78 changes: 39 additions & 39 deletions docker/spec/dependabot/docker/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
end

def stub_tag_with_no_digest(tag)
stub_request(:get, repo_url + "manifests/#{tag}").
and_return(body: "{}", status: 200, headers: JSON.parse(headers_response).except("docker_content_digest"))
stub_request(:head, repo_url + "manifests/#{tag}").
and_return(status: 200, headers: JSON.parse(headers_response).except("docker_content_digest"))
end

describe "#up_to_date?" do
Expand All @@ -72,8 +72,8 @@ def stub_tag_with_no_digest(tag)
before do
new_headers =
fixture("docker", "registry_manifest_headers", "generic.json")
stub_request(:get, repo_url + "manifests/17.10").
and_return(status: 200, body: "{}", headers: JSON.parse(new_headers))
stub_request(:head, repo_url + "manifests/17.10").
and_return(status: 200, body: "", headers: JSON.parse(new_headers))
end

it { is_expected.to be_falsy }
Expand Down Expand Up @@ -109,8 +109,8 @@ def stub_tag_with_no_digest(tag)
end

before do
stub_request(:get, repo_url + "manifests/artful").
and_return(status: 200, body: "{}", headers: JSON.parse(headers_response))
stub_request(:head, repo_url + "manifests/artful").
and_return(status: 200, headers: JSON.parse(headers_response))
end

context "that is out-of-date" do
Expand Down Expand Up @@ -154,8 +154,8 @@ def stub_tag_with_no_digest(tag)
end

before do
stub_request(:get, repo_url + "manifests/latest").
and_return(status: 200, body: "{}", headers: JSON.parse(headers_response))
stub_request(:head, repo_url + "manifests/latest").
and_return(status: 200, headers: JSON.parse(headers_response))
end

context "that is out-to-date" do
Expand Down Expand Up @@ -184,10 +184,10 @@ def stub_tag_with_no_digest(tag)
before do
stub_request(:get, repo_url + "tags/list").
and_return(status: 200, body: registry_tags)
stub_request(:get, repo_url + "manifests/3.6").
and_return(status: 200, body: "{}", headers: JSON.parse(headers_response))
stub_request(:get, repo_url + "manifests/3.6.3").
and_return(status: 200, body: "{}", headers: JSON.parse(headers_response))
stub_request(:head, repo_url + "manifests/3.6").
and_return(status: 200, headers: JSON.parse(headers_response))
stub_request(:head, repo_url + "manifests/3.6.3").
and_return(status: 200, headers: JSON.parse(headers_response))
end

it { is_expected.to be_falsey }
Expand Down Expand Up @@ -364,19 +364,19 @@ def stub_tag_with_no_digest(tag)
let(:version) { "12.10" }

before do
stub_request(:get, repo_url + "manifests/17.10").
stub_request(:head, repo_url + "manifests/17.10").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response)
)

# Stub the latest version to return a different digest
["17.04", "latest"].each do |version|
stub_request(:get, repo_url + "manifests/#{version}").
stub_request(:head, repo_url + "manifests/#{version}").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response.gsub("3ea1ca1", "4da71a2"))
)
end
Expand Down Expand Up @@ -495,28 +495,28 @@ def stub_tag_with_no_digest(tag)
stub_request(:get, repo_url + "tags/list").
and_return(status: 200, body: registry_tags)

stub_request(:get, repo_url + "manifests/#{version}").
stub_request(:head, repo_url + "manifests/#{version}").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response)
)

# Stub the latest version to return a different digest
["jdk-11.0.2.9", "latest"].each do |version|
stub_request(:get, repo_url + "manifests/#{version}").
stub_request(:head, repo_url + "manifests/#{version}").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response.gsub("3ea1ca1", "4da71a2"))
)
end

# Stub an oddly-formatted version to come back as a pre-release
stub_request(:get, repo_url + "manifests/jdk-11.28").
stub_request(:head, repo_url + "manifests/jdk-11.28").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response.gsub("3ea1ca1", "11171a2"))
)
end
Expand All @@ -537,19 +537,19 @@ def stub_tag_with_no_digest(tag)
stub_request(:get, repo_url + "tags/list").
and_return(status: 200, body: registry_tags)

stub_request(:get, repo_url + "manifests/#{version}").
stub_request(:head, repo_url + "manifests/#{version}").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response)
)

# Stub the latest version to return a different digest
["17.0.2_8-jre-alpine", "latest"].each do |version|
stub_request(:get, repo_url + "manifests/#{version}").
stub_request(:head, repo_url + "manifests/#{version}").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response.gsub("3ea1ca1", "4da71a2"))
)
end
Expand All @@ -562,10 +562,10 @@ def stub_tag_with_no_digest(tag)

context "followed by numbers and with less components than other version but higher underscore part" do
before do
stub_request(:get, repo_url + "manifests/#{latest_version}").
stub_request(:head, repo_url + "manifests/#{latest_version}").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response.gsub("3ea1ca1", "4da71a2"))
)
end
Expand Down Expand Up @@ -712,19 +712,19 @@ def stub_tag_with_no_digest(tag)
let(:latest_versions) { %w(2-sdk 2.1-sdk 2.1.401-sdk) }

before do
stub_request(:get, repo_url + "manifests/2.2-sdk").
stub_request(:head, repo_url + "manifests/2.2-sdk").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response)
)

# Stub the latest version to return a different digest
[*latest_versions, "latest"].each do |version|
stub_request(:get, repo_url + "manifests/#{version}").
stub_request(:head, repo_url + "manifests/#{version}").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response.gsub("3ea1ca1", "4da71a2"))
)
end
Expand Down Expand Up @@ -789,7 +789,7 @@ def stub_tag_with_no_digest(tag)

context "every time" do
before do
stub_request(:get, repo_url + "manifests/latest").
stub_request(:head, repo_url + "manifests/latest").
to_return(status: 404)
end

Expand Down Expand Up @@ -1055,8 +1055,8 @@ def stub_tag_with_no_digest(tag)
before do
new_headers =
fixture("docker", "registry_manifest_headers", "generic.json")
stub_request(:get, repo_url + "manifests/latest").
and_return(status: 200, body: "{}", headers: JSON.parse(new_headers))
stub_request(:head, repo_url + "manifests/latest").
and_return(status: 200, body: "", headers: JSON.parse(new_headers))
end

it "updates the digest" do
Expand All @@ -1081,8 +1081,8 @@ def stub_tag_with_no_digest(tag)
before do
new_headers =
fixture("docker", "registry_manifest_headers", "generic.json")
stub_request(:get, repo_url + "manifests/17.10").
and_return(status: 200, body: "{}", headers: JSON.parse(new_headers))
stub_request(:head, repo_url + "manifests/17.10").
and_return(status: 200, body: "", headers: JSON.parse(new_headers))
end

it "updates the tag and the digest" do
Expand Down Expand Up @@ -1139,10 +1139,10 @@ def stub_tag_with_no_digest(tag)

def stub_same_sha_for(*tags)
tags.each do |tag|
stub_request(:get, repo_url + "manifests/#{tag}").
stub_request(:head, repo_url + "manifests/#{tag}").
and_return(
status: 200,
body: "{}",
body: "",
headers: JSON.parse(headers_response.gsub(/"sha256:(.*)"/, "\"sha256:#{'a' * 40}\""))
)
end
Expand Down
4 changes: 2 additions & 2 deletions updater/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PATH
aws-sdk-ecr (~> 1.5)
bundler (>= 1.16, < 3.0.0)
commonmarker (>= 0.20.1, < 0.24.0)
docker_registry2 (~> 1.17.0)
docker_registry2 (~> 1.14.0)
excon (~> 0.96, < 0.100)
faraday (= 2.7.4)
faraday-retry (= 2.1.0)
Expand Down Expand Up @@ -144,7 +144,7 @@ GEM
irb (>= 1.5.0)
reline (>= 0.3.1)
diff-lcs (1.5.0)
docker_registry2 (1.17.0)
docker_registry2 (1.14.0)
rest-client (>= 1.8.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
Expand Down
Loading