mirror of
https://github.com/alibaba/higress.git
synced 2026-06-09 12:47:28 +08:00
fix ConvertBackendService
This commit is contained in:
@@ -334,9 +334,16 @@ func SplitServiceFQDN(fqdn string) (string, string, bool) {
|
|||||||
|
|
||||||
func ConvertBackendService(routeDestination *networking.HTTPRouteDestination) model.BackendService {
|
func ConvertBackendService(routeDestination *networking.HTTPRouteDestination) model.BackendService {
|
||||||
parts := strings.Split(routeDestination.Destination.Host, ".")
|
parts := strings.Split(routeDestination.Destination.Host, ".")
|
||||||
|
var namespace, name string
|
||||||
|
if len(parts) == 2 || len(parts) > 2 && strings.HasSuffix(routeDestination.Destination.Host, "cluster.local") {
|
||||||
|
name = parts[0]
|
||||||
|
namespace = parts[1]
|
||||||
|
} else {
|
||||||
|
name = routeDestination.Destination.Host
|
||||||
|
}
|
||||||
service := model.BackendService{
|
service := model.BackendService{
|
||||||
Namespace: parts[1],
|
Namespace: namespace,
|
||||||
Name: parts[0],
|
Name: name,
|
||||||
Weight: routeDestination.Weight,
|
Weight: routeDestination.Weight,
|
||||||
}
|
}
|
||||||
if routeDestination.Destination.Port != nil {
|
if routeDestination.Destination.Port != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user