Skip to content
This repository has been archived by the owner on Nov 6, 2018. It is now read-only.

Problem with publishing port #50

Open
Khazrak opened this issue May 24, 2016 · 7 comments
Open

Problem with publishing port #50

Khazrak opened this issue May 24, 2016 · 7 comments

Comments

@Khazrak
Copy link
Contributor

Khazrak commented May 24, 2016

After successfully exposing a port (thanks to the fix for #48 ) I'm now trying to publish that port.
The CreateRequest looks like this (which is wrong):
PortBindings={1337=[PortBinding(HostIp=0.0.0.0, HostPort=1337, additionalProperties={})]}

I attached the simple code example that generated this request:

Simple.txt

@iocanel
Copy link
Member

iocanel commented May 24, 2016

@Khazrak: The only issue that I see (with naked eye) is the key of the map which should be "1337/tcp" instead. However, this is something created by the sample code and not by the client.

Do I miss something?

@Khazrak
Copy link
Contributor Author

Khazrak commented May 25, 2016

What it should look like:
"PortBindings": {"container_port/tcp": [{"HostIp": "host_ip", "HostPort": "host_port"}]}
ex
"PortBindings": {"1337/tcp": [{"HostIp": "0.0.0.0", "HostPort": "1337"}]}

what it looks like now
PortBindings={1337=[PortBinding(HostIp=0.0.0.0, HostPort=1337, additionalProperties={})]}

All the ports should be in String's here

@iocanel
Copy link
Member

iocanel commented May 25, 2016

@Khazrak: They are Strings :-)

The JSON object looks like this:

"PortBindings":{"1337/tcp":[{"HostIp":"0.0.0.0","HostPort":"1337"}]}

How did u generate the output? Let me create a quick unit test for that.

@iocanel
Copy link
Member

iocanel commented May 25, 2016

unit test added.

@Khazrak
Copy link
Contributor Author

Khazrak commented May 25, 2016

Ok, now got it to work. Needed to add the "/tcp" manually to the key-part of the Map. Would be nice with a builder for it (the PortBinding has a builder, but not for the Map<String,ArrayList<PortBindning>>)

@iocanel
Copy link
Member

iocanel commented May 25, 2016

Even if we had a builder for the map itself (which is on my radar), that would still wouldn't solve the problem, as we would need to have a custom logic:

if map key does not match <port/protocol> use tcp as a default protocol

This is something I wouldn't want to have inside the builder.

I am wondering though if the client could use some sort of filters to apply modifications on the outgoing JSON before we send it. A filter would be a place were we could host some logic like this.

@iocanel
Copy link
Member

iocanel commented Jun 1, 2016

I think that the cleanest way to prevent this is by using validation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants