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 e3d6ae4
Show file tree
Hide file tree
Showing 42 changed files with 393 additions and 622 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
2 changes: 1 addition & 1 deletion gradle-plugin/kubernetes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-server-mock</artifactId>
<artifactId>kubernetes-server-mock</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
2 changes: 1 addition & 1 deletion gradle-plugin/openshift/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-server-mock</artifactId>
<artifactId>kubernetes-server-mock</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void pullImageWithPolicy_whenPullFailure_thenThrowException() throws IOException
// When
assertThatExceptionOfType(DockerAccessException.class)
.isThrownBy(() -> registryService.pullImageWithPolicy("example.org/foo/bar:latest", imagePullManager, registryConfig, buildConfiguration))
.withMessage("Unable to pull 'example.org/foo/bar:latest' from registry 'example.org' : {\"message\":\"ERROR\"} (Server Error: 500)");
.withMessage("Unable to pull 'example.org/foo/bar:latest' from registry 'example.org' : {\"message\":\"ERROR\"} (Internal Server Error: 500)");
}

private RegistryConfig createNewRegistryConfig(String registry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void pushImage_whenPushFailed_thenThrowException() throws IOException {
// When
assertThatExceptionOfType(DockerAccessException.class)
.isThrownBy(() -> registryService.pushImage(imageConfiguration, 0, registryConfig, false))
.withMessage("Unable to push 'example.org/foo/bar:latest' to registry 'example.org' : {\"message\":\"ERROR\"} (Server Error: 500)");
.withMessage("Unable to push 'example.org/foo/bar:latest' to registry 'example.org' : {\"message\":\"ERROR\"} (Internal Server Error: 500)");
}

@Test
Expand Down
11 changes: 6 additions & 5 deletions jkube-kit/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<artifactId>openshift-client</artifactId>
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-validator</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down Expand Up @@ -133,7 +138,7 @@
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-server-mock</artifactId>
<artifactId>kubernetes-server-mock</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand All @@ -143,10 +148,6 @@
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
</dependency>
<dependency>
<groupId>com.marcnuri.helm-java</groupId>
<artifactId>helm-java</artifactId>
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 @@ -13,27 +13,18 @@
*/
package org.eclipse.jkube.kit.common.util.validator;

import com.networknt.schema.ValidationMessage;
import io.fabric8.kubernetes.schema.validator.ValidationMessage;

/**
* Model to represent ignore validation rules as tuple of json tree path and constraint ruleType
* for resource descriptor validations
*/
public class IgnorePortValidationRule implements ValidationRule {

private final String ruleType;

public IgnorePortValidationRule(String aRuleType) {
this.ruleType = aRuleType;
}

public String getType() {
return ruleType;
}

@Override
public boolean ignore(ValidationMessage msg) {
return msg.getType().equalsIgnoreCase(TYPE) &&
msg.getMessage().contains(": integer found, object expected");
public boolean ignore(ValidationMessage validationMessage) {
return validationMessage.getLevel() == ValidationMessage.Level.ERROR &&
(validationMessage.getSchema() != null && validationMessage.getSchema().endsWith("/io.k8s.apimachinery.pkg.util.intstr.IntOrString")) &&
validationMessage.getMessage().matches(".+/(targetPort|port)'] Instance type \\(integer\\) does not match any allowed primitive type \\(allowed: \\[\\\"string\\\"\\]\\)$");
}
}

This file was deleted.

Loading

0 comments on commit e3d6ae4

Please sign in to comment.