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

Image name in remote docker image to string #2450

Conversation

dbyron0
Copy link
Contributor

@dbyron0 dbyron0 commented Mar 17, 2020

With this change, the ContainerFetchException looks like:

org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=doesnotexist:latest, imagePullPolicy=DefaultPullPolicy(), dockerClient=LazyDockerClient.INSTANCE)

where before it looked like:

org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageNameFuture=java.util.concurrent.CompletableFuture@6b37db36[Completed normally], imagePullPolicy=DefaultPullPolicy(), dockerClient=LazyDockerClient.INSTANCE)

@dbyron0 dbyron0 force-pushed the image_name_in_RemoteDockerImage_toString branch from dc4a5c8 to 12c3b1c Compare March 17, 2020 23:38
@@ -95,4 +95,10 @@ protected final String resolve() {
throw new ContainerFetchException("Failed to get Docker client for " + imageName, e);
}
}

@ToString.Include(name = "imageName", rank = 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add more tests for the scenario where imageNameFuture fails

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to do this...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a crack at it with 9b31632

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw why did you remove Lombok's toString? I really liked the @ToString.Include approach :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seemed like I needed a place to add logic about using imageName if available, and falling back to imageNameFuture.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm staring at it again now and I see a potential struggle. If I use @ToString.Include the "key" in the resulting string is always the same. I no longer get to choose whether to have imageName=foo when I have an image name, and fall back to imageNameFuture=....

But maybe it's OK, or even better, to have imageName= in both cases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbyron0 could you please share examples of the toString call of both options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With @ToString.Include:

  • when imageName is available: RemoteDockerImage{imageName=ibemazgg:latest, imagePullPolicy=DefaultPullPolicy(), dockerClient=LazyDockerClient.INSTANCE}
  • when imageName isn't available: RemoteDockerImage{imageName=org.testcontainers.images.RemoteDockerImage$1@5d01486, imagePullPolicy=DefaultPullPolicy(), dockerClient=LazyDockerClient.INSTANCE}

Without lombok:

  • when imageName is available: RemoteDockerImage{imageName=ibemazgg:latest, imagePullPolicy=DefaultPullPolicy(), dockerClient=LazyDockerClient.INSTANCE}
  • when imageName isn't available: RemoteDockerImage{imageNameFuture=org.testcontainers.images.RemoteDockerImage$1@5d01486, imagePullPolicy=DefaultPullPolicy(), dockerClient=LazyDockerClient.INSTANCE}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda like the Lombok version :)

side note: I would also exclude dockerClient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough: 1a31c5c

Would love a hand figure out the test failure / calling isDone.

@bsideup
Copy link
Member

bsideup commented Apr 11, 2020

@dbyron0 I am looking at the test failure now. Have you got a chance to debug it further?

@dbyron0
Copy link
Contributor Author

dbyron0 commented Apr 11, 2020

Sorry, I haven't.

@bsideup
Copy link
Member

bsideup commented Apr 12, 2020

@dbyron0 could you please give me permissions to push to your PR? I have a fix :)

@bsideup
Copy link
Member

bsideup commented Apr 12, 2020

Superseeded by #2450

@bsideup bsideup closed this Apr 12, 2020
@dbyron0
Copy link
Contributor Author

dbyron0 commented Apr 12, 2020

Guess I wasn't fast enough...Looks like #2558 took over from here.

Thanks much!

@rnorth
Copy link
Member

rnorth commented Apr 13, 2020

This was released in https://github.com/testcontainers/testcontainers-java/releases/tag/1.14.0 🎉

Thanks for the contribution!

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.

None yet

3 participants