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

Replace deprecated checkAndPullImage with RemoteDockerImage #5148

Merged
merged 8 commits into from
Mar 28, 2022

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented Mar 3, 2022

No description provided.

@bsideup bsideup added this to the next milestone Mar 3, 2022
@bsideup bsideup requested a review from rnorth March 4, 2022 11:59
Copy link
Member

@kiview kiview left a 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 bsideup merged commit 02782d9 into master Mar 28, 2022
@delete-merged-branch delete-merged-branch bot deleted the deprecate_checkAndPullImage branch March 28, 2022 15:13
@perlun
Copy link
Contributor

perlun commented Oct 27, 2022

@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.

use {@link RemoteDockerImage} doesn't tell me very much about how I should use that class. I gave it a try but it felt a bit non-obvious.

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 true if it exists; otherwise, false. What's the easiest way to transform the above to use RemoteDockerImage?

@kiview
Copy link
Member

kiview commented Oct 27, 2022

Hey @perlun, can you give us the context/use-case of the code? Else it's hard to recommend what you should do instead.

@perlun
Copy link
Contributor

perlun commented Nov 16, 2022

@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;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants