-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that all test container images are locally provided
- Loading branch information
1 parent
d67fa5b
commit 50630c5
Showing
7 changed files
with
121 additions
and
18 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
33 changes: 33 additions & 0 deletions
33
...ontainers/src/main/java/com/jordansimsmith/testcontainers/LoadedImageNameSubstitutor.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,33 @@ | ||
package com.jordansimsmith.testcontainers; | ||
|
||
import com.google.common.base.Preconditions; | ||
import org.testcontainers.utility.DockerImageName; | ||
import org.testcontainers.utility.ImageNameSubstitutor; | ||
import org.testcontainers.utility.TestcontainersConfiguration; | ||
|
||
public class LoadedImageNameSubstitutor extends ImageNameSubstitutor { | ||
|
||
@Override | ||
public DockerImageName apply(DockerImageName original) { | ||
if (original.toString().equals("testcontainers/ryuk:0.7.0")) { | ||
return LoadedImage.loadImage("ryuk.image.name", "ryuk.image.loader"); | ||
} | ||
|
||
var loadedPrefix = | ||
TestcontainersConfiguration.getInstance() | ||
.getClasspathProperties() | ||
.getProperty("loaded.image.prefix"); | ||
Preconditions.checkNotNull(loadedPrefix); | ||
if (original.toString().startsWith(loadedPrefix)) { | ||
return original; | ||
} | ||
|
||
throw new IllegalArgumentException( | ||
"All images must be loaded, refusing to resolve image:" + original); | ||
} | ||
|
||
@Override | ||
protected String getDescription() { | ||
return this.getClass().toString(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
lib/testcontainers/src/main/resources/testcontainers.properties
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 |
---|---|---|
@@ -1,2 +1,8 @@ | ||
image.substitutor=com.jordansimsmith.testcontainers.LoadedImageNameSubstitutor | ||
loaded.image.prefix=bazel/ | ||
|
||
ryuk.image.name=bazel/ryuk:ryuk | ||
ryuk.image.loader=lib/testcontainers/ryuk-load.sh | ||
|
||
dynamodb.image.name=bazel/dynamodb:dynamodb | ||
dynamodb.image.loader=lib/testcontainers/dynamodb-load.sh |