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