Parallelizes pushing to multiple tags.
@@ -23,12 +23,10 @@ import com.google.cloud.tools.jib.configuration.BuildConfiguration;
import com.google.cloud.tools.jib.image.json.BuildableManifestTemplate;
import com.google.cloud.tools.jib.image.json.ImageToJsonTranslator;
import com.google.cloud.tools.jib.registry.RegistryClient;
-import com.google.cloud.tools.jib.registry.RegistryException;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
@@ -96,10 +94,11 @@ class PushImageStep implements AsyncStep<Void>, Callable<Void> {
return Futures.whenAllSucceed(dependenciesBuilder.build())
.call(this::afterPushSteps, listeningExecutorService)
.get()
+ .get()
.get();
}
- private ListenableFuture<Void> afterPushSteps() throws ExecutionException {
+ private ListenableFuture<ListenableFuture<Void>> afterPushSteps() throws ExecutionException {
List<ListenableFuture<?>> dependencies = new ArrayList<>();
for (AsyncStep<PushBlobStep> pushBlobStepStep : NonBlockingSteps.get(pushBaseImageLayersStep)) {
dependencies.add(NonBlockingSteps.get(pushBlobStepStep).getFuture());
@@ -114,7 +113,7 @@ class PushImageStep implements AsyncStep<Void>, Callable<Void> {
.call(this::afterAllPushed, listeningExecutorService);
}
- private Void afterAllPushed() throws IOException, RegistryException, ExecutionException {
+ private ListenableFuture<Void> afterAllPushed() throws ExecutionException {
try (Timer ignored = new Timer(buildConfiguration.getBuildLogger(), DESCRIPTION)) {
RegistryClient registryClient =
buildConfiguration
@@ -134,13 +133,17 @@ class PushImageStep implements AsyncStep<Void>, Callable<Void> {
NonBlockingSteps.get(NonBlockingSteps.get(pushContainerConfigurationStep))));
// Pushes to all target image tags.
- // TODO: Parallelize.
+ List<ListenableFuture<Void>> pushAllTagsFutures = new ArrayList<>();
for (String tag : buildConfiguration.getAllTargetImageTags()) {
+ pushAllTagsFutures.add(
+ listeningExecutorService.submit(
+ () -> {
buildConfiguration.getBuildLogger().info("Tagging with " + tag + "...");
registryClient.pushManifest(manifestTemplate, tag);
+ return null;
+ }));
}
+ return Futures.whenAllSucceed(pushAllTagsFutures).call(() -> null, listeningExecutorService);
}
-
- return null;
}
}
