Search in sources :

Example 16 with ImageConfiguration

use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by google.

the class PluginConfigurationProcessorTest method testGetJavaContainerBuilderWithBaseImage_tarBase.

@Test
public void testGetJavaContainerBuilderWithBaseImage_tarBase() throws IncompatibleBaseImageJavaVersionException, IOException, InvalidImageReferenceException, CacheDirectoryCreationException {
    when(rawConfiguration.getFromImage()).thenReturn(Optional.of("tar:///path/to.tar"));
    ImageConfiguration result = getCommonImageConfiguration();
    assertThat(result.getTarPath()).hasValue(Paths.get("/path/to.tar"));
    assertThat(result.getDockerClient()).isEmpty();
}
Also used : ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) Test(org.junit.Test)

Example 17 with ImageConfiguration

use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by google.

the class PluginConfigurationProcessorTest method testGetJavaContainerBuilderWithBaseImage_registry.

@Test
public void testGetJavaContainerBuilderWithBaseImage_registry() throws IncompatibleBaseImageJavaVersionException, InvalidImageReferenceException, IOException, CacheDirectoryCreationException {
    when(rawConfiguration.getFromImage()).thenReturn(Optional.of("ima.ge/name"));
    ImageConfiguration result = getCommonImageConfiguration();
    assertThat(result.getImage().toString()).isEqualTo("ima.ge/name");
    assertThat(result.getDockerClient()).isEmpty();
    assertThat(result.getTarPath()).isEmpty();
}
Also used : ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) Test(org.junit.Test)

Example 18 with ImageConfiguration

use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by google.

the class PluginConfigurationProcessorTest method testGetJavaContainerBuilderWithBaseImage_java12BaseImage.

// https://github.com/GoogleContainerTools/jib/issues/1995
@Test
public void testGetJavaContainerBuilderWithBaseImage_java12BaseImage() throws InvalidImageReferenceException, IOException, IncompatibleBaseImageJavaVersionException, CacheDirectoryCreationException {
    when(projectProperties.getMajorJavaVersion()).thenReturn(12);
    when(rawConfiguration.getFromImage()).thenReturn(Optional.of("regis.try/java12image"));
    ImageConfiguration imageConfiguration = getCommonImageConfiguration();
    assertThat(imageConfiguration.getImageRegistry()).isEqualTo("regis.try");
    assertThat(imageConfiguration.getImageRepository()).isEqualTo("java12image");
}
Also used : ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) Test(org.junit.Test)

Example 19 with ImageConfiguration

use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by google.

the class Containerizer method to.

/**
 * Gets a new {@link Containerizer} that containerizes to a container registry.
 *
 * @param registryImage the {@link RegistryImage} that defines target container registry and
 *     credentials
 * @return a new {@link Containerizer}
 */
public static Containerizer to(RegistryImage registryImage) {
    ImageConfiguration imageConfiguration = ImageConfiguration.builder(registryImage.getImageReference()).setCredentialRetrievers(registryImage.getCredentialRetrievers()).build();
    Function<BuildContext, StepsRunner> stepsRunnerFactory = buildContext -> StepsRunner.begin(buildContext).registryPushSteps();
    return new Containerizer(DESCRIPTION_FOR_DOCKER_REGISTRY, imageConfiguration, stepsRunnerFactory, true);
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) ListMultimap(com.google.common.collect.ListMultimap) BuildContext(com.google.cloud.tools.jib.configuration.BuildContext) Function(java.util.function.Function) HashSet(java.util.HashSet) DockerClient(com.google.cloud.tools.jib.docker.DockerClient) XdgDirectories(com.google.cloud.tools.jib.filesystem.XdgDirectories) Path(java.nio.file.Path) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) ImmutableSet(com.google.common.collect.ImmutableSet) Files(java.nio.file.Files) Set(java.util.Set) IOException(java.io.IOException) StepsRunner(com.google.cloud.tools.jib.builder.steps.StepsRunner) BuildResult(com.google.cloud.tools.jib.builder.steps.BuildResult) Executors(java.util.concurrent.Executors) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) List(java.util.List) Paths(java.nio.file.Paths) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) EventHandlers(com.google.cloud.tools.jib.event.EventHandlers) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) BuildContext(com.google.cloud.tools.jib.configuration.BuildContext) ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) StepsRunner(com.google.cloud.tools.jib.builder.steps.StepsRunner)

Example 20 with ImageConfiguration

use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by google.

the class Containerizer method to.

/**
 * 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);
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) ListMultimap(com.google.common.collect.ListMultimap) BuildContext(com.google.cloud.tools.jib.configuration.BuildContext) Function(java.util.function.Function) HashSet(java.util.HashSet) DockerClient(com.google.cloud.tools.jib.docker.DockerClient) XdgDirectories(com.google.cloud.tools.jib.filesystem.XdgDirectories) Path(java.nio.file.Path) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) ImmutableSet(com.google.common.collect.ImmutableSet) Files(java.nio.file.Files) Set(java.util.Set) IOException(java.io.IOException) StepsRunner(com.google.cloud.tools.jib.builder.steps.StepsRunner) BuildResult(com.google.cloud.tools.jib.builder.steps.BuildResult) Executors(java.util.concurrent.Executors) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) List(java.util.List) Paths(java.nio.file.Paths) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) EventHandlers(com.google.cloud.tools.jib.event.EventHandlers) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) BuildContext(com.google.cloud.tools.jib.configuration.BuildContext) ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) StepsRunner(com.google.cloud.tools.jib.builder.steps.StepsRunner)

Aggregations

ImageConfiguration (com.google.cloud.tools.jib.configuration.ImageConfiguration)49 Test (org.junit.Test)41 BuildContext (com.google.cloud.tools.jib.configuration.BuildContext)21 Platform (com.google.cloud.tools.jib.api.buildplan.Platform)12 EventHandlers (com.google.cloud.tools.jib.event.EventHandlers)8 Path (java.nio.file.Path)8 ExecutorService (java.util.concurrent.ExecutorService)8 BuildResult (com.google.cloud.tools.jib.builder.steps.BuildResult)7 ContainerizerTestProxy (com.google.cloud.tools.jib.api.ContainerizerTestProxy)6 JibContainerBuilder (com.google.cloud.tools.jib.api.JibContainerBuilder)6 ContainerBuildPlan (com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan)6 StepsRunner (com.google.cloud.tools.jib.builder.steps.StepsRunner)6 ContainerConfiguration (com.google.cloud.tools.jib.configuration.ContainerConfiguration)6 DockerClient (com.google.cloud.tools.jib.docker.DockerClient)6 XdgDirectories (com.google.cloud.tools.jib.filesystem.XdgDirectories)6 Preconditions (com.google.common.base.Preconditions)6 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)6 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)6 ImmutableSet (com.google.common.collect.ImmutableSet)6 ListMultimap (com.google.common.collect.ListMultimap)6