Skip to content

Commit c29d66b

Browse files
authored
Merge branch 'master' into getRunListener
2 parents 38531d0 + 7e804ca commit c29d66b

File tree

12 files changed

+50
-28
lines changed

12 files changed

+50
-28
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.jenkins-ci.plugins</groupId>
55
<artifactId>plugin</artifactId>
6-
<version>4.62</version>
6+
<version>4.67</version>
77
<relativePath/>
88
</parent>
99

@@ -45,7 +45,7 @@
4545
<connectorHost />
4646
<jenkins.host.address />
4747
<slaveAgentPort />
48-
<jenkins.version>2.361.4</jenkins.version>
48+
<jenkins.version>2.387.3</jenkins.version>
4949
<no-test-jar>false</no-test-jar>
5050
<useBeta>true</useBeta>
5151
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
@@ -251,8 +251,8 @@
251251
<dependencies>
252252
<dependency>
253253
<groupId>io.jenkins.tools.bom</groupId>
254-
<artifactId>bom-2.361.x</artifactId>
255-
<version>1836.vfe602c266c05</version>
254+
<artifactId>bom-2.387.x</artifactId>
255+
<version>2163.v2d916d90c305</version>
256256
<scope>import</scope>
257257
<type>pom</type>
258258
</dependency>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar;
5252
import org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution;
5353
import org.csanchez.jenkins.plugins.kubernetes.pod.decorator.PodDecorator;
54+
import org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume;
5455
import org.csanchez.jenkins.plugins.kubernetes.volumes.PodVolume;
5556
import org.csanchez.jenkins.plugins.kubernetes.volumes.ConfigMapVolume;
5657
import org.kohsuke.accmod.Restricted;
@@ -196,6 +197,11 @@ public Pod build() {
196197
volumeMountBuilder = volumeMountBuilder.withSubPath(normalizePath(subPath));
197198
}
198199
}
200+
if (volume instanceof HostPathVolume) {
201+
final HostPathVolume hostPathVolume = (HostPathVolume) volume;
202+
Boolean readOnly = hostPathVolume.getReadOnly();
203+
volumeMountBuilder = volumeMountBuilder.withReadOnly(readOnly);
204+
}
199205
volumeMounts.put(mountPath, volumeMountBuilder.build());
200206
volumes.put(volumeName, volume.buildVolume(volumeName, podName));
201207
i++;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ protected Object readResolve() {
4040
@Deprecated
4141
public static class HostPathVolume extends org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume {
4242

43-
public HostPathVolume(String hostPath, String mountPath) {
44-
super(hostPath, mountPath);
43+
public HostPathVolume(String hostPath, String mountPath, Boolean readOnly) {
44+
super(hostPath, mountPath, readOnly);
4545
}
4646

4747
protected Object readResolve() {
4848
return new org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume(this.getHostPath(),
49-
this.getMountPath());
49+
this.getMountPath(), this.getReadOnly());
5050
}
5151
}
5252

src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
package org.csanchez.jenkins.plugins.kubernetes.volumes;
2626

27+
import edu.umd.cs.findbugs.annotations.CheckForNull;
28+
import edu.umd.cs.findbugs.annotations.NonNull;
2729
import org.jenkinsci.Symbol;
2830
import org.kohsuke.stapler.DataBoundConstructor;
2931

@@ -36,10 +38,14 @@ public class HostPathVolume extends PodVolume {
3638
private String mountPath;
3739
private String hostPath;
3840

41+
@CheckForNull
42+
private Boolean readOnly;
43+
3944
@DataBoundConstructor
40-
public HostPathVolume(String hostPath, String mountPath) {
45+
public HostPathVolume(String hostPath, String mountPath, Boolean readOnly) {
4146
this.hostPath = hostPath;
4247
this.mountPath = mountPath;
48+
this.readOnly = readOnly;
4349
}
4450

4551
public Volume buildVolume(String volumeName) {
@@ -57,6 +63,11 @@ public String getHostPath() {
5763
return hostPath;
5864
}
5965

66+
@NonNull
67+
public Boolean getReadOnly() {
68+
return readOnly != null && readOnly;
69+
}
70+
6071
@Extension
6172
@Symbol("hostPathVolume")
6273
public static class DescriptorImpl extends Descriptor<PodVolume> {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM jenkins/inbound-agent:3107.v665000b_51092-5
1+
FROM jenkins/inbound-agent:3107.v665000b_51092-15

src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume/config.jelly

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010
<f:textbox />
1111
</f:entry>
1212

13+
<f:entry title="${%Read Only}" field="readOnly">
14+
<f:checkbox />
15+
</f:entry>
16+
1317
</j:jelly>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Flag for read-only mount, set hostPath mount to readOnly is considered best-practice.

src/test/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloudTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
import java.util.logging.Level;
1515
import java.util.logging.Logger;
1616

17-
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
18-
import com.gargoylesoftware.htmlunit.html.DomElement;
19-
import com.gargoylesoftware.htmlunit.html.DomNodeList;
20-
import com.gargoylesoftware.htmlunit.html.HtmlButton;
21-
import com.gargoylesoftware.htmlunit.html.HtmlElement;
22-
import com.gargoylesoftware.htmlunit.html.HtmlForm;
23-
import com.gargoylesoftware.htmlunit.html.HtmlFormUtil;
24-
import com.gargoylesoftware.htmlunit.html.HtmlInput;
25-
import com.gargoylesoftware.htmlunit.html.HtmlPage;
17+
import org.htmlunit.ElementNotFoundException;
18+
import org.htmlunit.html.DomElement;
19+
import org.htmlunit.html.DomNodeList;
20+
import org.htmlunit.html.HtmlButton;
21+
import org.htmlunit.html.HtmlElement;
22+
import org.htmlunit.html.HtmlForm;
23+
import org.htmlunit.html.HtmlFormUtil;
24+
import org.htmlunit.html.HtmlInput;
25+
import org.htmlunit.html.HtmlPage;
2626
import org.apache.commons.beanutils.PropertyUtils;
2727
import org.apache.commons.lang3.RandomStringUtils;
2828
import org.apache.commons.lang3.RandomUtils;
@@ -266,7 +266,7 @@ public void defaultWorkspaceVolume() throws Exception {
266266
buttonDetails.click();
267267
DomElement templates = p.getElementByName("templates");
268268
HtmlInput templateName = getInputByName(templates, "_.name");
269-
templateName.setValueAttribute("default-workspace-volume");
269+
templateName.setValue("default-workspace-volume");
270270
j.submit(f);
271271
cloud = j.jenkins.clouds.get(KubernetesCloud.class);
272272
PodTemplate podTemplate = cloud.getTemplates().get(0);

src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public void testBuildFromTemplate(boolean directConnection) throws Exception {
289289
template.setHostNetwork(false);
290290

291291
List<PodVolume> volumes = new ArrayList<PodVolume>();
292-
volumes.add(new HostPathVolume("/host/data", "/container/data"));
292+
volumes.add(new HostPathVolume("/host/data", "/container/data", false));
293293
volumes.add(new EmptyDirVolume("/empty/dir", false));
294294
template.setVolumes(volumes);
295295

src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtilsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,13 @@ public void shouldTreatNullEnvFromSouresAsEmpty(boolean parentEnvNull, boolean t
527527
@Test
528528
public void shouldCombineAllMounts() {
529529
PodTemplate template1 = new PodTemplate();
530-
HostPathVolume hostPathVolume1 = new HostPathVolume("/host/mnt1", "/container/mnt1");
531-
HostPathVolume hostPathVolume2 = new HostPathVolume("/host/mnt2", "/container/mnt2");
530+
HostPathVolume hostPathVolume1 = new HostPathVolume("/host/mnt1", "/container/mnt1", false);
531+
HostPathVolume hostPathVolume2 = new HostPathVolume("/host/mnt2", "/container/mnt2", false);
532532
template1.setVolumes(asList(hostPathVolume1, hostPathVolume2));
533533

534534
PodTemplate template2 = new PodTemplate();
535-
HostPathVolume hostPathVolume3 = new HostPathVolume("/host/mnt3", "/container/mnt3");
536-
HostPathVolume hostPathVolume4 = new HostPathVolume("/host/mnt1", "/container/mnt4");
535+
HostPathVolume hostPathVolume3 = new HostPathVolume("/host/mnt3", "/container/mnt3", false);
536+
HostPathVolume hostPathVolume4 = new HostPathVolume("/host/mnt1", "/container/mnt4", false);
537537
template2.setVolumes(asList(hostPathVolume3, hostPathVolume4));
538538

539539
PodTemplate result = combine(template1, template2);

0 commit comments

Comments
 (0)