Skip to content

Commit

Permalink
improve logic by adding type casting check
Browse files Browse the repository at this point in the history
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
  • Loading branch information
zachaller committed May 4, 2023
1 parent a2d1b0d commit 0974afa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rollout/trafficrouting/istio/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 0974afa

Please sign in to comment.