Repository: GoogleContainerTools/jib
File: jib-core/src/main/java/com/google/cloud/tools/jib/api/Containerizer.java (Java)

Code before:
   *
   * @param dockerDaemonImage the {@link DockerDaemonImage} that defines target Docker daemon
   * @return a new {@link Containerizer}
   */
  public static Containerizer to(DockerDaemonImage dockerDaemonImage) {
    ImageConfiguration imageConfiguration =
        ImageConfiguration.builder(dockerDaemonImage.getImageReference()).build();

    DockerClient dockerClient =
        new DockerClient(
            dockerDaemonImage.getDockerExecutable(), dockerDaemonImage.getDockerEnvironment());
    Function<BuildContext, StepsRunner> stepsRunnerFactory =
        buildContext -> StepsRunner.begin(buildContext).dockerLoadSteps(dockerClient);

    return new Containerizer(
        DESCRIPTION_FOR_DOCKER_DAEMON, imageConfiguration, stepsRunnerFactory, false);
  }

  /**
   * Gets a new {@link Containerizer} that containerizes to a tarball archive.
   *
   * @param tarImage the {@link TarImage} that defines target output file
   * @return a new {@link Containerizer}
   */
  public static Containerizer to(TarImage tarImage) {
    Optional<ImageReference> tarImageReference = tarImage.getImageReference();
    if (!tarImageReference.isPresent()) {
      throw new IllegalArgumentException(
          "Image name must be set when building a TarImage; use TarImage#named(...) to set the name"
              + " of the target image");
    }

    ImageConfiguration imageConfiguration =
        ImageConfiguration.builder(tarImageReference.get()).build();

    Function<BuildContext, StepsRunner> stepsRunnerFactory =
        buildContext -> StepsRunner.begin(buildContext).tarBuildSteps(tarImage.getPath());

    return new Containerizer(
        DESCRIPTION_FOR_TARBALL, imageConfiguration, stepsRunnerFactory, false);
  }

  private final String description;
  private final ImageConfiguration imageConfiguration;
  private final Function<BuildContext, StepsRunner> stepsRunnerFactory;
  private final boolean mustBeOnline;
  private final Set<String> additionalTags = new HashSet<>();
  private final EventHandlers.Builder eventHandlersBuilder = EventHandlers.builder();

  @Nullable private ExecutorService executorService;
  private Path baseImageLayersCacheDirectory = DEFAULT_BASE_CACHE_DIRECTORY;

Review comment (suggestion):
```suggestion
    Optional<ImageReference> imageReference = tarImage.getImageReference();
```

Code after:
   *
   * @param dockerDaemonImage the {@link DockerDaemonImage} that defines target Docker daemon
   * @return a new {@link Containerizer}
   */
  public static Containerizer to(DockerDaemonImage dockerDaemonImage) {
    ImageConfiguration imageConfiguration =
        ImageConfiguration.builder(dockerDaemonImage.getImageReference()).build();

    DockerClient dockerClient =
        new DockerClient(
            dockerDaemonImage.getDockerExecutable(), dockerDaemonImage.getDockerEnvironment());
    Function<BuildContext, StepsRunner> stepsRunnerFactory =
        buildContext -> StepsRunner.begin(buildContext).dockerLoadSteps(dockerClient);

    return new Containerizer(
        DESCRIPTION_FOR_DOCKER_DAEMON, imageConfiguration, stepsRunnerFactory, false);
  }

  /**
   * Gets a new {@link Containerizer} that containerizes to a tarball archive.
   *
   * @param tarImage the {@link TarImage} that defines target output file
   * @return a new {@link Containerizer}
   */
  public static Containerizer to(TarImage tarImage) {
    Optional<ImageReference> imageReference = tarImage.getImageReference();
    if (!imageReference.isPresent()) {
      throw new IllegalArgumentException(
          "Image name must be set when building a TarImage; use TarImage#named(...) to set the name"
              + " of the target image");
    }

    ImageConfiguration imageConfiguration =
        ImageConfiguration.builder(imageReference.get()).build();

    Function<BuildContext, StepsRunner> stepsRunnerFactory =
        buildContext -> StepsRunner.begin(buildContext).tarBuildSteps(tarImage.getPath());

    return new Containerizer(
        DESCRIPTION_FOR_TARBALL, imageConfiguration, stepsRunnerFactory, false);
  }

  private final String description;
  private final ImageConfiguration imageConfiguration;
  private final Function<BuildContext, StepsRunner> stepsRunnerFactory;
  private final boolean mustBeOnline;
  private final Set<String> additionalTags = new HashSet<>();
  private final EventHandlers.Builder eventHandlersBuilder = EventHandlers.builder();

  @Nullable private ExecutorService executorService;
  private Path baseImageLayersCacheDirectory = DEFAULT_BASE_CACHE_DIRECTORY;