Skip to content

Commit

Permalink
Merge pull request #1472 from Vlatombe/tidy-up-JENKINS-72314
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlatombe authored Nov 16, 2023
2 parents d65bbc7 + cdcb8aa commit fd176ec
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public class KubernetesCloud extends Cloud implements PodTemplateGroup {
public KubernetesCloud(String name) {
super(name);
setMaxRequestsPerHost(DEFAULT_MAX_REQUESTS_PER_HOST);
setPodLabels(null);
}

/**
Expand Down Expand Up @@ -457,7 +456,7 @@ public void setLabels(Map<String, String> labels) {
*/
@NonNull
public List<PodLabel> getPodLabels() {
return podLabels == null ? List.of() : podLabels;
return podLabels == null || podLabels.isEmpty() ? PodLabel.fromMap(DEFAULT_POD_LABELS) : podLabels;
}

/**
Expand All @@ -466,7 +465,9 @@ public List<PodLabel> getPodLabels() {
@DataBoundSetter
public void setPodLabels(@CheckForNull List<PodLabel> labels) {
this.podLabels = new ArrayList<>();
this.podLabels.addAll(labels == null || labels.isEmpty() ? PodLabel.fromMap(DEFAULT_POD_LABELS) : labels);
if (labels != null) {
this.podLabels.addAll(labels);
}
}

/**
Expand Down Expand Up @@ -716,7 +717,7 @@ public boolean equals(Object o) {
Objects.equals(jenkinsUrl, that.jenkinsUrl) &&
Objects.equals(jenkinsTunnel, that.jenkinsTunnel) &&
Objects.equals(credentialsId, that.credentialsId) &&
Objects.equals(podLabels, that.podLabels) &&
Objects.equals(getPodLabels(), that.getPodLabels()) &&
Objects.equals(podRetention, that.podRetention) &&
Objects.equals(waitForPodSec, that.waitForPodSec) &&
useJenkinsProxy==that.useJenkinsProxy;
Expand Down Expand Up @@ -997,8 +998,8 @@ private Object readResolve() {
if (waitForPodSec == null) {
waitForPodSec = DEFAULT_WAIT_FOR_POD_SEC;
}
if (podLabels == null) {
setPodLabels(labels == null ? null : PodLabel.fromMap(labels));
if (podLabels == null && labels != null) {
setPodLabels(PodLabel.fromMap(labels));
}
if (containerCap != null && containerCap == 0) {
containerCap = null;
Expand Down

0 comments on commit fd176ec

Please sign in to comment.