소스 검색

fix(go): use existing extclient sort function;

VishalDalwadi 1 일 전
부모
커밋
10a67f3b21
1개의 변경된 파일7개의 추가작업 그리고 14개의 파일을 삭제
  1. 7 14
      pro/controllers/users.go

+ 7 - 14
pro/controllers/users.go

@@ -10,12 +10,6 @@ import (
 	"strings"
 	"time"
 
-	"github.com/gravitl/netmaker/pro/idp"
-	"github.com/gravitl/netmaker/pro/idp/azure"
-	"github.com/gravitl/netmaker/pro/idp/google"
-	"github.com/gravitl/netmaker/pro/idp/okta"
-	"golang.org/x/exp/slices"
-
 	"github.com/google/uuid"
 	"github.com/gorilla/mux"
 	"github.com/gravitl/netmaker/database"
@@ -25,6 +19,10 @@ import (
 	"github.com/gravitl/netmaker/mq"
 	proAuth "github.com/gravitl/netmaker/pro/auth"
 	"github.com/gravitl/netmaker/pro/email"
+	"github.com/gravitl/netmaker/pro/idp"
+	"github.com/gravitl/netmaker/pro/idp/azure"
+	"github.com/gravitl/netmaker/pro/idp/google"
+	"github.com/gravitl/netmaker/pro/idp/okta"
 	proLogic "github.com/gravitl/netmaker/pro/logic"
 	"github.com/gravitl/netmaker/servercfg"
 	"github.com/gravitl/netmaker/utils"
@@ -1501,17 +1499,12 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
 			userExtClients[extClient.IngressGatewayID] = []models.ExtClient{}
 		}
 
-		index, ok := slices.BinarySearchFunc(userExtClients[extClient.IngressGatewayID], extClient, func(a models.ExtClient, b models.ExtClient) int {
-			return strings.Compare(a.ClientID, b.ClientID)
-		})
-		if ok {
-			continue
-		}
-
-		userExtClients[extClient.IngressGatewayID] = slices.Insert(userExtClients[extClient.IngressGatewayID], index, extClient)
+		userExtClients[extClient.IngressGatewayID] = append(userExtClients[extClient.IngressGatewayID], extClient)
 	}
 
 	for ingressGatewayID, extClients := range userExtClients {
+		logic.SortExtClient(extClients)
+
 		node, ok := userGwNodes[ingressGatewayID]
 		if !ok {
 			continue