Merge pull request #57846 from dims/fix-external-address-parsing-under-ipv6

Automatic merge from submit-queue (batch tested with PRs 56315, 57846). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fix ExternalAddress parsing problem under IPv6

**What this PR does / why we need it**:
`!strings.Contains(host, ":") ` will fail miserably under ipv6

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2018-01-04 13:51:32 -08:00 committed by GitHub
commit fa2ea5284e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -342,10 +342,10 @@ func (c *Config) Complete(informers informers.SharedInformerFactory) CompletedCo
if host == "" && c.PublicAddress != nil {
host = c.PublicAddress.String()
}
if !strings.Contains(host, ":") {
if c.ReadWritePort != 0 {
host = net.JoinHostPort(host, strconv.Itoa(c.ReadWritePort))
}
// if there is no port, and we have a ReadWritePort, use that
if _, _, err := net.SplitHostPort(host); err != nil && c.ReadWritePort != 0 {
host = net.JoinHostPort(host, strconv.Itoa(c.ReadWritePort))
}
c.ExternalAddress = host