@@ -483,10 +483,10 @@ func (t *Translator) addRouteToRouteConfig(
483483 http3Settings * ir.HTTP3Settings ,
484484) error {
485485 var (
486- vHosts = map [string ]* routev3.VirtualHost {} // store virtual hosts by domain
487- virtualHostsToAdd []* routev3.VirtualHost // newly created virtual hosts to be added to the route config
488- errs error // the accumulated errors
489- err error
486+ vHosts = map [string ]* routev3.VirtualHost {} // store virtual hosts by domain
487+ vHostList []* routev3.VirtualHost // keep track of order by using a list as well as the map
488+ errs error // the accumulated errors
489+ err error
490490 )
491491
492492 // Check if an extension is loaded that wants to modify xDS Routes after they have been generated
@@ -523,7 +523,7 @@ func (t *Translator) addRouteToRouteConfig(
523523 }
524524 }
525525 vHosts [httpRoute .Hostname ] = vHost
526- virtualHostsToAdd = append (virtualHostsToAdd , vHost )
526+ vHostList = append (vHostList , vHost )
527527 }
528528
529529 var xdsRoute * routev3.Route
@@ -634,7 +634,7 @@ func (t *Translator) addRouteToRouteConfig(
634634 }
635635 }
636636
637- for _ , vHost := range virtualHostsToAdd {
637+ for _ , vHost := range vHostList {
638638 // Check if an extension want to modify the Virtual Host we just generated
639639 // If no extension exists (or it doesn't subscribe to this hook) then this is a quick no-op.
640640 if err = processExtensionPostVHostHook (vHost , t .ExtensionManager ); err != nil {
@@ -647,7 +647,7 @@ func (t *Translator) addRouteToRouteConfig(
647647 }
648648 }
649649 }
650- xdsRouteCfg .VirtualHosts = append (xdsRouteCfg .VirtualHosts , virtualHostsToAdd ... )
650+ xdsRouteCfg .VirtualHosts = append (xdsRouteCfg .VirtualHosts , vHostList ... )
651651 return errs
652652}
653653
0 commit comments