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();
}
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();
}
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");
}
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);
}
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);
}
Aggregations