updated tests for new behavior

This commit is contained in:
yusing
2024-10-11 10:00:10 +08:00
6 changed files with 142 additions and 91 deletions

View File

@@ -85,24 +85,12 @@ func (e *RawEntry) FillMissingFields() {
if p, ok := e.PrivatePortMapping[pp]; ok {
pp = U.PortString(p.PublicPort)
}
if _, ok := e.PublicPortMapping[pp]; !ok { // port is not exposed, but specified
// try to fallback to first public port
if p, ok := F.FirstValueOf(e.PublicPortMapping); ok {
pp = U.PortString(p.PublicPort)
}
}
}
// replace public port with private port if using private IP.
if e.Host == e.PrivateIP {
if p, ok := e.PublicPortMapping[pp]; ok {
pp = U.PortString(p.PrivatePort)
}
if _, ok := e.PrivatePortMapping[pp]; !ok { // port is not exposed, but specified
// try to fallback to first private port
if p, ok := F.FirstValueOf(e.PrivatePortMapping); ok {
pp = U.PortString(p.PrivatePort)
}
}
}
if e.Scheme == "" && isDocker {