From 0ad17f594ada75e801138c07d149bde0741aea5c Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 12 May 2023 10:29:29 -0700 Subject: [PATCH] Adjust "Docker Hub" URL references to use a shared variable (This makes testing against Hub's staging environment more straightforward.) --- push.pl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/push.pl b/push.pl index 4c871ea9f..6449690cb 100755 --- a/push.pl +++ b/push.pl @@ -43,8 +43,10 @@ unless (defined $password) { $password = $term->get_reply(prompt => 'Hub Password'); # TODO hide the input? O:) } -my $login = $ua->post('https://hub.docker.com/v2/users/login/' => {} => json => { username => $username, password => $password }); -die 'login failed' unless $login->res->is_success; +my $dockerHub = 'https://hub.docker.com'; + +my $login = $ua->post($dockerHub . '/v2/users/login/' => {} => json => { username => $username, password => $password }); +die 'login failed: ' . $login->res->error->{message} unless $login->res->is_success; my $token = $login->res->json->{token}; @@ -57,7 +59,7 @@ for my $cookie (@{ $login->res->cookies }) { } die 'missing CSRF token' unless defined $csrf; -my $attemptLogin = $ua->post('https://hub.docker.com/attempt-login/' => {} => json => { jwt => $token }); +my $attemptLogin = $ua->post($dockerHub . '/attempt-login/' => {} => json => { jwt => $token }); die 'attempt-login failed' unless $attemptLogin->res->is_success; my $authorizationHeader = { @@ -171,7 +173,7 @@ while (my $repo = shift) { # 'library/hylang', 'tianon/perl', etc my $repoName = $repo; $repoName =~ s!^.*/!!; # 'hylang', 'perl', etc - my $repoUrl = 'https://hub.docker.com/v2/repositories/' . $repo . '/'; + my $repoUrl = $dockerHub . '/v2/repositories/' . $repo . '/'; if ($logos && $repo =~ m{ ^ library/ }x) { # the "library" org images include a logo which is displayed in the Hub UI