From 0974afa05bbf98eacd90c1b834bafad4460f2e48 Mon Sep 17 00:00:00 2001 From: zachaller Date: Thu, 4 May 2023 10:08:47 -0500 Subject: [PATCH] improve logic by adding type casting check Signed-off-by: zachaller --- rollout/trafficrouting/istio/istio.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rollout/trafficrouting/istio/istio.go b/rollout/trafficrouting/istio/istio.go index ac6fdb846d..7c1bc27dbf 100644 --- a/rollout/trafficrouting/istio/istio.go +++ b/rollout/trafficrouting/istio/istio.go @@ -1443,10 +1443,11 @@ func getOrderedVirtualServiceRoutes(httpRouteI []interface{}, managedRoutes []v1 r := route.(map[string]interface{}) // Not checking the cast success here is ok because it covers the case when the route has no name - name, _ := r["name"].(string) + name, rNameOK := r["name"].(string) + routeMapName, RMapNameOK := routeMap["name"].(string) // The second or clause is for the case when we have a route that has no name set because this field // is optional in istio virtual service if there is only one route - if name == routeMap["name"] || (name == "" && routeMap["name"] == nil) { + if name == routeMapName || (!rNameOK && !RMapNameOK) { orderedInterfaceVSVCHTTPRoutes = append(orderedInterfaceVSVCHTTPRoutes, route) } }