@@ -483,10 +483,10 @@ func (t *Translator) addRouteToRouteConfig(
483
483
http3Settings * ir.HTTP3Settings ,
484
484
) error {
485
485
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
490
490
)
491
491
492
492
// 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(
523
523
}
524
524
}
525
525
vHosts [httpRoute .Hostname ] = vHost
526
- virtualHostsToAdd = append (virtualHostsToAdd , vHost )
526
+ vHostList = append (vHostList , vHost )
527
527
}
528
528
529
529
var xdsRoute * routev3.Route
@@ -634,7 +634,7 @@ func (t *Translator) addRouteToRouteConfig(
634
634
}
635
635
}
636
636
637
- for _ , vHost := range virtualHostsToAdd {
637
+ for _ , vHost := range vHostList {
638
638
// Check if an extension want to modify the Virtual Host we just generated
639
639
// If no extension exists (or it doesn't subscribe to this hook) then this is a quick no-op.
640
640
if err = processExtensionPostVHostHook (vHost , t .ExtensionManager ); err != nil {
@@ -647,7 +647,7 @@ func (t *Translator) addRouteToRouteConfig(
647
647
}
648
648
}
649
649
}
650
- xdsRouteCfg .VirtualHosts = append (xdsRouteCfg .VirtualHosts , virtualHostsToAdd ... )
650
+ xdsRouteCfg .VirtualHosts = append (xdsRouteCfg .VirtualHosts , vHostList ... )
651
651
return errs
652
652
}
653
653
0 commit comments