From ebfc47a6899c36c25dcfa3f6fe9e458cf1eb6e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Ollivier?= Date: Wed, 15 Jan 2025 13:58:55 +0100 Subject: [PATCH] Leverage the dockerhub account for skopeo if set (#30) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Leverage the dockerhub account if they are set in env skopeo directly pulls from docker.io which easily reaches the anon pull rate limit. Please see shared_database and observability failing because of skopeo (whatever the use of private mirror or mirror.gcr.io): https://github.com/cnti-testcatalog/testsuite/actions/runs/12674901774/job/35470396257?pr=2203 https://github.com/cnti-testcatalog/testsuite/actions/runs/12674901774/job/35470398665?pr=2203 Signed-off-by: Cédric Ollivier Co-authored-by: Martin Matyas --- cluster_tools.cr | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cluster_tools.cr b/cluster_tools.cr index 356ea38b..c6b26f42 100644 --- a/cluster_tools.cr +++ b/cluster_tools.cr @@ -249,7 +249,14 @@ module ClusterTools def self.official_content_digest_by_image_name(image_name) Log.info { "official_content_digest_by_image_name: #{image_name}"} - result = exec("skopeo inspect docker://#{image_name}") + if ENV["DOCKERHUB_USERNAME"]? && ENV["DOCKERHUB_PASSWORD"]? + Log.info { "Using USERNAME and PASSWORD for accessing the registry via skopeo" } + registry_creds = "--creds #{ENV["DOCKERHUB_USERNAME"]}:#{ENV["DOCKERHUB_PASSWORD"]}" + else + Log.info { "Access the registry anonymously via skopeo" } + registry_creds = "" + end + result = exec("skopeo inspect #{registry_creds} docker://#{image_name}") response = result[:output] if result[:status].success? && !response.empty? return JSON.parse(response)