public JibContainerBuilder applyContainerBuildPlan(ContainerBuildPlan buildPlan)
      throws InvalidImageReferenceException {
    containerBuildPlanBuilder
        .setBaseImage(buildPlan.getBaseImage())
        .setPlatforms(buildPlan.getPlatforms())
        .setCreationTime(buildPlan.getCreationTime())
        .setFormat(buildPlan.getFormat())
        .setEnvironment(buildPlan.getEnvironment())
        .setLabels(buildPlan.getLabels())
        .setVolumes(buildPlan.getVolumes())
        .setExposedPorts(buildPlan.getExposedPorts())
        .setUser(buildPlan.getUser())
        .setWorkingDirectory(buildPlan.getWorkingDirectory())
        .setEntrypoint(buildPlan.getEntrypoint())
        .setCmd(buildPlan.getCmd())
        .setLayers(buildPlan.getLayers());

    containerConfigurationBuilder
        .setPlatforms(buildPlan.getPlatforms())
        .setCreationTime(buildPlan.getCreationTime())
        .setEnvironment(buildPlan.getEnvironment())
        .setLabels(buildPlan.getLabels())
        .setVolumes(buildPlan.getVolumes())
        .setExposedPorts(buildPlan.getExposedPorts())
        .setUser(buildPlan.getUser())
        .setWorkingDirectory(buildPlan.getWorkingDirectory())
        .setEntrypoint(buildPlan.getEntrypoint())
        .setProgramArguments(buildPlan.getCmd());

    ImageConfiguration.Builder builder =
        ImageConfiguration.builder(ImageReference.parse(buildPlan.getBaseImage()))
            .setCredentialRetrievers(baseImageConfiguration.getCredentialRetrievers());
    baseImageConfiguration.getDockerClient().ifPresent(builder::setDockerClient);
    baseImageConfiguration.getTarPath().ifPresent(builder::setTarPath);
    baseImageConfiguration = builder.build();

    // For now, only FileEntriesLayer is supported in jib-core.
    Function<LayerObject, FileEntriesLayer> castToFileEntriesLayer =
        layer -> {
          Verify.verify(
              layer instanceof FileEntriesLayer,
              "layer types other than FileEntriesLayer not yet supported in build plan layers");
          return (FileEntriesLayer) layer;
        };
    layerConfigurations =
        buildPlan.getLayers().stream().map(castToFileEntriesLayer).collect(Collectors.toList());

    buildContextBuilder
        .setTargetFormat(buildPlan.getFormat())
        .setBaseImageConfiguration(baseImageConfiguration)
        .setLayerConfigurations(layerConfigurations);
    return this;
  }
Internal method. API end users should not use it.

<p>Reconfigures {@link JibContainerBuilder} from the given {@code buildPlan}. Every value
configurable using "setters" in this class is overwritten by the value in {@code buildPlan};
only retained are some base image properties inherent in {@link JibContainerBuilder} but absent
in {@link ContainerBuildPlan}, such as {@link CredentialRetriever}s for {@link RegistryImage},
{@link DockerClient} for {@link DockerDaemonImage}, and output path for {@link TarImage}.

@param buildPlan build plan to apply
@return {@link JibContainerBuilder} reconfigured from {@code buildPlan}
@throws InvalidImageReferenceException if the base image value in {@code buildPlan} is an
    invalid reference
jib-core/src/main/java/com/google/cloud/tools/jib/api/JibContainerBuilder.java