Search in sources :

Example 1 with ContainerizerTestProxy

use of com.google.cloud.tools.jib.api.ContainerizerTestProxy 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();
}
Also used : ImageConfiguration(com.google.cloud.tools.jib.configuration.ImageConfiguration) ContainerizerTestProxy(com.google.cloud.tools.jib.api.ContainerizerTestProxy) Test(org.junit.Test)

Example 2 with ContainerizerTestProxy

use of com.google.cloud.tools.jib.api.ContainerizerTestProxy 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();
}
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 3 with ContainerizerTestProxy

use of com.google.cloud.tools.jib.api.ContainerizerTestProxy in project jib by GoogleContainerTools.

the class ContainerizersTest method testApplyConfiguration_defaults.

@Test
public void testApplyConfiguration_defaults() throws InvalidImageReferenceException, FileNotFoundException, CacheDirectoryCreationException {
    CommonCliOptions commonCliOptions = CommandLine.populateCommand(new CommonCliOptions(), "-t", "test-image-ref");
    ContainerizerTestProxy containerizer = new ContainerizerTestProxy(Containerizers.from(commonCliOptions, consoleLogger, cacheDirectories));
    assertThat(Boolean.getBoolean(JibSystemProperties.SEND_CREDENTIALS_OVER_HTTP)).isFalse();
    assertThat(Boolean.getBoolean(JibSystemProperties.SERIALIZE)).isFalse();
    assertThat(containerizer.getToolName()).isEqualTo(VersionInfo.TOOL_NAME);
    assertThat(containerizer.getToolVersion()).isEqualTo(VersionInfo.getVersionSimple());
    assertThat(Boolean.getBoolean("sendCredentialsOverHttp")).isFalse();
    assertThat(containerizer.getAllowInsecureRegistries()).isFalse();
    assertThat(containerizer.getBaseImageLayersCacheDirectory()).isEqualTo(baseImageCache);
    assertThat(containerizer.getApplicationsLayersCacheDirectory()).isEqualTo(applicationCache);
    assertThat(containerizer.getAdditionalTags()).isEqualTo(ImmutableSet.of());
}
Also used : ContainerizerTestProxy(com.google.cloud.tools.jib.api.ContainerizerTestProxy) Test(org.junit.Test)

Example 4 with ContainerizerTestProxy

use of com.google.cloud.tools.jib.api.ContainerizerTestProxy 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 5 with ContainerizerTestProxy

use of com.google.cloud.tools.jib.api.ContainerizerTestProxy 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)

Aggregations

ContainerizerTestProxy (com.google.cloud.tools.jib.api.ContainerizerTestProxy)10 Test (org.junit.Test)10 ImageConfiguration (com.google.cloud.tools.jib.configuration.ImageConfiguration)6 Path (java.nio.file.Path)2