Skip to content

Commit d1cb599

Browse files
committed
Add optional "--dry-run" flag for pre-testing "heavy" pushes
1 parent db8b401 commit d1cb599

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

put-multiarch/put-multiarch.pl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Mojo::Util;
1212

1313
my $publicProxy = $ENV{DOCKERHUB_PUBLIC_PROXY} || die 'missing DOCKERHUB_PUBLIC_PROXY env (https://github.com/tianon/dockerhub-public-proxy)';
14+
my $dryRun = ($ARGV[0] || '') eq '--dry-run';
15+
shift @ARGV if $dryRun;
1416

1517
my $ua = Mojo::UserAgent->new->max_redirects(10)->connect_timeout(120)->inactivity_timeout(120);
1618
$ua->transactor->name(join ' ',
@@ -381,6 +383,8 @@ ($method, $repos, $url, $contentType = undef, $payload = undef, $tries = 10)
381383
return head_manifest_p($org, $repo, $manifestListDigest)->then(sub ($exists) {
382384
# if we already have the manifest we're planning to push in the namespace where we plan to push it, we can skip all blob mounts! \m/
383385
return if $exists;
386+
# (we can also skip if we're in "dry run" mode since we only care about the final manifest matching in that case)
387+
return if $dryRun;
384388

385389
return (
386390
@neededArtifactPromises
@@ -426,7 +430,12 @@ ($method, $repos, $url, $contentType = undef, $payload = undef, $tries = 10)
426430
# let's do one final check of the tag we're pushing to see if it's already the manifest we expect it to be (to avoid making literally every image constantly "Updated a few seconds ago" all the time)
427431
return get_manifest_p($org, $repo, $tag)->then(sub ($manifestData = undef) {
428432
if ($manifestData && $manifestData->{digest} eq $manifestListDigest) {
429-
say "Skipping $org/$repo:$tag ($manifestListDigest)";
433+
say "Skipping $org/$repo:$tag ($manifestListDigest)" unless $dryRun; # if we're in "dry run" mode, we need clean output
434+
return;
435+
}
436+
437+
if ($dryRun) {
438+
say "Would push $org/$repo:$tag ($manifestListDigest)";
430439
return;
431440
}
432441

0 commit comments

Comments
 (0)