Skip to content

Commit 34853fe

Browse files
authored
Deprecate file/volume mapping APIs (#7652)
Using `Copy Files API` will make tests portable cross docker environments. Docs are removed too.
1 parent 3b8c869 commit 34853fe

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

core/src/main/java/org/testcontainers/containers/Container.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class ExecResult {
7777
* @param hostPath the file system path on the host
7878
* @param containerPath the file system path inside the container
7979
* @param mode the bind mode
80+
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
8081
*/
82+
@Deprecated
8183
default void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode) {
8284
addFileSystemBind(hostPath, containerPath, mode, SelinuxContext.SHARED);
8385
}
@@ -90,7 +92,9 @@ default void addFileSystemBind(final String hostPath, final String containerPath
9092
* @param containerPath the file system path inside the container
9193
* @param mode the bind mode
9294
* @param selinuxContext selinux context argument to use for this file
95+
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
9396
*/
97+
@Deprecated
9498
void addFileSystemBind(String hostPath, String containerPath, BindMode mode, SelinuxContext selinuxContext);
9599

96100
/**
@@ -134,7 +138,9 @@ default void addFileSystemBind(final String hostPath, final String containerPath
134138
* @param hostPath the file system path on the host
135139
* @param containerPath the file system path inside the container
136140
* @return this
141+
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
137142
*/
143+
@Deprecated
138144
default SELF withFileSystemBind(String hostPath, String containerPath) {
139145
return withFileSystemBind(hostPath, containerPath, BindMode.READ_WRITE);
140146
}
@@ -146,7 +152,9 @@ default SELF withFileSystemBind(String hostPath, String containerPath) {
146152
* @param containerPath the file system path inside the container
147153
* @param mode the bind mode
148154
* @return this
155+
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
149156
*/
157+
@Deprecated
150158
SELF withFileSystemBind(String hostPath, String containerPath, BindMode mode);
151159

152160
/**
@@ -297,7 +305,9 @@ default SELF withEnv(String key, Function<Optional<String>, String> mapper) {
297305
* @param containerPath path this should be mapped to inside the container
298306
* @param mode access mode for the file
299307
* @return this
308+
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
300309
*/
310+
@Deprecated
301311
default SELF withClasspathResourceMapping(
302312
final String resourcePath,
303313
final String containerPath,
@@ -316,7 +326,9 @@ default SELF withClasspathResourceMapping(
316326
* @param mode access mode for the file
317327
* @param selinuxContext selinux context argument to use for this file
318328
* @return this
329+
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
319330
*/
331+
@Deprecated
320332
SELF withClasspathResourceMapping(
321333
String resourcePath,
322334
String containerPath,

docs/features/files.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,3 @@ Setting file mode is also possible.
3030
<!--codeinclude-->
3131
[Copying files from a container](../../core/src/test/java/org/testcontainers/junit/CopyFileToContainerTest.java) inside_block:copyFileFromContainer
3232
<!--/codeinclude-->
33-
34-
## File mapping
35-
36-
It is possible to map a file or directory from your FileSystem into the container as a volume using `withFileSystemBind`:
37-
```java
38-
String pathToFile = System.getProperty("user.home") + "/.aws";
39-
new GenericContainer(...)
40-
.withFileSystemBind(pathToFile, "/home/user/.aws", BindMode.READ_ONLY)
41-
```
42-
43-
## Volume mapping
44-
45-
It is possible to map a file or directory **on the classpath** into the container as a volume using `withClasspathResourceMapping`:
46-
```java
47-
new GenericContainer(...)
48-
.withClasspathResourceMapping("redis.conf",
49-
"/etc/redis.conf",
50-
BindMode.READ_ONLY)
51-
```
52-

0 commit comments

Comments
 (0)