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 Docker daemon.
*
* @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);
}
use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by google.
the class PluginConfigurationProcessorTest method testGetJavaContainerBuilderWithBaseImage_registryWithPrefix.
@Test
public void testGetJavaContainerBuilderWithBaseImage_registryWithPrefix() throws IncompatibleBaseImageJavaVersionException, InvalidImageReferenceException, IOException, CacheDirectoryCreationException {
when(rawConfiguration.getFromImage()).thenReturn(Optional.of("registry://ima.ge/name"));
ImageConfiguration result = getCommonImageConfiguration();
assertThat(result.getImage().toString()).isEqualTo("ima.ge/name");
assertThat(result.getDockerClient()).isEmpty();
assertThat(result.getTarPath()).isEmpty();
}
use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by google.
the class PluginConfigurationProcessorTest method testGetJavaContainerBuilderWithBaseImage_dockerBase.
@Test
public void testGetJavaContainerBuilderWithBaseImage_dockerBase() throws IncompatibleBaseImageJavaVersionException, IOException, InvalidImageReferenceException, CacheDirectoryCreationException {
when(rawConfiguration.getFromImage()).thenReturn(Optional.of("docker://ima.ge/name"));
ImageConfiguration result = getCommonImageConfiguration();
assertThat(result.getImage().toString()).isEqualTo("ima.ge/name");
assertThat(result.getDockerClient()).isPresent();
assertThat(result.getTarPath()).isEmpty();
}
use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by google.
the class ContainerBuildersTest method testCreate_registry.
@Test
public void testCreate_registry() throws IOException, InvalidImageReferenceException, CacheDirectoryCreationException {
JibContainerBuilder containerBuilder = ContainerBuilders.create("registry://registry-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("registry-image-ref");
assertThat(imageConfiguration.getDockerClient().isPresent()).isFalse();
assertThat(imageConfiguration.getTarPath().isPresent()).isFalse();
}
use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by google.
the class ContainerizerTest method testGetImageConfiguration_registryImage.
@Test
public void testGetImageConfiguration_registryImage() throws InvalidImageReferenceException {
CredentialRetriever credentialRetriever = Mockito.mock(CredentialRetriever.class);
Containerizer containerizer = Containerizer.to(RegistryImage.named("registry/image").addCredentialRetriever(credentialRetriever));
ImageConfiguration imageConfiguration = containerizer.getImageConfiguration();
Assert.assertEquals("registry/image", imageConfiguration.getImage().toString());
Assert.assertEquals(Arrays.asList(credentialRetriever), imageConfiguration.getCredentialRetrievers());
}
Aggregations