-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Replace deprecated checkAndPullImage
with RemoteDockerImage
#5148
Conversation
core/src/test/java/org/testcontainers/utility/AuthenticatedImagePullTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and nice cleanup 👍
@bsideup and others, while this is probably a great change, it's quite hard for me as a user to understand how I should edit my code to use the new API. 🤔 I looked but I couldn't find anything obvious in the release notes.
What we have (with 1.15.1) is something like this: DockerClientFactory clientFactory = DockerClientFactory.instance()
try {
clientFactory.checkAndPullImage(
clientFactory.client(),
containerName
);
return true;
}
catch ( NotFoundException e ) {
return false;
} In other words: attempt to pull an image, return |
Hey @perlun, can you give us the context/use-case of the code? Else it's hard to recommend what you should do instead. |
@kiview - the use case is to check if a specifically named remote container exist or not, and if not, choose a different code path (using another image without a pre-seeded DB structure and then create the DB structure manually instead). But one of my colleagues already solved this I think, without me even knowing about it. 🙂 Here's the replacement code, sharing it in the hope that it will be useful to others: try {
DockerImageName dockerImageName = DockerImageName.parse( preSeededDbContainerName );
RemoteDockerImage remoteDockerImage = new RemoteDockerImage( dockerImageName );
remoteDockerImage.get();
return true;
}
catch ( ContainerFetchException e ) {
return false;
} |
No description provided.