From 859a2539b6ada481a9be80f521e2f65ed971d8e4 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Thu, 16 Nov 2023 15:25:32 +0100 Subject: [PATCH] Fix tests --- .../jenkins/plugins/kubernetes/KubernetesCloud.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java index 663f0cbee9..0f217c7dfa 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java @@ -148,7 +148,7 @@ public class KubernetesCloud extends Cloud implements PodTemplateGroup { public KubernetesCloud(String name) { super(name); setMaxRequestsPerHost(DEFAULT_MAX_REQUESTS_PER_HOST); - setPodLabels(PodLabel.fromMap(DEFAULT_POD_LABELS)); + setPodLabels(null); } /** @@ -466,9 +466,7 @@ public List getPodLabels() { @DataBoundSetter public void setPodLabels(@CheckForNull List labels) { this.podLabels = new ArrayList<>(); - if (labels != null) { - this.podLabels.addAll(labels); - } + this.podLabels.addAll(labels == null || labels.isEmpty() ? PodLabel.fromMap(DEFAULT_POD_LABELS) : labels); } /** @@ -999,8 +997,8 @@ private Object readResolve() { if (waitForPodSec == null) { waitForPodSec = DEFAULT_WAIT_FOR_POD_SEC; } - if (podLabels == null && labels != null) { - setPodLabels(PodLabel.fromMap(labels)); + if (podLabels == null) { + setPodLabels(labels == null ? null : PodLabel.fromMap(labels)); } if (containerCap != null && containerCap == 0) { containerCap = null;