in go/metadata/capabilities/capabilities.go [241:288]
func normalizeProxyCapability(in map[string]interface{}, out map[string]interface{}) error {
outProxy := map[string]interface{}{}
if proxy, ok := in["proxy"]; ok {
proxyMap, ok := proxy.(map[string]interface{})
if !ok {
return fmt.Errorf("proxy %v is %T, should be map[string]interface{}", proxy, proxy)
}
for k, v := range proxyMap {
switch k {
case "proxyType":
pt, ok := v.(string)
if !ok {
return fmt.Errorf("proxyType %v is %T, should be string", k, k)
}
outProxy["proxyType"] = strings.ToLower(pt)
continue
case "noProxy":
var outNP []interface{}
switch np := v.(type) {
case []interface{}:
outNP = append(outNP, np...)
case string:
for _, h := range strings.Split(np, ",") {
outNP = append(outNP, h)
}
default:
return fmt.Errorf("noProxy %v is %T, should be string or []interface{}", k, k)
}
if len(outNP) != 0 {
outProxy["noProxy"] = outNP
}
default:
if v != nil {
outProxy[k] = v
}
}
}
}
if len(outProxy) != 0 {
out["proxy"] = outProxy
}
delete(in, "proxy")
return nil
}