use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by GoogleContainerTools.
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();
}
use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by GoogleContainerTools.
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 GoogleContainerTools.
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();
}
use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by GoogleContainerTools.
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);
}
use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by GoogleContainerTools.
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);
}
Aggregations