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);
}
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());
}
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);
}
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);
}
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"));
}
Aggregations