use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class IngressEnricherTest method testNetworkingV1IngressIsGenerated.
@Test
public void testNetworkingV1IngressIsGenerated() {
// Given
final TreeMap<String, Object> config = new TreeMap<>();
config.put("host", "test.192.168.39.25.nip.io");
config.put("targetApiVersion", "networking.k8s.io/v1");
new Expectations() {
{
Configuration configuration = Configuration.builder().image(imageConfiguration).processorConfig(new ProcessorConfig(null, null, Collections.singletonMap("jkube-ingress", config))).build();
context.getConfiguration();
result = configuration;
context.getProperty("jkube.createExternalUrls");
result = "true";
}
};
KubernetesListBuilder kubernetesListBuilder = new KubernetesListBuilder();
kubernetesListBuilder.addToItems(initTestService().build());
// When
ingressEnricher.create(PlatformMode.kubernetes, kubernetesListBuilder);
// Then
assertThat(kubernetesListBuilder).extracting(KubernetesListBuilder::buildItems).asList().hasSize(2).element(1).extracting("spec.rules").asList().extracting("host").containsExactly("test.192.168.39.25.nip.io");
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class DefaultServiceEnricher method extractPorts.
// ========================================================================================================
// Port handling
private List<ServicePort> extractPorts(List<ImageConfiguration> images) {
List<ServicePort> ret = new ArrayList<>();
boolean isMultiPort = Boolean.parseBoolean(getConfig(Config.MULTI_PORT));
List<ServicePort> configuredPorts = extractPortsFromConfig();
for (ImageConfiguration image : images) {
Map<String, String> labels = extractLabelsFromConfig(image);
List<String> podPorts = getPortsFromBuildConfiguration(image);
List<String> portsFromImageLabels = getLabelWithService(labels);
if (podPorts.isEmpty()) {
continue;
}
// Extract first port and remove first element
if (portsFromImageLabels == null || portsFromImageLabels.isEmpty()) {
addPortIfNotNull(ret, extractPortsFromImageSpec(image.getName(), podPorts.remove(0), shiftOrNull(configuredPorts), null));
} else {
for (String imageLabelPort : portsFromImageLabels) {
addPortIfNotNull(ret, extractPortsFromImageSpec(image.getName(), podPorts.remove(0), shiftOrNull(configuredPorts), imageLabelPort));
}
}
// Remaining port specs if multi-port is selected
if (isMultiPort) {
for (String port : podPorts) {
addPortIfNotNull(ret, extractPortsFromImageSpec(image.getName(), port, shiftOrNull(configuredPorts), null));
}
}
}
// If there are still ports configured add them directly
if (isMultiPort) {
ret.addAll(mirrorMissingTargetPorts(configuredPorts));
} else if (ret.isEmpty() && !configuredPorts.isEmpty()) {
ret.addAll(mirrorMissingTargetPorts(Collections.singletonList(configuredPorts.get(0))));
}
return ret;
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ImageEnricher method mergeImageConfigurationWithContainerSpec.
// Add missing information to the given containers as found
// configured
private void mergeImageConfigurationWithContainerSpec(List<Container> containers) {
int idx = 0;
for (ImageConfiguration image : getImages()) {
Container container = getContainer(idx, containers);
mergeImagePullPolicy(image, container);
mergeImage(image, container);
mergeContainerName(image, container);
mergeEnvVariables(container);
idx++;
}
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class KubernetesResourceUtilTest method extractContainerName.
@Test
public void extractContainerName() {
// Given
final ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("dummy-image").registry("example.com/someregistry").name("test").build();
// When
final String result = KubernetesResourceUtil.extractContainerName(new GroupArtifactVersion("io.fabric8-test-", "fabric8-maven-plugin-dummy", "0"), imageConfiguration);
// Then
assertThat(result).isEqualTo("iofabric8-test--fabric8-maven-plugin-dummy");
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ContainerHandlerTest method getRegistryTest.
@Test
public void getRegistryTest() {
ContainerHandler handler = createContainerHandler(project1);
ImageConfiguration imageConfig = ImageConfiguration.builder().name("test").alias("test-app").build(buildImageConfiguration1).build();
images.clear();
images.add(imageConfig);
Properties properties = project1.getProperties();
properties.setProperty("jkube.docker.pull.registry", "push.me");
project1.setProperties(properties);
containers = handler.getContainers(config1, images);
project1.getProperties().remove("jkube.docker.pull.registry");
assertEquals("push.me/test:latest", containers.get(0).getImage());
}
Aggregations