Skip to content

Commit 0ad17f5

Browse files
committed
Adjust "Docker Hub" URL references to use a shared variable
(This makes testing against Hub's staging environment more straightforward.)
1 parent 6614bce commit 0ad17f5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

push.pl

+6-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@
4343
$password = $term->get_reply(prompt => 'Hub Password'); # TODO hide the input? O:)
4444
}
4545

46-
my $login = $ua->post('https://hub.docker.com/v2/users/login/' => {} => json => { username => $username, password => $password });
47-
die 'login failed' unless $login->res->is_success;
46+
my $dockerHub = 'https://hub.docker.com';
47+
48+
my $login = $ua->post($dockerHub . '/v2/users/login/' => {} => json => { username => $username, password => $password });
49+
die 'login failed: ' . $login->res->error->{message} unless $login->res->is_success;
4850

4951
my $token = $login->res->json->{token};
5052

@@ -57,7 +59,7 @@
5759
}
5860
die 'missing CSRF token' unless defined $csrf;
5961

60-
my $attemptLogin = $ua->post('https://hub.docker.com/attempt-login/' => {} => json => { jwt => $token });
62+
my $attemptLogin = $ua->post($dockerHub . '/attempt-login/' => {} => json => { jwt => $token });
6163
die 'attempt-login failed' unless $attemptLogin->res->is_success;
6264

6365
my $authorizationHeader = {
@@ -171,7 +173,7 @@ sub prompt_for_edit {
171173
my $repoName = $repo;
172174
$repoName =~ s!^.*/!!; # 'hylang', 'perl', etc
173175

174-
my $repoUrl = 'https://hub.docker.com/v2/repositories/' . $repo . '/';
176+
my $repoUrl = $dockerHub . '/v2/repositories/' . $repo . '/';
175177

176178
if ($logos && $repo =~ m{ ^ library/ }x) {
177179
# the "library" org images include a logo which is displayed in the Hub UI

0 commit comments

Comments
 (0)