Revision f785e5ae
Added by Marek Hulán about 3 years ago
app/models/service/registry_api.rb | ||
---|---|---|
4 | 4 |
DEFAULTS = { |
5 | 5 |
url: 'http://localhost:5000'.freeze, |
6 | 6 |
connection: { omit_default_port: true, |
7 |
headers: { "Content-Type" => "application/json" }} |
|
7 |
headers: { "Content-Type" => "application/json" } |
|
8 |
} |
|
8 | 9 |
} |
9 | 10 |
|
10 | 11 |
attr_accessor :config, :url |
... | ... | |
80 | 81 |
def get_tags(image_name) |
81 | 82 |
get("/v1/repositories/#{image_name}/tags") |
82 | 83 |
rescue => e |
83 |
logger.warn "API v1 - Repository images request failed #{e.backtrace}"
|
|
84 |
Foreman::Logging.exception("API v1 - Repository images request failed", e)
|
|
84 | 85 |
tags_v2(image_name) |
85 | 86 |
end |
86 | 87 |
|
... | ... | |
88 | 89 |
get("/v2/#{image_name}/tags/list")['tags'].map { |tag| { 'name' => tag } } |
89 | 90 |
rescue Docker::Error::NotFoundError |
90 | 91 |
[] |
92 |
rescue Excon::Error::Found => e |
|
93 |
if e.response.status == 302 |
|
94 |
new_path = URI.parse(e.response.headers['Location']).path |
|
95 |
get(new_path)['tags'].map { |tag| { 'name' => tag } } |
|
96 |
else |
|
97 |
::Foreman.exception "Could not load tags using v2", e |
|
98 |
[] |
|
99 |
end |
|
91 | 100 |
end |
92 | 101 |
|
93 | 102 |
def credentials |
Also available in: Unified diff
Fixes #26740 - Support following redirects for docker tags API v2 (#218)