mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
minor validation for port
This commit is contained in:
@@ -130,6 +130,10 @@ func ParsePortSpec(port string) (PortSpec, error) {
|
||||
return spec, fmt.Errorf("invalid container port '%s': %w", parts[1], err)
|
||||
}
|
||||
|
||||
if parts[0] == "" {
|
||||
return spec, fmt.Errorf("hostname or published port must be specified, format: " +
|
||||
"hostname:container_port or published_port:container_port")
|
||||
}
|
||||
// Try to parse the first part as port.
|
||||
if publishedPort, err := parsePort(parts[0]); err == nil {
|
||||
spec.PublishedPort = publishedPort
|
||||
@@ -138,9 +142,6 @@ func ParsePortSpec(port string) (PortSpec, error) {
|
||||
if spec.Mode == PortModeHost {
|
||||
return spec, fmt.Errorf("hostname cannot be specified in host mode")
|
||||
}
|
||||
if parts[0] == "" {
|
||||
return spec, fmt.Errorf("hostname must not be empty")
|
||||
}
|
||||
spec.Hostname = parts[0]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user