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

Code before:
      // Gets the image manifest to push.
      BuildableManifestTemplate manifestTemplate =
          new ImageToJsonTranslator(builtImage)
              .getManifestTemplate(
                  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

Review comment (suggestion):
```suggestion
  private static Set<String> getChildTags(Image builtImage, Set<String> tags, DescriptorDigest manifestDigest, boolean platformTagFeatureEnabled) {
```

Code after:
      if (JibSystemProperties.skipExistingImages() && manifestAlreadyExists) {
        eventHandlers.dispatch(LogEvent.info("Skipping pushing manifest; already exists."));
        return ImmutableList.of();
      }

      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