Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate file/volume mapping APIs #7652

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
```

Loading