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

Extend 'addFixedExposedPort' method with InternetProtocol argument #586

Merged
merged 3 commits into from
Feb 21, 2018

Conversation

agafox
Copy link
Contributor

@agafox agafox commented Feb 17, 2018

No description provided.

* @param protocol an internet protocol (tcp or udp)
* @return this container
*/
public SELF withFixedExposedPort(int hostPort, int containerPort, InternetProtocol protocol) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather not leak docker-java implementation details into the public API. Instead I think we should use our own Enums here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point @kiview
Fixed.

*/
public enum InternetProtocol {

tcp,
Copy link
Member

Choose a reason for hiding this comment

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

Can you change the enums to uppercase please? 🙂

Copy link
Contributor Author

@agafox agafox Feb 18, 2018

Choose a reason for hiding this comment

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

@kiview If it's not your code style conventions I prefer to leave it as is rather then do implicit 'toLowerCase' and 'toUpperCase' modifications every time. Want to recall that this part is case sensitive in Docker and docker-java.

Copy link
Member

Choose a reason for hiding this comment

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

we use uppercase for enum values. If you want, you can create toDockerNotation/fromDockerNotation methods to encapsulate the conversion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bsideup Thank you for explanation. Added toDockerNotation/fromDockerNotation methods.

@bsideup bsideup added this to the next milestone Feb 18, 2018
@rnorth
Copy link
Member

rnorth commented Feb 18, 2018

See also #554 - this doesn't need to be done as part of this PR, but is useful to be aware of. It looks like this PR (e.g. creation of the enum) will help - thanks.

@agafox
Copy link
Contributor Author

agafox commented Feb 19, 2018

@kiview @bsideup should I fixed something else in term of this PR? @rnorth I took a look at #554 - very reasonable case but requires more changes for sure. I probably can help with it after this PR will be merged.

@@ -654,7 +654,22 @@ public SELF withExposedPorts(Integer... ports) {
* @param containerPort
*/
protected void addFixedExposedPort(int hostPort, int containerPort) {
portBindings.add(String.format("%d:%d", hostPort, containerPort));
addFixedExposedPort(hostPort, containerPort, InternetProtocol.TCP);
Copy link
Member

Choose a reason for hiding this comment

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

AFAIR if the protocol is not specified, it will use both, no? If so, this is a breaking change

Copy link
Contributor Author

@agafox agafox Feb 19, 2018

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

👍

@bsideup bsideup merged commit 87e22ec into testcontainers:master Feb 21, 2018
@bsideup
Copy link
Member

bsideup commented Feb 21, 2018

@agafox thanks for your contribution! 💪

@NaveenKVN
Copy link

Why is this methord protected in 1.19.0

protected void addFixedExposedPort(int hostPort, int containerPort, InternetProtocol protocol) {
this.portBindings.add(String.format("%d:%d/%s", hostPort, containerPort, protocol.toDockerNotation()));
}

This pull request was closed.
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.

5 participants