diff --git a/gwctl/pkg/resourcediscovery/node_list.go b/gwctl/pkg/resourcediscovery/node_list.go index 9a343fea6d..1642f139ea 100644 --- a/gwctl/pkg/resourcediscovery/node_list.go +++ b/gwctl/pkg/resourcediscovery/node_list.go @@ -35,10 +35,7 @@ func (g GatewayClassNodeList) Len() int { } func (g GatewayClassNodeList) Less(i, j int) bool { - if g[i].GatewayClass.GetName() != g[j].GatewayClass.GetName() { - return g[i].GatewayClass.GetName() < g[j].GatewayClass.GetName() - } - return string(g[i].GatewayClass.Spec.ControllerName) < string(g[j].GatewayClass.Spec.ControllerName) + return g[i].GatewayClass.GetName() < g[j].GatewayClass.GetName() // names can't collide as GatewayClass is a cluster-scoped resource } func (g GatewayClassNodeList) Swap(i, j int) { @@ -83,10 +80,9 @@ func (g GatewayNodeList) Len() int { } func (g GatewayNodeList) Less(i, j int) bool { - if g[i].Gateway.GetName() != g[j].Gateway.GetName() { - return g[i].Gateway.GetName() < g[j].Gateway.GetName() - } - return g[i].Gateway.Spec.GatewayClassName < g[j].Gateway.Spec.GatewayClassName + a := fmt.Sprintf("%v/%v", g[i].Gateway.GetName(), g[i].Gateway.Spec.GatewayClassName) + b := fmt.Sprintf("%v/%v", g[j].Gateway.GetName(), g[j].Gateway.Spec.GatewayClassName) + return a < b } func (g GatewayNodeList) Swap(i, j int) { @@ -108,10 +104,9 @@ func (h HTTPRouteNodeList) Len() int { } func (h HTTPRouteNodeList) Less(i, j int) bool { - if h[i].HTTPRoute.GetNamespace() != h[j].HTTPRoute.GetNamespace() { - return h[i].HTTPRoute.GetNamespace() < h[j].HTTPRoute.GetNamespace() - } - return h[i].HTTPRoute.GetName() < h[j].HTTPRoute.GetName() + a := fmt.Sprintf("%v/%v", h[i].HTTPRoute.GetNamespace(), h[i].HTTPRoute.GetName()) + b := fmt.Sprintf("%v/%v", h[j].HTTPRoute.GetNamespace(), h[j].HTTPRoute.GetName()) + return a < b } func (h HTTPRouteNodeList) Swap(i, j int) {