Search in sources :

Example 76 with ImageConfiguration

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

the class PropertyConfigHandlerTest method resolveExternalImageConfig.

private ImageConfiguration resolveExternalImageConfig(String[] testData) {
    Map<String, String> external = new HashMap<>();
    external.put("type", "props");
    ImageConfiguration config = ImageConfiguration.builder().name("image").alias("alias").external(external).build(BuildConfiguration.builder().build()).build();
    List<ImageConfiguration> resolvedImageConfigs = resolveImage(config, props(testData));
    assertEquals(1, resolvedImageConfigs.size());
    return resolvedImageConfigs.get(0);
}
Also used : HashMap(java.util.HashMap) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration)

Example 77 with ImageConfiguration

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

the class PropertyConfigHandlerTest method testCleanupDefault.

@Test
public void testCleanupDefault() {
    String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.FROM), "base" };
    ImageConfiguration config = resolveExternalImageConfig(mergeArrays(getBaseTestData(), testData));
    assertEquals(DEFAULT_CLEANUP, config.getBuildConfiguration().cleanupMode().toParameter());
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) Test(org.junit.Test)

Example 78 with ImageConfiguration

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

the class PropertyConfigHandlerTest method testRunCommandsFromPropertiesAndConfig.

@Test
public void testRunCommandsFromPropertiesAndConfig() {
    imageConfiguration = ImageConfiguration.builder().external(new HashMap<>()).build(BuildConfiguration.builder().runCmds(Arrays.asList("some", "ignored", "value")).addCacheFrom("foo/bar:latest").build()).build();
    makeExternalConfigUse(PropertyMode.Override);
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo", "docker.run.1", "propconf", "docker.run.2", "withrun", "docker.run.3", "used"));
    assertEquals(1, configs.size());
    BuildConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    String[] runCommands = new ArrayList<>(buildConfig.getRunCmds()).toArray(new String[buildConfig.getRunCmds().size()]);
    assertArrayEquals(new String[] { "propconf", "withrun", "used" }, runCommands);
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) HashMap(java.util.HashMap) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) Test(org.junit.Test)

Example 79 with ImageConfiguration

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

the class PropertyConfigHandlerTest method testRunCommandsFromConfigAndProperties.

@Test
public void testRunCommandsFromConfigAndProperties() {
    imageConfiguration = ImageConfiguration.builder().external(externalMode(PropertyMode.Fallback)).build(BuildConfiguration.builder().runCmds(Arrays.asList("some", "configured", "value")).addCacheFrom("foo/bar:latest").build()).build();
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo", "docker.run.1", "this", "docker.run.2", "is", "docker.run.3", "ignored"));
    assertEquals(1, configs.size());
    BuildConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    String[] runCommands = new ArrayList<>(buildConfig.getRunCmds()).toArray(new String[buildConfig.getRunCmds().size()]);
    assertArrayEquals(new String[] { "some", "configured", "value" }, runCommands);
}
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) Test(org.junit.Test)

Example 80 with ImageConfiguration

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

the class ConfigHelperTest method initImageConfiguration_withSimpleDockerFileInProjectBaseDir_shouldCreateImageConfiguration.

@Test
public void initImageConfiguration_withSimpleDockerFileInProjectBaseDir_shouldCreateImageConfiguration() {
    List<ImageConfiguration> images = new ArrayList<>();
    File dockerFile = new File(getClass().getResource("/dummy-javaproject/Dockerfile").getFile());
    when(jKubeConfiguration.getBasedir()).thenReturn(dockerFile.getParentFile());
    when(javaProject.getProperties()).thenReturn(new Properties());
    when(javaProject.getGroupId()).thenReturn("org.eclipse.jkube");
    when(javaProject.getArtifactId()).thenReturn("test-java-project");
    when(javaProject.getVersion()).thenReturn("0.0.1-SNAPSHOT");
    // When
    List<ImageConfiguration> resolvedImages = ConfigHelper.initImageConfiguration("1.12", new Date(), images, imageConfigResolver, logger, null, configs -> configs, jKubeConfiguration);
    // Then
    assertThat(resolvedImages).isNotNull().hasSize(1).element(0).hasFieldOrPropertyWithValue("name", "jkube/test-java-project:latest").hasFieldOrPropertyWithValue("build.dockerFile", dockerFile).hasFieldOrPropertyWithValue("build.ports", Collections.singletonList("8080"));
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ArrayList(java.util.ArrayList) Properties(java.util.Properties) File(java.io.File) Date(java.util.Date) 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