use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.
the class ContainerHandler method getContainerPorts.
private List<ContainerPort> getContainerPorts(ImageConfiguration imageConfig) {
BuildConfiguration buildConfig = imageConfig.getBuildConfiguration();
List<String> ports = buildConfig.getPorts();
if (!ports.isEmpty()) {
List<ContainerPort> ret = new ArrayList<>();
PortMapping portMapping = new PortMapping(ports, configurationProperties);
JsonArray portSpecs = portMapping.toJson();
for (int i = 0; i < portSpecs.size(); i++) {
JsonObject portSpec = portSpecs.get(i).getAsJsonObject();
ret.add(extractContainerPort(portSpec));
}
return ret;
} else {
return null;
}
}
use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration 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);
}
use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.
the class PropertyConfigHandlerTest method testShell.
@Test
public void testShell() {
List<ImageConfiguration> configs = resolveImage(imageConfiguration, props(mergeArrays(getBaseTestData(), new String[] { "docker.from", "base", "docker.name", "demo", "docker.shell", "/bin/sh -c" })));
assertEquals(1, configs.size());
BuildConfiguration buildConfig = configs.get(0).getBuildConfiguration();
String[] shell = new ArrayList<>(buildConfig.getShell().asStrings()).toArray(new String[buildConfig.getShell().asStrings().size()]);
assertArrayEquals(new String[] { "/bin/sh", "-c" }, shell);
}
use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.
the class PropertyConfigHandlerTest method testBuildFromDockerFileMerged.
@Test
public void testBuildFromDockerFileMerged() {
imageConfiguration = ImageConfiguration.builder().name("myimage").external(externalMode(PropertyMode.Override)).build(BuildConfiguration.builder().dockerFile("/some/path").addCacheFrom("foo/bar:latest").build()).build();
List<ImageConfiguration> configs = resolveImage(imageConfiguration, props());
assertEquals(1, configs.size());
BuildConfiguration buildConfiguration = configs.get(0).getBuildConfiguration();
assertNotNull(buildConfiguration);
buildConfiguration.initAndValidate();
Path absolutePath = Paths.get(".").toAbsolutePath();
String expectedPath = absolutePath.getRoot() + "some" + File.separator + "path";
assertEquals(expectedPath, buildConfiguration.getDockerFile().getAbsolutePath());
}
use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.
the class PropertyConfigHandlerTest method testRunCommands.
@Test
public void testRunCommands() {
List<ImageConfiguration> configs = resolveImage(imageConfiguration, props(mergeArrays(getBaseTestData(), new String[] { "docker.from", "base", "docker.name", "demo", "docker.run.1", "foo", "docker.run.2", "bar", "docker.run.3", "wibble" })));
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[] { "xyz", "foo", "bar", "wibble" }, runCommands);
}
Aggregations