The default port is used when there is no port number for k8s (#2598)
* k8s 没有端口号时使用默认端口 * Modify the not port test
This commit is contained in:
@@ -32,18 +32,21 @@ func ParseTarget(target resolver.Target) (Service, error) {
|
||||
}
|
||||
|
||||
endpoints := targets.GetEndpoints(target)
|
||||
segs := strings.SplitN(endpoints, colon, 2)
|
||||
if len(segs) < 2 {
|
||||
return emptyService, fmt.Errorf("bad endpoint: %s", endpoints)
|
||||
if strings.Contains(endpoints, colon) {
|
||||
segs := strings.SplitN(endpoints, colon, 2)
|
||||
if len(segs) < 2 {
|
||||
return emptyService, fmt.Errorf("bad endpoint: %s", endpoints)
|
||||
}
|
||||
|
||||
service.Name = segs[0]
|
||||
port, err := strconv.Atoi(segs[1])
|
||||
if err != nil {
|
||||
return emptyService, err
|
||||
}
|
||||
|
||||
service.Port = port
|
||||
} else {
|
||||
service.Name = endpoints
|
||||
}
|
||||
|
||||
service.Name = segs[0]
|
||||
port, err := strconv.Atoi(segs[1])
|
||||
if err != nil {
|
||||
return emptyService, err
|
||||
}
|
||||
|
||||
service.Port = port
|
||||
|
||||
return service, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user