-
-
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
Extend 'addFixedExposedPort' method with InternetProtocol argument #586
Conversation
* @param protocol an internet protocol (tcp or udp) | ||
* @return this container | ||
*/ | ||
public SELF withFixedExposedPort(int hostPort, int containerPort, InternetProtocol protocol) { |
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.
I'd rather not leak docker-java implementation details into the public API. Instead I think we should use our own Enums here.
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.
Good point @kiview
Fixed.
*/ | ||
public enum InternetProtocol { | ||
|
||
tcp, |
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.
Can you change the enums to uppercase please? 🙂
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.
@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.
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.
we use uppercase for enum values. If you want, you can create toDockerNotation
/fromDockerNotation
methods to encapsulate the conversion
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.
@bsideup Thank you for explanation. Added toDockerNotation/fromDockerNotation methods.
…style conventions
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. |
@@ -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); |
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.
AFAIR if the protocol is not specified, it will use both, no? If so, this is a breaking change
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.
No @bsideup by default it is TCP. Proof: https://docs.docker.com/config/containers/container-networking/
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.
👍
@agafox thanks for your contribution! 💪 |
Why is this methord protected in 1.19.0 protected void addFixedExposedPort(int hostPort, int containerPort, InternetProtocol protocol) { |
No description provided.