-
Notifications
You must be signed in to change notification settings - Fork 2k
Convert ports before parsing. #2251
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
Conversation
e94aa6f
to
cbe2887
Compare
rebased, and addressed nits 👍 ptal |
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.
LGTM
ping @silvin-lubecki PTAL |
cli/command/container/opts.go
Outdated
8000
} | ||
|
||
params[opt[0]] = opt[1] | ||
optsList = append(optsList, fmt.Sprintf("%s:%s/%s", params["target"], params["published"], params["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.
Note; this needs to be updated once #2252 is merged
Also; looking at how it's serialised to a string:
- host-ip is not in the serialised form. while this looks to be currently not supported in the long form (we should), having a combination of "long" and "short" options could possibly mean that duplicates go unnoticed (I'd have to check). i.e.,
-p 0.0.0.0:8080:80
is the equivalent to-p published=8080,target=80
, but the latter is serialised to8080:80
(not0.0.0.0:8080:80
). Then again, we may already have a problem if-p 0.0.0.0:8080:80
and-p 127.0.0.1:8080:80
are both set 🤔 - the long-form
mode=host
is only supported for swarm services (wondering if it should be added as a no-op option fordocker run
🤔
Perhaps with some refactoring, we can re-use the PortOpt
type for both docker run
and docker service
(separating validation to produce errors on options that are not supported by either docker run
or docker service
);
Line 29 in 2634562
func (p *PortOpt) Set(value string) error { |
Refactor code to allow mixed notation with -p flag. Signed-off-by: Aleksander Piotrowski <apiotrowski312@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
cbe2887
to
c2c7503
Compare
Codecov Report
@@ Coverage Diff @@
## master #2251 +/- ##
=========================================
Coverage ? 56.79%
=========================================
Files ? 310
Lines ? 21802
Branches ? 0
=========================================
Hits ? 12383
Misses ? 8503
Partials ? 916 |
@silvin-lubecki updated; PTAL |
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.
Still LGTM 👍
carry of #1965 (original branch was gone)
Refactor code to allow mixing notation with -p
Closes #1962
closes #1965
closes #2041
closes #2151
closes #2227
closes #2371
Signed-off-by: Aleksander Piotrowski apiotrowski312@gmail.com
- What I did
After refactoring and bug fixing. Docker provides better error message with invalid port:
docker run --rm -p 8080:87888888 busybox
and works with mixed notation like:
docker run --rm -p 8080:80 -p published=1500,target=444 busybox
- How I did it
I changed parsePortOpts, before it was iterating over all
-p
args and assuming that all of them are in the same notation. My fix is to iterate over all args and change every with=
to short notation and then parse it.- How to verify it
docker run --rm -p 8080:80 -p published=1500,target=444 busybox
docker run --rm -p 8080:87888888 busybox
- Description for the changelog
Fix a bug with parsing
-p
flag with mixed notation- A picture of a cute animal (not mandatory but encouraged)