Skip to content

Commit

Permalink
Deprecate file/volume mapping APIs (#7652)
Browse files Browse the repository at this point in the history
Using `Copy Files API` will make tests portable cross docker environments.
Docs are removed too.
  • Loading branch information
eddumelendez committed Oct 23, 2023
1 parent 3b8c869 commit 34853fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
12 changes: 12 additions & 0 deletions core/src/main/java/org/testcontainers/containers/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class ExecResult {
* @param hostPath the file system path on the host
* @param containerPath the file system path inside the container
* @param mode the bind mode
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
*/
@Deprecated
default void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode) {
addFileSystemBind(hostPath, containerPath, mode, SelinuxContext.SHARED);
}
Expand All @@ -90,7 +92,9 @@ default void addFileSystemBind(final String hostPath, final String containerPath
* @param containerPath the file system path inside the container
* @param mode the bind mode
* @param selinuxContext selinux context argument to use for this file
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
*/
@Deprecated
void addFileSystemBind(String hostPath, String containerPath, BindMode mode, SelinuxContext selinuxContext);

/**
Expand Down Expand Up @@ -134,7 +138,9 @@ default void addFileSystemBind(final String hostPath, final String containerPath
* @param hostPath the file system path on the host
* @param containerPath the file system path inside the container
* @return this
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
*/
@Deprecated
default SELF withFileSystemBind(String hostPath, String containerPath) {
return withFileSystemBind(hostPath, containerPath, BindMode.READ_WRITE);
}
Expand All @@ -146,7 +152,9 @@ default SELF withFileSystemBind(String hostPath, String containerPath) {
* @param containerPath the file system path inside the container
* @param mode the bind mode
* @return this
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
*/
@Deprecated
SELF withFileSystemBind(String hostPath, String containerPath, BindMode mode);

/**
Expand Down Expand Up @@ -297,7 +305,9 @@ default SELF withEnv(String key, Function<Optional<String>, String> mapper) {
* @param containerPath path this should be mapped to inside the container
* @param mode access mode for the file
* @return this
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
*/
@Deprecated
default SELF withClasspathResourceMapping(
final String resourcePath,
final String containerPath,
Expand All @@ -316,7 +326,9 @@ default SELF withClasspathResourceMapping(
* @param mode access mode for the file
* @param selinuxContext selinux context argument to use for this file
* @return this
* @deprecated use {@link GenericContainer#withCopyToContainer(Transferable, String)}
*/
@Deprecated
SELF withClasspathResourceMapping(
String resourcePath,
String containerPath,
Expand Down
20 changes: 0 additions & 20 deletions docs/features/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,3 @@ Setting file mode is also possible.
<!--codeinclude-->
[Copying files from a container](../../core/src/test/java/org/testcontainers/junit/CopyFileToContainerTest.java) inside_block:copyFileFromContainer
<!--/codeinclude-->

## File mapping

It is possible to map a file or directory from your FileSystem into the container as a volume using `withFileSystemBind`:
```java
String pathToFile = System.getProperty("user.home") + "/.aws";
new GenericContainer(...)
.withFileSystemBind(pathToFile, "/home/user/.aws", BindMode.READ_ONLY)
```

## Volume mapping

It is possible to map a file or directory **on the classpath** into the container as a volume using `withClasspathResourceMapping`:
```java
new GenericContainer(...)
.withClasspathResourceMapping("redis.conf",
"/etc/redis.conf",
BindMode.READ_ONLY)
```

0 comments on commit 34853fe

Please sign in to comment.