use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by GoogleContainerTools.
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();
}
use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by GoogleContainerTools.
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();
}
use of com.google.cloud.tools.jib.configuration.ImageConfiguration in project jib by GoogleContainerTools.
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();
}
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 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 GoogleContainerTools.
the class ContainerizerTest method testGetImageConfiguration_tarImage.
@Test
public void testGetImageConfiguration_tarImage() throws InvalidImageReferenceException {
Containerizer containerizer = Containerizer.to(TarImage.at(Paths.get("output/file")).named("tar/image"));
ImageConfiguration imageConfiguration = containerizer.getImageConfiguration();
Assert.assertEquals("tar/image", imageConfiguration.getImage().toString());
Assert.assertEquals(0, imageConfiguration.getCredentialRetrievers().size());
}
Aggregations