Skip to content

Commit

Permalink
DONT MERGE
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Nov 29, 2024
1 parent 4e362f6 commit 8190ed0
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 312 deletions.
2 changes: 1 addition & 1 deletion .jenkins/pipelines/java-8.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline {
tools {
maven 'apache-maven-latest'
// https://wiki.eclipse.org/Jenkins#JDK
jdk 'temurin-jdk8-latest'
jdk 'temurin-jdk11-latest'
}
options {
disableConcurrentBuilds(abortPrevious: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ public static Path exportKubernetesClientConfigToFile(io.fabric8.kubernetes.clie
kubeConfigBuilder.addToContexts(kubernetesClientConfig.getCurrentContext());
kubeConfigBuilder.withCurrentContext(kubernetesClientConfig.getCurrentContext().getName());
kubeConfigBuilder.addToUsers(createKubeConfigUserFromClient(kubernetesClientConfig));
KubeConfigUtils.persistKubeConfigIntoFile(kubeConfigBuilder.build(), targetKubeConfig.toString());
KubeConfigUtils.persistKubeConfigIntoFile(kubeConfigBuilder.build(), targetKubeConfig.toFile());
return targetKubeConfig;
} catch (IOException ioException) {
throw new JKubeException("Failure in exporting KubernetesClient config : " + ioException.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import io.fabric8.kubernetes.api.model.HasMetadata;
Expand Down Expand Up @@ -53,7 +54,7 @@ public static boolean isOpenShift(KubernetesClient client) {


public static KubernetesList processTemplatesLocally(Template entity, boolean failOnMissingParameterValue) {
List<HasMetadata> objects = null;
List<?> objects = null;
if (entity != null) {
objects = entity.getObjects();
if (objects == null || objects.isEmpty()) {
Expand Down Expand Up @@ -86,7 +87,8 @@ public static KubernetesList processTemplatesLocally(Template entity, boolean fa
return Serialization.unmarshal(json, KubernetesList.class);
} else {
KubernetesList answer = new KubernetesList();
answer.setItems(objects);
Objects.requireNonNull(objects).stream().filter(o -> o instanceof HasMetadata)
.forEach(o -> answer.getItems().add((HasMetadata) o));
return answer;
}
}
Expand All @@ -109,9 +111,9 @@ public static boolean isFinished(String status) {
}

public static Template combineTemplates(Template firstTemplate, Template template) {
List<HasMetadata> objects = template.getObjects();
List<?> objects = template.getObjects();
if (objects != null) {
for (HasMetadata object : objects) {
for (Object object : objects) {
addTemplateObject(firstTemplate, object);
}
}
Expand Down Expand Up @@ -156,8 +158,8 @@ private static void combineParameters(List<Parameter> parameters, List<Parameter
}
}

private static void addTemplateObject(Template template, HasMetadata object) {
List<HasMetadata> objects = template.getObjects();
private static void addTemplateObject(Template template, Object object) {
List<Object> objects = template.getObjects();
objects.add(object);
template.setObjects(objects);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
import io.fabric8.kubernetes.client.dsl.NonDeletingOperation;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import io.fabric8.mockwebserver.http.RecordedRequest;
import io.fabric8.openshift.api.model.DeploymentConfig;
import io.fabric8.openshift.api.model.DeploymentConfigBuilder;
import io.fabric8.openshift.api.model.DeploymentConfigSpecBuilder;
import io.fabric8.openshift.client.OpenShiftClient;
import io.fabric8.zjsonpatch.JsonPatch;
import okhttp3.mockwebserver.RecordedRequest;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.assertj.core.groups.Tuple;
import org.eclipse.jkube.kit.common.JKubeConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.fabric8.kubernetes.client.NamespacedKubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import okhttp3.mockwebserver.RecordedRequest;
import io.fabric8.mockwebserver.http.RecordedRequest;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void push_withValidImage_shouldLogWarning() throws JKubeServiceException {
@Test
void initClient_withNoOpenShift_shouldThrowException() {
// Given
when(jKubeServiceHub.getClient().adapt(OpenShiftClient.class).isSupported()).thenReturn(false);
when(jKubeServiceHub.getClient().hasApiGroup("openshift.io", false)).thenReturn(false);
OpenshiftBuildService openshiftBuildService = new OpenshiftBuildService(jKubeServiceHub);
// When + Then
assertThatIllegalStateException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import io.fabric8.mockwebserver.http.RecordedRequest;
import io.fabric8.openshift.api.model.ImageStreamTagBuilder;
import io.fabric8.openshift.client.OpenShiftClient;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -63,7 +64,6 @@
import io.fabric8.openshift.api.model.ImageStreamBuilder;
import io.fabric8.openshift.api.model.ImageStreamStatusBuilder;
import io.fabric8.openshift.api.model.NamedTagEventListBuilder;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*/
package org.eclipse.jkube.kit.config.service.openshift;

import io.fabric8.mockwebserver.http.Headers;
import io.fabric8.mockwebserver.http.RecordedRequest;
import io.fabric8.mockwebserver.utils.ResponseProvider;
import okhttp3.Headers;
import okhttp3.mockwebserver.RecordedRequest;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,14 @@ private void enrichKubernetes(final KubernetesListBuilder builder) {
for (HasMetadata resource : templates) {
if (resource instanceof Template) {
Template template = (Template) resource;
List<HasMetadata> objects = template.getObjects();
List<?> objects = template.getObjects();
if (objects != null) {
removeTemplateObjects(kubernetesItems, objects);
kubernetesItems.addAll(objects);
for (Object object : objects) {
if (object instanceof HasMetadata) {
kubernetesItems.add((HasMetadata) object);
}
}
}
}
}
Expand All @@ -162,12 +166,16 @@ private void enrichOpenShift(final KubernetesListBuilder builder) {
filterAndAddItemsToBuilder(builder, openshiftItems);
}

private void removeTemplateObjects(List<HasMetadata> list, List<HasMetadata> objects) {
for (HasMetadata object : objects) {
private void removeTemplateObjects(List<HasMetadata> list, List<?> objects) {
for (Object object : objects) {
if (!(object instanceof HasMetadata)) {
continue;
}
HasMetadata hm = (HasMetadata) object;
List<HasMetadata> copy = new ArrayList<>(list);
for (HasMetadata resource : copy) {
if (Objects.equals(resource.getKind(), object.getKind()) &&
Objects.equals(KubernetesHelper.getName(object), KubernetesHelper.getName(resource))) {
if (Objects.equals(resource.getKind(), hm.getKind()) &&
Objects.equals(KubernetesHelper.getName(hm), KubernetesHelper.getName(resource))) {
list.remove(resource);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jkube.enricher.generic.ingress.ExtensionsV1beta1IngressConverter;
import org.eclipse.jkube.enricher.generic.ingress.NetworkingV1IngressGenerator;
import org.eclipse.jkube.kit.common.Configs;
import org.eclipse.jkube.kit.config.resource.IngressConfig;
Expand Down Expand Up @@ -95,10 +94,10 @@ private HasMetadata generateIngressWithConfiguredApiVersion(ServiceBuilder servi
serviceBuilder, getRouteDomain(), getConfig(Config.HOST), getIngressRuleXMLConfig(resourceConfig), getIngressTlsXMLConfig(resourceConfig));
HasMetadata generatedIngress = ingress;

String targetIngressApiVersion = getConfig(Config.TARGET_API_VERSION);
if (targetIngressApiVersion.equalsIgnoreCase("extensions/v1beta1")) {
generatedIngress = ExtensionsV1beta1IngressConverter.convert(ingress);
}
// String targetIngressApiVersion = getConfig(Config.TARGET_API_VERSION);
// if (targetIngressApiVersion.equalsIgnoreCase("extensions/v1beta1")) {
// generatedIngress = ExtensionsV1beta1IngressConverter.convert(ingress);
// }
return generatedIngress;
}

Expand Down

This file was deleted.

Loading

0 comments on commit 8190ed0

Please sign in to comment.