mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Merge pull request #1395 from thockin/kubecfg
Don't force a host port through kubecfg
This commit is contained in:
commit
c6e4ce321d
@ -154,20 +154,36 @@ func portsFromString(spec string) []api.Port {
|
|||||||
var result []api.Port
|
var result []api.Port
|
||||||
for _, part := range parts {
|
for _, part := range parts {
|
||||||
pieces := strings.Split(part, ":")
|
pieces := strings.Split(part, ":")
|
||||||
if len(pieces) != 2 {
|
if len(pieces) < 1 || len(pieces) > 2 {
|
||||||
glog.Infof("Bad port spec: %s", part)
|
glog.Infof("Bad port spec: %s", part)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
host, err := strconv.Atoi(pieces[0])
|
host := 0
|
||||||
if err != nil {
|
container := 0
|
||||||
glog.Errorf("Host part is not integer: %s %v", pieces[0], err)
|
var err error
|
||||||
continue
|
if len(pieces) == 1 {
|
||||||
}
|
container, err = strconv.Atoi(pieces[0])
|
||||||
container, err := strconv.Atoi(pieces[1])
|
if err != nil {
|
||||||
if err != nil {
|
glog.Errorf("Container port is not integer: %s %v", pieces[0], err)
|
||||||
glog.Errorf("Container part is not integer: %s %v", pieces[1], err)
|
continue
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
host, err = strconv.Atoi(pieces[0])
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Host port is not integer: %s %v", pieces[0], err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
container, err = strconv.Atoi(pieces[1])
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Container port is not integer: %s %v", pieces[1], err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if container < 1 {
|
||||||
|
glog.Errorf("Container port is not valid: %d", container)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
result = append(result, api.Port{ContainerPort: container, HostPort: host})
|
result = append(result, api.Port{ContainerPort: container, HostPort: host})
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user