Search in sources :

Example 11 with ImageConfiguration

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

the class KubernetesExtensionTest method images_withCallableClosure_shouldSetImagesInClosureExecution.

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

        public Void doCall(Object... args) {
            extension.image(new Closure<Void>(new ImageConfiguration()) {

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

Example 12 with ImageConfiguration

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

the class KubernetesBuildTask method run.

@Override
public void run() {
    if (kubernetesExtension.getRuntimeMode() == RuntimeMode.OPENSHIFT) {
        kitLogger.info("Using [[B]]OpenShift[[B]] build with strategy [[B]]%s[[B]]", kubernetesExtension.getBuildStrategyOrDefault().getLabel());
    } else {
        kitLogger.info("Building container image in [[B]]Kubernetes[[B]] mode");
    }
    try {
        storeTimestamp(getBuildTimestampFile(kubernetesExtension.javaProject.getBuildDirectory().getAbsolutePath(), DOCKER_BUILD_TIMESTAMP), getBuildTimestamp(null, null, kubernetesExtension.javaProject.getBuildDirectory().getAbsolutePath(), DOCKER_BUILD_TIMESTAMP));
        jKubeServiceHub.getBuildService().build(resolvedImages.toArray(new ImageConfiguration[0]));
    } catch (JKubeServiceException | IOException e) {
        kitLogger.error(e.getMessage());
        throw new GradleException(e.getMessage(), e);
    }
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) GradleException(org.gradle.api.GradleException) JKubeServiceException(org.eclipse.jkube.kit.config.service.JKubeServiceException) IOException(java.io.IOException)

Example 13 with ImageConfiguration

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

the class JibServiceUtilTest method testGetBaseImageWithNotNullBuildConfig.

@Test
public void testGetBaseImageWithNotNullBuildConfig() {
    // Given
    final ImageConfiguration imageConfiguration = ImageConfiguration.builder().build(BuildConfiguration.builder().from("quay.io/jkubeio/jkube-test-image:0.0.1").build()).build();
    // When
    final String result = JibServiceUtil.getBaseImage(imageConfiguration);
    // Then
    assertThat(result).isEqualTo("quay.io/jkubeio/jkube-test-image:0.0.1");
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) JibServiceUtil.containerFromImageConfiguration(org.eclipse.jkube.kit.service.jib.JibServiceUtil.containerFromImageConfiguration) Test(org.junit.Test)

Example 14 with ImageConfiguration

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

the class PropertyConfigHandlerTest method testPortsFromConfigAndProperties.

@Test
public void testPortsFromConfigAndProperties() {
    imageConfiguration = ImageConfiguration.builder().external(new HashMap<>()).build(BuildConfiguration.builder().ports(Collections.singletonList("1234")).addCacheFrom("foo/bar:latest").build()).run(RunImageConfiguration.builder().ports(Collections.singletonList("jolokia.port:1234")).build()).build();
    makeExternalConfigUse(PropertyMode.Override);
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.name", "demo", "docker.ports.1", "9090", "docker.ports.2", "0.0.0.0:80:80", "docker.from", "busybox"));
    assertEquals(1, configs.size());
    RunImageConfiguration runConfig = configs.get(0).getRunConfiguration();
    List<String> portsAsList = runConfig.getPorts();
    String[] ports = new ArrayList<>(portsAsList).toArray(new String[portsAsList.size()]);
    assertArrayEquals(new String[] { "9090", "0.0.0.0:80:80", "jolokia.port:1234" }, ports);
    BuildConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    ports = new ArrayList<>(buildConfig.getPorts()).toArray(new String[buildConfig.getPorts().size()]);
    assertArrayEquals(new String[] { "9090", "80", "1234" }, ports);
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) ArrayList(java.util.ArrayList) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) Test(org.junit.Test)

Example 15 with ImageConfiguration

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

the class PropertyConfigHandlerTest method testNoOptimise.

@Test
public void testNoOptimise() {
    String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.OPTIMISE), "false", k(ConfigKey.FROM), "base" };
    ImageConfiguration config = resolveExternalImageConfig(mergeArrays(getBaseTestData(), testData));
    assertFalse(config.getBuildConfiguration().optimise());
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) 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