Skip to content
6 changes: 4 additions & 2 deletions docker/lib/dependabot/docker/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,17 @@ def tags_from_registry
@tags_from_registry ||=
begin
client = docker_registry_client

client.tags(docker_repo_name, auto_paginate: true).fetch("tags")
repo = docker_repo_name
client.tags(repo, auto_paginate: true).fetch("tags")
Comment thread
honeyankit marked this conversation as resolved.
Outdated
rescue *transient_docker_errors
attempt ||= 1
attempt += 1
raise if attempt > 3

retry
end
rescue DockerRegistry2::NotFound
raise DockerRegistry2::NotFound, "404 Not Found. Image https://#{registry_hostname}/#{repo} not found"
Comment thread
deivid-rodriguez marked this conversation as resolved.
Outdated
Comment thread
honeyankit marked this conversation as resolved.
Outdated
rescue DockerRegistry2::RegistryAuthenticationException,
RestClient::Forbidden
raise PrivateSourceAuthenticationFailure, registry_hostname
Expand Down
38 changes: 38 additions & 0 deletions docker/spec/dependabot/docker/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,44 @@
it { is_expected.to eq("17.04") }
end

context "when image is not found" do
let(:tags_fixture_name) { "ubuntu_no_latest.json" }

context "with replaces-base set to true" do
let(:credentials) do
[{
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => "token"
}, {
"type" => "docker_registry",
"registry" => "registry-host.io:5000",
"username" => "grey",
"password" => "pa55word",
"replaces-base" => true
}]
end

before do
tags_url = "https://registry-host.io:5000/v2/ubuntu/tags/list"
stub_request(:get, tags_url).
and_return(
status: 404,
body: ""
)
end

it "raises a to DockerRegistry2::NotFound error" do
error_class = DockerRegistry2::NotFound
expect { checker.latest_version }.
to raise_error(error_class) do |error|
expect(error.message).to eq("404 Not Found. Image https://registry-host.io:5000/ubuntu not found")
end
end
end
end

context "when the dependency's version has a prefix" do
let(:version) { "artful-20170826" }
it { is_expected.to eq("artful-20170916") }
Expand Down