mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 03:53:33 +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)
|
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.
|
// Try to parse the first part as port.
|
||||||
if publishedPort, err := parsePort(parts[0]); err == nil {
|
if publishedPort, err := parsePort(parts[0]); err == nil {
|
||||||
spec.PublishedPort = publishedPort
|
spec.PublishedPort = publishedPort
|
||||||
@@ -138,9 +142,6 @@ func ParsePortSpec(port string) (PortSpec, error) {
|
|||||||
if spec.Mode == PortModeHost {
|
if spec.Mode == PortModeHost {
|
||||||
return spec, fmt.Errorf("hostname cannot be specified in host mode")
|
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]
|
spec.Hostname = parts[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user