Skip to content

Commit

Permalink
Merge pull request #5734 from dependabot/deivid-rodriguez/docker-issues
Browse files Browse the repository at this point in the history
Allow updating Java images with "update releases"
  • Loading branch information
jeffwidman authored Sep 17, 2022
2 parents f78ab8b + 559237a commit 37c897a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker/lib/dependabot/docker/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module Dependabot
module Docker
class UpdateChecker < Dependabot::UpdateCheckers::Base
VERSION_REGEX =
/v?(?<version>[0-9]+(?:(?:\.[a-z0-9]+)|(?:-(?:kb)?[0-9]+))*)/i.freeze
/v?(?<version>[0-9]+(?:(?:\.[_a-z0-9]+)|(?:-(?:kb)?[0-9]+))*)/i.freeze
VERSION_WITH_SFX = /^#{VERSION_REGEX}(?<suffix>-[a-z0-9.\-]+)?$/i.freeze
VERSION_WITH_PFX = /^(?<prefix>[a-z0-9.\-]+-)?#{VERSION_REGEX}$/i.freeze
VERSION_WITH_PFX_AND_SFX =
Expand Down
3 changes: 3 additions & 0 deletions docker/lib/dependabot/docker/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
module Dependabot
module Docker
class Version < Gem::Version
def initialize(version)
super(version.tr("_", "."))
end
end
end
end
Expand Down
37 changes: 37 additions & 0 deletions docker/spec/dependabot/docker/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,43 @@
it { is_expected.to eq("jdk-11.0.2.9-alpine-slim") }
end

context "when the dependencies have a underscore" do
let(:dependency_name) { "eclipse-temurin" }
let(:tags_fixture_name) { "eclipse-temurin.json" }
let(:repo_url) do
"https://registry.hub.docker.com/v2/library/eclipse-temurin/"
end
let(:headers_response) do
fixture("docker", "registry_manifest_headers", "ubuntu_17.10.json")
end
before do
stub_request(:get, repo_url + "tags/list").
and_return(status: 200, body: registry_tags)

stub_request(:head, repo_url + "manifests/#{version}").
and_return(
status: 200,
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(:head, repo_url + "manifests/#{version}").
and_return(
status: 200,
body: "",
headers: JSON.parse(headers_response.gsub("3ea1ca1", "4da71a2"))
)
end
end

context "followed by numbers" do
let(:version) { "17.0.1_12-jre-alpine" }
it { is_expected.to eq("17.0.2_8-jre-alpine") }
end
end

context "when the dependency has a namespace" do
let(:dependency_name) { "moj/ruby" }
let(:version) { "2.4.0" }
Expand Down
11 changes: 11 additions & 0 deletions docker/spec/fixtures/docker/registry_tags/eclipse-temurin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "library/eclipse-temurin",
"tags": [
"17.0.1_12-jre-windowsservercore-ltsc2022",
"17.0.2_8-jre-alpine",
"17.0.1_12-jre-alpine",
"17-jre-alpine",
"11.0.14_9-jre-alpine",
"11-jre-alpine"
]
}

0 comments on commit 37c897a

Please sign in to comment.