Search in sources :

Example 46 with BuildConfiguration

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

the class MicronautGeneratorTest method customize_webPortIsFirst.

@Test
public void customize_webPortIsFirst() {
    // Given
    when(ctx.getProject().getCompileClassPathElements()).thenReturn(Collections.emptyList());
    when(ctx.getProject().getOutputDirectory()).thenReturn(new File("MOCK"));
    // When
    final List<ImageConfiguration> result = micronautGenerator.customize(new ArrayList<>(), false);
    // Then
    assertThat(result).singleElement().extracting(ImageConfiguration::getBuildConfiguration).extracting(BuildConfiguration::getPorts).asList().containsExactly("8080", "8778", "9779");
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) File(java.io.File) Test(org.junit.Test)

Example 47 with BuildConfiguration

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

the class DefaultServiceEnricherAddMissingPartsTest method setUp.

@Before
public void setUp() {
    properties = new Properties();
    images = new ArrayList<>();
    images.add(ImageConfiguration.builder().name("test-image").build(new BuildConfiguration()).build());
    // @formatter:off
    new Expectations() {

        {
            context.getProperties();
            result = properties;
            context.getConfiguration().getImages();
            result = images;
            context.getGav().getSanitizedArtifactId();
            result = "artifact-id";
        }
    };
    // @formatter:on
    enricher = new DefaultServiceEnricher(context);
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) Expectations(mockit.Expectations) Properties(java.util.Properties) Before(org.junit.Before)

Example 48 with BuildConfiguration

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

the class ContainerHandlerTest method containerPortsWithoutPortTest.

@Test
public void containerPortsWithoutPortTest() {
    ContainerHandler handler = createContainerHandler(project);
    // without Ports
    final BuildConfiguration buildImageConfiguration2 = BuildConfiguration.builder().from("fabric8/maven:latest").cleanup("try").compressionString("gzip").build();
    ImageConfiguration imageConfiguration2 = ImageConfiguration.builder().name("test").alias("test-app").build(buildImageConfiguration2).registry("docker.io").build();
    images.clear();
    images.add(imageConfiguration2);
    containers = handler.getContainers(config, images);
    assertNull(containers.get(0).getPorts());
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Test(org.junit.Test)

Example 49 with BuildConfiguration

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

the class ContainerHandlerTest method getContainersWithAliasTest.

@Test
public void getContainersWithAliasTest() {
    project.setArtifactId("test-artifact");
    project.setGroupId("test-group");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    ContainerHandler handler = new ContainerHandler(project.getProperties(), new GroupArtifactVersion("test-group", "test-artifact", "0"), probeHandler);
    // 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("docker.io/test/test-app:1.2").alias("test-app").build(buildImageConfiguration).registry("docker-alternate.io").build();
    images.clear();
    images.add(imageConfiguration);
    containers = handler.getContainers(config, images);
    assertNotNull(containers);
    assertEquals("test-app", containers.get(0).getName());
    assertEquals("docker.io/test/test-app:1.2", 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 50 with BuildConfiguration

use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration 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)

Aggregations

BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)58 Test (org.junit.Test)39 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)24 File (java.io.File)23 Properties (java.util.Properties)11 AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)10 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)10 RunImageConfiguration (org.eclipse.jkube.kit.config.image.RunImageConfiguration)8 GroupArtifactVersion (org.eclipse.jkube.kit.config.resource.GroupArtifactVersion)8 Before (org.junit.Before)8 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)7 ArrayList (java.util.ArrayList)6 Expectations (mockit.Expectations)5 VolumeConfig (org.eclipse.jkube.kit.config.resource.VolumeConfig)5 Verifications (mockit.Verifications)4 List (java.util.List)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assembly (org.eclipse.jkube.kit.common.Assembly)3 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)3 JavaProject (org.eclipse.jkube.kit.common.JavaProject)3