Skip to content

Commit

Permalink
chore: nits related to sorting
Browse files Browse the repository at this point in the history
Signed-off-by: Yashvardhan Kukreja <yash.kukreja.98@gmail.com>
  • Loading branch information
yashvardhan-kukreja committed Apr 11, 2024
1 parent 00fb01e commit c84847e
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions gwctl/pkg/resourcediscovery/node_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit c84847e

Please sign in to comment.