Skip to content

Commit 717152e

Browse files
authored
Support propagation modes rslave, rshared and rprivate in Bind.parse (#2519)
Fixes #2271
1 parent 55e4593 commit 717152e

File tree

2 files changed

+54
-0
lines changed
  • docker-java-api/src/main/java/com/github/dockerjava/api/model
  • docker-java/src/test/java/com/github/dockerjava/api/model

2 files changed

+54
-0
lines changed

docker-java-api/src/main/java/com/github/dockerjava/api/model/Bind.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,16 @@ public static Bind parse(String serialized) {
118118
nocopy = true;
119119
} else if (PropagationMode.SHARED.toString().equals(p)) {
120120
propagationMode = PropagationMode.SHARED;
121+
} else if (PropagationMode.RSHARED.toString().equals(p)) {
122+
propagationMode = PropagationMode.RSHARED;
121123
} else if (PropagationMode.SLAVE.toString().equals(p)) {
122124
propagationMode = PropagationMode.SLAVE;
125+
} else if (PropagationMode.RSLAVE.toString().equals(p)) {
126+
propagationMode = PropagationMode.RSLAVE;
123127
} else if (PropagationMode.PRIVATE.toString().equals(p)) {
124128
propagationMode = PropagationMode.PRIVATE;
129+
} else if (PropagationMode.RPRIVATE.toString().equals(p)) {
130+
propagationMode = PropagationMode.RPRIVATE;
125131
} else {
126132
seMode = SELContext.fromString(p);
127133
}

docker-java/src/test/java/com/github/dockerjava/api/model/BindTest.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ public void parseReadWriteShared() {
166166
assertThat(bind.getPropagationMode(), is(PropagationMode.SHARED));
167167
}
168168

169+
@Test
170+
public void parseReadWriteRshared() {
171+
Bind bind = Bind.parse("/host:/container:rw,rshared");
172+
assertThat(bind.getPath(), is("/host"));
173+
assertThat(bind.getVolume().getPath(), is("/container"));
174+
assertThat(bind.getAccessMode(), is(rw));
175+
assertThat(bind.getSecMode(), is(SELContext.none));
176+
assertThat(bind.getNoCopy(), nullValue());
177+
assertThat(bind.getPropagationMode(), is(PropagationMode.RSHARED));
178+
}
179+
169180
@Test
170181
public void parseReadWriteSlave() {
171182
Bind bind = Bind.parse("/host:/container:rw,slave");
@@ -177,6 +188,17 @@ public void parseReadWriteSlave() {
177188
assertThat(bind.getPropagationMode(), is(PropagationMode.SLAVE));
178189
}
179190

191+
@Test
192+
public void parseReadWriteRslave() {
193+
Bind bind = Bind.parse("/host:/container:rw,rslave");
194+
assertThat(bind.getPath(), is("/host"));
195+
assertThat(bind.getVolume().getPath(), is("/container"));
196+
assertThat(bind.getAccessMode(), is(rw));
197+
assertThat(bind.getSecMode(), is(SELContext.none));
198+
assertThat(bind.getNoCopy(), nullValue());
199+
assertThat(bind.getPropagationMode(), is(PropagationMode.RSLAVE));
200+
}
201+
180202
@Test
181203
public void parseReadWritePrivate() {
182204
Bind bind = Bind.parse("/host:/container:rw,private");
@@ -188,6 +210,17 @@ public void parseReadWritePrivate() {
188210
assertThat(bind.getPropagationMode(), is(PropagationMode.PRIVATE));
189211
}
190212

213+
@Test
214+
public void parseReadWriteRprivate() {
215+
Bind bind = Bind.parse("/host:/container:rw,rprivate");
216+
assertThat(bind.getPath(), is("/host"));
217+
assertThat(bind.getVolume().getPath(), is("/container"));
218+
assertThat(bind.getAccessMode(), is(rw));
219+
assertThat(bind.getSecMode(), is(SELContext.none));
220+
assertThat(bind.getNoCopy(), nullValue());
221+
assertThat(bind.getPropagationMode(), is(PropagationMode.RPRIVATE));
222+
}
223+
191224
@Test
192225
public void parseReadOnly() {
193226
Bind bind = Bind.parse("/host:/container:ro");
@@ -284,16 +317,31 @@ public void toStringReadWriteShared() {
284317
assertThat(Bind.parse("/host:/container:rw,shared").toString(), is("/host:/container:rw,shared"));
285318
}
286319

320+
@Test
321+
public void toStringReadWriteRshared() {
322+
assertThat(Bind.parse("/host:/container:rw,rshared").toString(), is("/host:/container:rw,rshared"));
323+
}
324+
287325
@Test
288326
public void toStringReadWriteSlave() {
289327
assertThat(Bind.parse("/host:/container:rw,slave").toString(), is("/host:/container:rw,slave"));
290328
}
291329

330+
@Test
331+
public void toStringReadWriteRslave() {
332+
assertThat(Bind.parse("/host:/container:rw,rslave").toString(), is("/host:/container:rw,rslave"));
333+
}
334+
292335
@Test
293336
public void toStringReadWritePrivate() {
294337
assertThat(Bind.parse("/host:/container:rw,private").toString(), is("/host:/container:rw,private"));
295338
}
296339

340+
@Test
341+
public void toStringReadWriteRprivate() {
342+
assertThat(Bind.parse("/host:/container:rw,rprivate").toString(), is("/host:/container:rw,rprivate"));
343+
}
344+
297345
@Test
298346
public void toStringDefaultAccessMode() {
299347
assertThat(Bind.parse("/host:/container").toString(), is("/host:/container:rw"));

0 commit comments

Comments
 (0)