Skip to content

Commit

Permalink
fix: remove route name appID (#2071)
Browse files Browse the repository at this point in the history
Signed-off-by: 张启航 <[email protected]>
  • Loading branch information
ZhangSetSail authored Nov 21, 2024
1 parent 24668b1 commit bc085c4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/controller/apigateway/api_gateway_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ func (g Struct) GetHTTPAPIRoute(w http.ResponseWriter, r *http.Request) {
httpRoute := v.Spec.HTTP[0].DeepCopy()
labels := v.Labels
service_alias := ""
regionAppID := ""
for labelK, labelV := range labels {
if labelV == "service_alias" {
service_alias = service_alias + "-" + labelK
}
if labelK == "app_id" {
regionAppID = labelV
}
}
httpRoute.Name = v.Name + "|" + service_alias
httpRoute.Name = regionAppID + "|" + v.Name + "|" + service_alias
resp = append(resp, httpRoute)
}
httputil.ReturnSuccess(r, w, resp)
Expand Down Expand Up @@ -198,7 +202,7 @@ func (g Struct) CreateHTTPAPIRoute(w http.ResponseWriter, r *http.Request) {

c := k8s.Default().ApiSixClient.ApisixV2()

routeName := r.URL.Query().Get("intID") + apisixRouteHTTP.Match.Hosts[0] + apisixRouteHTTP.Match.Paths[0]
routeName := apisixRouteHTTP.Match.Hosts[0] + apisixRouteHTTP.Match.Paths[0]

routeName = strings.ReplaceAll(routeName, "/", "p-p")
routeName = strings.ReplaceAll(routeName, "*", "s-s")
Expand Down Expand Up @@ -442,6 +446,7 @@ func (g Struct) CreateTCPRoute(w http.ResponseWriter, r *http.Request) {
labels["service_id"] = r.URL.Query().Get("service_id")
labels["service_alias"] = serviceName
labels["outer"] = "true"
labels["port"] = apisixRouteStream.Backend.ServicePort.String()
service = &corev1.Service{
ObjectMeta: v1.ObjectMeta{
Labels: labels,
Expand Down

0 comments on commit bc085c4

Please sign in to comment.