Skip to content

Commit cdcb8aa

Browse files
committed
[JENKINS-72314] Tidy up previous changes
1 parent d65bbc7 commit cdcb8aa

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ public class KubernetesCloud extends Cloud implements PodTemplateGroup {
148148
public KubernetesCloud(String name) {
149149
super(name);
150150
setMaxRequestsPerHost(DEFAULT_MAX_REQUESTS_PER_HOST);
151-
setPodLabels(null);
152151
}
153152

154153
/**
@@ -457,7 +456,7 @@ public void setLabels(Map<String, String> labels) {
457456
*/
458457
@NonNull
459458
public List<PodLabel> getPodLabels() {
460-
return podLabels == null ? List.of() : podLabels;
459+
return podLabels == null || podLabels.isEmpty() ? PodLabel.fromMap(DEFAULT_POD_LABELS) : podLabels;
461460
}
462461

463462
/**
@@ -466,7 +465,9 @@ public List<PodLabel> getPodLabels() {
466465
@DataBoundSetter
467466
public void setPodLabels(@CheckForNull List<PodLabel> labels) {
468467
this.podLabels = new ArrayList<>();
469-
this.podLabels.addAll(labels == null || labels.isEmpty() ? PodLabel.fromMap(DEFAULT_POD_LABELS) : labels);
468+
if (labels != null) {
469+
this.podLabels.addAll(labels);
470+
}
470471
}
471472

472473
/**
@@ -716,7 +717,7 @@ public boolean equals(Object o) {
716717
Objects.equals(jenkinsUrl, that.jenkinsUrl) &&
717718
Objects.equals(jenkinsTunnel, that.jenkinsTunnel) &&
718719
Objects.equals(credentialsId, that.credentialsId) &&
719-
Objects.equals(podLabels, that.podLabels) &&
720+
Objects.equals(getPodLabels(), that.getPodLabels()) &&
720721
Objects.equals(podRetention, that.podRetention) &&
721722
Objects.equals(waitForPodSec, that.waitForPodSec) &&
722723
useJenkinsProxy==that.useJenkinsProxy;
@@ -997,8 +998,8 @@ private Object readResolve() {
997998
if (waitForPodSec == null) {
998999
waitForPodSec = DEFAULT_WAIT_FOR_POD_SEC;
9991000
}
1000-
if (podLabels == null) {
1001-
setPodLabels(labels == null ? null : PodLabel.fromMap(labels));
1001+
if (podLabels == null && labels != null) {
1002+
setPodLabels(PodLabel.fromMap(labels));
10021003
}
10031004
if (containerCap != null && containerCap == 0) {
10041005
containerCap = null;

0 commit comments

Comments
 (0)