Search in sources :

Example 96 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class ContainerHandlerTest method registryHandling.

@Test
public void registryHandling() {
    // container name with alias
    final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().build();
    String[] testData = { "docker.io/test/test-app:1.2", "docker-alternate.io", null, null, "docker.io/test/test-app:1.2", "test/test-app:1.2", "docker-image-config.io", "docker-pull.io", "docker-default.io", "docker-image-config.io/test/test-app:1.2", "test/test-app", null, "docker-pull.io", "docker-default.io", "docker-pull.io/test/test-app:latest", "test/test-app", null, null, "docker-default.io", "docker-default.io/test/test-app:latest" };
    for (int i = 0; i < testData.length; i += 5) {
        JavaProject testProject = JavaProject.builder().properties(new Properties()).build();
        Properties testProps = new Properties();
        if (testData[i + 2] != null) {
            testProps.put("jkube.docker.pull.registry", testData[i + 2]);
        }
        if (testData[i + 3] != null) {
            testProps.put("jkube.docker.registry", testData[i + 3]);
        }
        Properties properties = testProject.getProperties();
        properties.putAll(testProps);
        testProject.setProperties(properties);
        ContainerHandler handler = createContainerHandler(testProject);
        // container name with alias
        ImageConfiguration imageConfiguration = ImageConfiguration.builder().build(buildImageConfiguration).name(testData[i]).registry(testData[i + 1]).build();
        images.clear();
        images.add(imageConfiguration);
        containers = handler.getContainers(config, images);
        assertNotNull(containers);
        assertEquals(testData[i + 4], containers.get(0).getImage());
    }
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) JavaProject(org.eclipse.jkube.kit.common.JavaProject) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Properties(java.util.Properties) Test(org.junit.Test)

Example 97 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class ContainerHandlerTest method getContainerTestWithUser.

@Test
public void getContainerTestWithUser() {
    project.setArtifactId("test-artifact");
    project.setGroupId("test-group");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    // container name with user and image with tag
    ContainerHandler handler = new ContainerHandler(project.getProperties(), new GroupArtifactVersion("test-group", "test-artifact", "0"), probeHandler);
    final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().ports(ports).from("fabric8/").cleanup("try").tags(tags).compressionString("gzip").dockerFile("testFile").build();
    ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("user/test:latest").build(buildImageConfiguration).registry("docker.io").build();
    images.clear();
    images.add(imageConfiguration);
    containers = handler.getContainers(config, images);
    assertNotNull(containers);
    assertEquals("user-test-artifact", containers.get(0).getName());
    assertEquals("docker.io/user/test:latest", containers.get(0).getImage());
    assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) GroupArtifactVersion(org.eclipse.jkube.kit.config.resource.GroupArtifactVersion) Test(org.junit.Test)

Example 98 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class DaemonSetHandlerTest method before.

@Before
public void before() {
    // volume config with name and multiple mount
    mounts.add("/path/system");
    mounts.add("/path/sys");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    VolumeConfig volumeConfig1 = VolumeConfig.builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.add(volumeConfig1);
    // container name with alias
    final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compressionString("gzip").build();
    ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("test").alias("test-app").build(buildImageConfiguration).registry("docker.io").build();
    images.add(imageConfiguration);
    daemonSetHandler = new DaemonSetHandler(new PodTemplateHandler(new ContainerHandler(project.getProperties(), new GroupArtifactVersion("g", "a", "v"), probeHandler)));
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) GroupArtifactVersion(org.eclipse.jkube.kit.config.resource.GroupArtifactVersion) VolumeConfig(org.eclipse.jkube.kit.config.resource.VolumeConfig) Before(org.junit.Before)

Example 99 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class DeploymentConfigHandlerTest method getPodTemplateSpec_withNoImages_shouldReturnPodTemplateSpecWithNoContainers.

@Test
public void getPodTemplateSpec_withNoImages_shouldReturnPodTemplateSpecWithNoContainers() {
    // Given
    final ResourceConfig resourceConfig = resourceConfigBuilder.controllerName("controller").build();
    final List<ImageConfiguration> images = Collections.emptyList();
    // When
    final PodTemplateSpec result = deploymentConfigHandler.getPodTemplateSpec(resourceConfig, images);
    // Then
    assertThat(result).extracting("spec.containers").asList().isEmpty();
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 100 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class DeploymentConfigHandlerTest method get_withNoImagesAndNoControllerName_shouldThrowException.

@Test
public void get_withNoImagesAndNoControllerName_shouldThrowException() {
    // Given
    final ResourceConfig resourceConfig = resourceConfigBuilder.build();
    final List<ImageConfiguration> images = Collections.emptyList();
    // When
    final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> deploymentConfigHandler.get(resourceConfig, images));
    // Then
    assertThat(result).hasMessage("No controller name is specified!");
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Aggregations

ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)109 Test (org.junit.Test)75 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)29 RunImageConfiguration (org.eclipse.jkube.kit.config.image.RunImageConfiguration)28 File (java.io.File)26 ArrayList (java.util.ArrayList)19 Expectations (mockit.Expectations)15 GroupArtifactVersion (org.eclipse.jkube.kit.config.resource.GroupArtifactVersion)11 Before (org.junit.Before)11 IOException (java.io.IOException)9 Properties (java.util.Properties)8 KitLogger (org.eclipse.jkube.kit.common.KitLogger)8 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)7 JKubeServiceException (org.eclipse.jkube.kit.config.service.JKubeServiceException)7 WatchImageConfiguration (org.eclipse.jkube.kit.config.image.WatchImageConfiguration)6 ResourceConfig (org.eclipse.jkube.kit.config.resource.ResourceConfig)6 List (java.util.List)5 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)5 VolumeConfig (org.eclipse.jkube.kit.config.resource.VolumeConfig)5 Container (io.fabric8.kubernetes.api.model.Container)4