Search in sources :

Example 91 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration 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 92 with ImageConfiguration

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

the class KubernetesExtensionTest method images_withMapListClosure_shouldSetImagesUsingConfigObjectParsing.

@Test
public void images_withMapListClosure_shouldSetImagesUsingConfigObjectParsing() {
    // Given
    final KubernetesExtension extension = new TestKubernetesExtension();
    // When
    extension.images(new Closure<Void>(extension) {

        public Void doCall(Object... args) {
            setProperty("image1", new Closure<Void>(new ImageConfiguration()) {

                public Void doCall(Object... args) {
                    setProperty("name", "closure/image1:name");
                    return null;
                }
            });
            setProperty("image2", new Closure<Void>(new ImageConfiguration()) {

                public Void doCall(Object... args) {
                    setProperty("name", "closure/image2:name");
                    return null;
                }
            });
            return null;
        }
    });
    // Then
    assertThat(extension.images).hasSize(2).extracting(ImageConfiguration::getName).containsExactly("closure/image1:name", "closure/image2:name");
}
Also used : Closure(groovy.lang.Closure) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Test(org.junit.Test)

Example 93 with ImageConfiguration

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

the class DefaultServiceEnricherTest method serviceImageLabelEnrichment.

@Test
public void serviceImageLabelEnrichment() throws Exception {
    ImageConfiguration imageConfigurationWithLabels = ImageConfiguration.builder().name("test-label").alias("test").build();
    final TreeMap<String, Object> config = new TreeMap<>();
    config.put("type", "LoadBalancer");
    new Expectations() {

        {
            Configuration configuration = Configuration.builder().image(imageConfigurationWithLabels).processorConfig(new ProcessorConfig(null, null, Collections.singletonMap("jkube-service", config))).build();
            groupArtifactVersion.getSanitizedArtifactId();
            result = "jkube-service";
            context.getConfiguration();
            result = configuration;
            imageConfigurationWithLabels.getBuildConfiguration();
            result = BuildConfiguration.builder().labels(Collections.singletonMap("jkube.generator.service.ports", "9090")).ports(Arrays.asList("80", "53/UDP")).build();
        }
    };
    String json = enrich();
    assertPort(json, 0, 9090, 9090, "http", "TCP");
}
Also used : Expectations(mockit.Expectations) BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) TreeMap(java.util.TreeMap) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Test(org.junit.Test)

Example 94 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration 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 95 with ImageConfiguration

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

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