Merge pull request #52013 from FengyunPan/autoprobing-external-network

Automatic merge from submit-queue (batch tested with PRs 52013, 56719). 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>.

Support autoprobing floating-network-id for openstack cloud provider

Currently if user doesn't specify floatingnetwork-id and loadbalancer.openstack.org/floating-network-id annotation, openstack cloud provider can't create a external LoadBalancer service.
Actually we can get  floatingnetwork-id automatically.
If we get multiple  floatingnetwork-ids, then ask user to specify one, or we use the  floatingnetwork-id to create floatingip for external LoadBalancer service.

This is a part of #50726

**Special notes for your reviewer**:
/assign @dims

**Release note**:
```release-note
Support autoprobing floating-network-id for openstack cloud provider
```

Kubernetes-commit: 36ea6de4a0fd79b97768b9b58c634140f64fc73d
This commit is contained in:
Kubernetes Publisher 2017-12-04 10:55:14 -08:00
commit 59ab1a8387
2 changed files with 718 additions and 709 deletions

1416
Godeps/Godeps.json generated

File diff suppressed because it is too large Load Diff

View File

@ -347,12 +347,21 @@ func BuildQueryString(opts interface{}) (*url.URL, error) {
params.Add(tags[0], v.Index(i).String()) params.Add(tags[0], v.Index(i).String())
} }
} }
case reflect.Map:
if v.Type().Key().Kind() == reflect.String && v.Type().Elem().Kind() == reflect.String {
var s []string
for _, k := range v.MapKeys() {
value := v.MapIndex(k).String()
s = append(s, fmt.Sprintf("'%s':'%s'", k.String(), value))
}
params.Add(tags[0], fmt.Sprintf("{%s}", strings.Join(s, ", ")))
}
} }
} else { } else {
// Otherwise, the field is not set. // Otherwise, the field is not set.
if len(tags) == 2 && tags[1] == "required" { if len(tags) == 2 && tags[1] == "required" {
// And the field is required. Return an error. // And the field is required. Return an error.
return nil, fmt.Errorf("Required query parameter [%s] not set.", f.Name) return &url.URL{}, fmt.Errorf("Required query parameter [%s] not set.", f.Name)
} }
} }
} }