-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interface to customize CreateContainerCmd via SPI
Add `CreateContainerCmdCustomizer` interface to customize `CreateContainerCmd`. Customization is applied after Testcontainers configuration is set.
- Loading branch information
1 parent
5e88c3d
commit 3a02788
Showing
6 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
core/src/main/java/org/testcontainers/core/CreateContainerCmdCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.testcontainers.core; | ||
|
||
import com.github.dockerjava.api.command.CreateContainerCmd; | ||
|
||
/** | ||
* Callback interface that can be used to customize a {@link CreateContainerCmd}. | ||
*/ | ||
public interface CreateContainerCmdCustomizer { | ||
/** | ||
* Callback to customize a {@link CreateContainerCmd} instance. | ||
* @param createContainerCmd the create command to customize | ||
*/ | ||
void customize(CreateContainerCmd createContainerCmd); | ||
} |
12 changes: 12 additions & 0 deletions
12
core/src/test/java/org/testcontainers/custom/TestCreateContainerCmdCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.testcontainers.custom; | ||
|
||
import com.github.dockerjava.api.command.CreateContainerCmd; | ||
import org.testcontainers.core.CreateContainerCmdCustomizer; | ||
|
||
public class TestCreateContainerCmdCustomizer implements CreateContainerCmdCustomizer { | ||
|
||
@Override | ||
public void customize(CreateContainerCmd createContainerCmd) { | ||
createContainerCmd.getLabels().put("project", "testcontainers-java"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...src/test/resources/META-INF/services/org.testcontainers.core.CreateContainerCmdCustomizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.testcontainers.custom.TestCreateContainerCmdCustomizer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters