Repository: GoogleContainerTools/jib
File: jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PushImageStep.java (Java)

Code before:
                  buildContext.getTargetFormat(), containerConfigurationDigestAndSize);

      DescriptorDigest manifestDigest = Digests.computeJsonDigest(manifestTemplate);

      Set<String> imageQualifiers = singlePlatform ? tags : getChildTags(builtImage, tags, manifestDigest, buildContext.getContainerConfiguration().isPlatformTag());

      return imageQualifiers.stream()
          .map(
              qualifier ->
                  new PushImageStep(
                      buildContext,
                      progressDispatcher.newChildProducer(),
                      registryClient,
                      manifestTemplate,
                      qualifier,
                      manifestDigest,
                      containerConfigurationDigestAndSize.getDigest()))
          .collect(ImmutableList.toImmutableList());
    }
  }

  private static Set<String> getChildTags(Image builtImage, Set<String> tags, DescriptorDigest manifestDigest, boolean newTagFeatureEnabled) {
    if (newTagFeatureEnabled) {
      String architecture = builtImage.getArchitecture();
      return tags.stream().map(tag -> tag + "-" + architecture).collect(Collectors.toSet());
    } else {
      return Collections.singleton(manifestDigest.toString());
    }
  }

  static ImmutableList<PushImageStep> makeListForManifestList(
      BuildContext buildContext,
      ProgressEventDispatcher.Factory progressEventDispatcherFactory,
      RegistryClient registryClient,
      ManifestTemplate manifestList,
      boolean manifestListAlreadyExists)
      throws IOException {
    Set<String> tags = buildContext.getAllTargetImageTags();

    EventHandlers eventHandlers = buildContext.getEventHandlers();
    try (TimerEventDispatcher ignored =
            new TimerEventDispatcher(eventHandlers, "Preparing manifest list pushers");
        ProgressEventDispatcher progressEventDispatcher =
            progressEventDispatcherFactory.create("launching manifest list pushers", tags.size())) {
      boolean singlePlatform = buildContext.getContainerConfiguration().getPlatforms().size() == 1;
      if (singlePlatform) {
        return ImmutableList.of(); // single image; no need to push a manifest list
      }

      if (JibSystemProperties.skipExistingImages() && manifestListAlreadyExists) {
        eventHandlers.dispatch(LogEvent.info("Skipping pushing manifest list; already exists."));

Review comment (refactor):
We can remove this else statement and return `Collections.singleton(manifestDigest.toString())` after the if-statement. 

Code after:

      return imageQualifiers.stream()
          .map(
              qualifier ->
                  new PushImageStep(
                      buildContext,
                      progressDispatcher.newChildProducer(),
                      registryClient,
                      manifestTemplate,
                      qualifier,
                      manifestDigest,
                      containerConfigurationDigestAndSize.getDigest()))
          .collect(ImmutableList.toImmutableList());
    }
  }

  private static Set<String> getImageQualifiers(
      BuildContext buildContext, Image builtImage, DescriptorDigest manifestDigest) {
    boolean singlePlatform = buildContext.getContainerConfiguration().getPlatforms().size() == 1;
    Set<String> tags = buildContext.getAllTargetImageTags();
    if (singlePlatform) {
      return tags;
    }
    if (buildContext.getEnablePlatformTags()) {
      String architecture = builtImage.getArchitecture();
      return tags.stream().map(tag -> tag + "-" + architecture).collect(Collectors.toSet());
    }
    return Collections.singleton(manifestDigest.toString());
  }

  static ImmutableList<PushImageStep> makeListForManifestList(
      BuildContext buildContext,
      ProgressEventDispatcher.Factory progressEventDispatcherFactory,
      RegistryClient registryClient,
      ManifestTemplate manifestList,
      boolean manifestListAlreadyExists)
      throws IOException {
    Set<String> tags = buildContext.getAllTargetImageTags();

    EventHandlers eventHandlers = buildContext.getEventHandlers();
    try (TimerEventDispatcher ignored =
            new TimerEventDispatcher(eventHandlers, "Preparing manifest list pushers");
        ProgressEventDispatcher progressEventDispatcher =
            progressEventDispatcherFactory.create("launching manifest list pushers", tags.size())) {
      boolean singlePlatform = buildContext.getContainerConfiguration().getPlatforms().size() == 1;
      if (singlePlatform) {
        return ImmutableList.of(); // single image; no need to push a manifest list
      }

      if (JibSystemProperties.skipExistingImages() && manifestListAlreadyExists) {
        eventHandlers.dispatch(LogEvent.info("Skipping pushing manifest list; already exists."));