Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't force a host port through kubecfg #1395

Merged
merged 1 commit into from
Sep 22, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 24 additions & 8 deletions pkg/kubecfg/kubecfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,36 @@ func portsFromString(spec string) []api.Port {
var result []api.Port
for _, part := range parts {
pieces := strings.Split(part, ":")
if len(pieces) != 2 {
if len(pieces) < 1 || len(pieces) > 2 {
glog.Infof("Bad port spec: %s", part)
continue
}
host, err := strconv.Atoi(pieces[0])
if err != nil {
glog.Errorf("Host part is not integer: %s %v", pieces[0], err)
continue
host := 0
container := 0
var err error
if len(pieces) == 1 {
container, err = strconv.Atoi(pieces[0])
if err != nil {
glog.Errorf("Container port is not integer: %s %v", pieces[0], 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
}
}
container, err := strconv.Atoi(pieces[1])
if err != nil {
glog.Errorf("Container part is not integer: %s %v", pieces[1], err)
if container < 1 {
glog.Errorf("Container port is not valid: %d", container)
continue
}

result = append(result, api.Port{ContainerPort: container, HostPort: host})
}
return result
Expand Down