Skip to content

Commit

Permalink
Merge pull request jenkinsci#54 from Vlatombe/update-kubernetes-clien…
Browse files Browse the repository at this point in the history
…t-api-5.x

Update kubernetes-client-api to 5.4.1
  • Loading branch information
jtnord authored Jun 23, 2021
2 parents a6a4bd0 + e0074cf commit 4a47970
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
35 changes: 30 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.2</version>
<version>4.18</version>
<relativePath />
</parent>

Expand All @@ -45,8 +45,9 @@
<properties>
<revision>0.19</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.190.1</jenkins.version>
<jenkins.version>2.222.4</jenkins.version>
<java.level>8</java.level>
<junit5.version>5.7.2</junit5.version>
</properties>

<scm>
Expand Down Expand Up @@ -144,7 +145,8 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jackson2-api</artifactId>
<version>2.10.2</version>
<version>2.12.3</version>

</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -164,7 +166,8 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>kubernetes-client-api</artifactId>
<version>4.6.0-2</version>
<version>5.4.1</version>

</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -186,6 +189,13 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>openstack-cloud</artifactId>
<exclusions>
<exclusion>
<!-- from snakeyaml-api -->
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<!-- Basic Username PrivateKey -->
Expand Down Expand Up @@ -233,7 +243,7 @@
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-server-mock</artifactId>
<version>4.6.0</version>
<version>5.4.1</version>
<scope>test</scope>
<exclusions>
<!-- fails maven enforcer because kubernetes-client has a different version
Expand Down Expand Up @@ -285,4 +295,19 @@
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit5.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package com.cloudbees.jenkins.plugins.kubernetes_credentials_provider;

import io.fabric8.kubernetes.client.WatcherException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -246,7 +247,7 @@ public void eventReceived(Action action, Secret secret) {
}

@Override
public void onClose(KubernetesClientException cause) {
public void onClose(WatcherException cause) {
if (cause != null) {
LOG.log(Level.WARNING, "Secrets watch stopped unexpectedly", cause);
LOG.log(Level.INFO, "Restating secrets watcher");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,8 @@ public static <T> T requireNonNull(@Nullable T obj, String exceptionMessage, @Nu
@SuppressFBWarnings(value= {"ES_COMPARING_PARAMETER_STRING_WITH_EQ"}, justification="the string will be the same string if not mapped")
public static String getNonNullSecretData(Secret s, String key, String exceptionMessage) throws CredentialsConvertionException {
String mappedKey = getKeyName(s, key);
if (mappedKey == key) { // use String == as getKeyName(key) will return key if no custom mapping is defined)
return requireNonNull(s.getData().get(key), exceptionMessage, null);
}
return requireNonNull(s.getData().get(mappedKey), exceptionMessage, mappedKey);
Map<String, String> data = requireNonNull(s.getData(), exceptionMessage, mappedKey == key ? null : mappedKey);
return requireNonNull(data.get(mappedKey), exceptionMessage, mappedKey);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.cloudbees.jenkins.plugins.kubernetes_credentials_provider;

import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;

import io.fabric8.kubernetes.client.WatcherException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -23,7 +21,6 @@
import hudson.security.ACL;
import io.fabric8.kubernetes.api.model.*;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import jenkins.model.Jenkins;
import jenkins.util.Timer;
Expand Down Expand Up @@ -149,7 +146,7 @@ public void restartWatchOnCloseException() throws Exception {
defaultMockKubernetesResponses();
KubernetesCredentialProvider provider = new MockedKubernetesCredentialProvider();
provider.startWatchingForSecrets();
provider.onClose(new KubernetesClientException("test exception"));
provider.onClose(new WatcherException("test exception"));
// expect 2 requests to list
assertRequestCount("/api/v1/namespaces/test/secrets?labelSelector=jenkins.io%2Fcredentials-type", 2);
}
Expand Down

0 comments on commit 4a47970

Please sign in to comment.