Search in sources :

Example 11 with ImageConfiguration

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

the class ContainerBuildersTest method testCreate_dockerBaseImage.

@Test
public void testCreate_dockerBaseImage() throws IOException, InvalidImageReferenceException, CacheDirectoryCreationException {
    JibContainerBuilder containerBuilder = ContainerBuilders.create("docker://docker-image-ref", Collections.emptySet(), mockCommonCliOptions, mockLogger);
    BuildContext buildContext = JibContainerBuilderTestHelper.toBuildContext(containerBuilder, Containerizer.to(RegistryImage.named("ignored")));
    ImageConfiguration imageConfiguration = buildContext.getBaseImageConfiguration();
    assertThat(imageConfiguration.getImage().toString()).isEqualTo("docker-image-ref");
    assertThat(imageConfiguration.getDockerClient().isPresent()).isTrue();
    assertThat(imageConfiguration.getTarPath().isPresent()).isFalse();
}
Also used : BuildContext(com.google.cloud.tools.jib.configuration.BuildContext) ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) Test(org.junit.Test)

Example 12 with ImageConfiguration

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

the class ContainerBuildersTest method testCreate_tarBase.

@Test
public void testCreate_tarBase() throws IOException, InvalidImageReferenceException, CacheDirectoryCreationException {
    JibContainerBuilder containerBuilder = ContainerBuilders.create("tar:///path/to.tar", Collections.emptySet(), mockCommonCliOptions, mockLogger);
    BuildContext buildContext = JibContainerBuilderTestHelper.toBuildContext(containerBuilder, Containerizer.to(RegistryImage.named("ignored")));
    ImageConfiguration imageConfiguration = buildContext.getBaseImageConfiguration();
    assertThat(imageConfiguration.getTarPath()).isEqualTo(Optional.of(Paths.get("/path/to.tar")));
    assertThat(imageConfiguration.getDockerClient().isPresent()).isFalse();
}
Also used : BuildContext(com.google.cloud.tools.jib.configuration.BuildContext) ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) Test(org.junit.Test)

Example 13 with ImageConfiguration

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

the class ContainerizersTest method testFrom_registryImage.

@Test
public void testFrom_registryImage() throws InvalidImageReferenceException, IOException {
    CommonCliOptions commonCliOptions = CommandLine.populateCommand(new CommonCliOptions(), "-t", "registry://gcr.io/test/test-image-ref");
    ContainerizerTestProxy containerizer = new ContainerizerTestProxy(Containerizers.from(commonCliOptions, consoleLogger, cacheDirectories));
    // description from Containerizer.java
    assertThat(containerizer.getDescription()).isEqualTo("Building and pushing image");
    ImageConfiguration config = containerizer.getImageConfiguration();
    assertThat(config.getCredentialRetrievers()).isNotEmpty();
    assertThat(config.getDockerClient()).isEmpty();
    assertThat(config.getImage().toString()).isEqualTo("gcr.io/test/test-image-ref");
    assertThat(config.getTarPath()).isEmpty();
}
Also used : ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) ContainerizerTestProxy(com.google.cloud.tools.jib.api.ContainerizerTestProxy) Test(org.junit.Test)

Example 14 with ImageConfiguration

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

the class ContainerizersTest method testFrom_tarImage.

@Test
public void testFrom_tarImage() throws InvalidImageReferenceException, IOException {
    Path tarPath = temporaryFolder.getRoot().toPath().resolve("test-tar.tar");
    CommonCliOptions commonCliOptions = CommandLine.populateCommand(new CommonCliOptions(), "-t=tar://" + tarPath.toAbsolutePath(), "--name=gcr.io/test/test-image-ref");
    ContainerizerTestProxy containerizer = new ContainerizerTestProxy(Containerizers.from(commonCliOptions, consoleLogger, cacheDirectories));
    assertThat(containerizer.getDescription()).isEqualTo("Building image tarball");
    ImageConfiguration config = containerizer.getImageConfiguration();
    assertThat(config.getCredentialRetrievers()).isEmpty();
    assertThat(config.getDockerClient()).isEmpty();
    assertThat(config.getImage().toString()).isEqualTo("gcr.io/test/test-image-ref");
    // weird, but the way jib currently works
    assertThat(config.getTarPath()).isEmpty();
}
Also used : Path(java.nio.file.Path) ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) ContainerizerTestProxy(com.google.cloud.tools.jib.api.ContainerizerTestProxy) Test(org.junit.Test)

Example 15 with ImageConfiguration

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

the class ContainerizersTest method testFrom_dockerDaemonImage.

@Test
public void testFrom_dockerDaemonImage() throws InvalidImageReferenceException, FileNotFoundException {
    CommonCliOptions commonCliOptions = CommandLine.populateCommand(new CommonCliOptions(), "-t", "docker://gcr.io/test/test-image-ref");
    ContainerizerTestProxy containerizer = new ContainerizerTestProxy(Containerizers.from(commonCliOptions, consoleLogger, cacheDirectories));
    assertThat(containerizer.getDescription()).isEqualTo("Building image to Docker daemon");
    ImageConfiguration config = containerizer.getImageConfiguration();
    assertThat(config.getCredentialRetrievers()).isEmpty();
    assertThat(config.getDockerClient()).isEmpty();
    assertThat(config.getImage().toString()).isEqualTo("gcr.io/test/test-image-ref");
    assertThat(config.getTarPath()).isEmpty();
}
Also used : ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) ContainerizerTestProxy(com.google.cloud.tools.jib.api.ContainerizerTestProxy) Test(org.junit.Test)

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