Skip to content

Commit

Permalink
Only use base tags with our expected archs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmj committed May 3, 2024
1 parent 6624fe3 commit d7ac610
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/bob/docker_hub.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ defmodule Bob.DockerHub do
end
end

def delete_tag(repo, tag) do
url = @dockerhub_url <> "v2/repositories/#{repo}/tags/#{tag}"
headers = headers()
opts = [:with_body, recv_timeout: 20_000]

result =
Bob.HTTP.retry("DockerHub #{url}", fn ->
:hackney.request(:delete, url, headers, "", opts)
end)

case result do
{:ok, 204, _headers, _body} -> :ok
{:ok, 404, _headers, _body} -> :ok
end
end

def headers() do
if token = Application.get_env(:bob, :dockerhub_token) do
[{"authorization", "JWT #{token}"}]
Expand Down
3 changes: 2 additions & 1 deletion lib/bob/job/docker_checker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ defmodule Bob.Job.DockerChecker do
tags =
("library/" <> repo)
|> Bob.DockerHub.fetch_repo_tags()
|> Enum.map(&elem(&1, 0))
|> Enum.filter(fn {_tag, archs} -> Enum.all?(@archs, &(&1 in archs)) end)
|> Enum.map(fn {tag, _archs} -> tag end)
|> Enum.sort(&(&1 >= &2))

Enum.map(regexes, fn regex ->
Expand Down

0 comments on commit d7ac610

Please sign in to comment.