Work on port ranges - change all to strings#566
Work on port ranges - change all to strings#566larochef wants to merge 1 commit intodocker-java:masterfrom
Conversation
| * @see Ports#bind(ExposedPort, Binding) | ||
| * @see ExposedPort | ||
| */ | ||
| public Binding(Integer hostPort) { |
There was a problem hiding this comment.
Change to string? to be consistent?
There was a problem hiding this comment.
The thing is there already is a constructor same signature, that's why I didn't change the Integer. I guess it would be safer to have static factories instead, and only keep the constructor wil everything. What do you think ?
|
LGTM if api allow string, then it should be string. |
|
I'm not sure whether we should switch to |
|
Related documentation: https://docs.docker.com/engine/reference/run/#expose-incoming-ports
|
|
@marcuslinke well, if you would bundle cli logic into direct API requests that would end in difficult code. |
|
That's a good question, the string validation. I've been wondering if we should have a regexp, something like [1-9][0-9]+(-[1-9][0-9]+)? but then, if some new format appears in the docker api in the future, then we'll have to change again. So should we validate or let docker do it instead ? |
|
I think the point here is whether docker deamon returns a meaningful error in the case of invalid string. @larochef Could you check that please? Maybe validation is realized in docker CLI or in remote API or not at all. If validation is done in remote API we can use string without any problem. If validation is implemented in docker CLI we need at least validation in docker-java for this. |
|
I confirm that docker damon returns you a proper error. |
|
@larochef Thanks! But what is with the more complex constraints:
|
|
Ok, so after some investigation:
Should we support ranges and do the same magic as docker-cli or let the user handle ranges manually ? I don't think it's a good idea to let this too magic since each port binding requires some proxy magic by docker and consumes memory. |
|
OK, let summarize the possible cases for a mapping string from docker CLI perspective: case I think the third case (range to range) shouldn't be supported by docker-java. So we have to ensure that only the first and the second case will be possible with our API. Do you agree? |
| import com.github.dockerjava.api.model.RestartPolicy; | ||
| import com.github.dockerjava.api.model.Volume; | ||
| import com.github.dockerjava.api.model.VolumesFrom; | ||
| import com.github.dockerjava.api.model.*; |
There was a problem hiding this comment.
please don't replace imports with hashes.
|
Sorry for the imports, I'll check again my ide configuguration.. @marcuslinke I agree with that. I guess then we can leave the exposed port (the one from the container) as an int and have then the bound ports as strings since they can be ranges. If we want all as Strings, I guess then we'll have to add a check in the corresponding serializer. What do you think ? |
@larochef Thats what I thought also. Letting |
Current coverage is 30.51%
@@ master #566 diff @@
==========================================
Files 296 296
Lines 6129 6129
Methods 0 0
Messages 0 0
Branches 532 532
==========================================
+ Hits 1459 1870 +411
+ Misses 4585 4259 -326
+ Partials 85 0 -85
|
7d0b988 to
3901348
Compare
|
Ok, I've re-worked the PR in that way, tell what you think of it now. |
|
Good for me :) |
This is a fix for #556 allowing port ranges.
This change is