@@ -36,7 +36,7 @@ func (t typedName) String() string {
3636}
3737
3838// processJSONPatches applies each JSONPatch to the Xds Resources for a specific type.
39- func processJSONPatches (tCtx * types.ResourceVersionTable , envoyPatchPolicies []* ir.EnvoyPatchPolicy ) error {
39+ func processJSONPatches (tCtx * types.ResourceVersionTable , gResources * ir. GlobalResources , envoyPatchPolicies []* ir.EnvoyPatchPolicy ) error {
4040 var errs error
4141
4242 for _ , e := range envoyPatchPolicies {
@@ -96,7 +96,7 @@ func processJSONPatches(tCtx *types.ResourceVersionTable, envoyPatchPolicies []*
9696 }
9797
9898 // find the resources to patch and convert them to JSON
99- dests , err = findXdsResources (tCtx , p )
99+ dests , err = findXdsResources (tCtx , gResources , p )
100100 if err != nil {
101101 tErrs = errors .Join (tErrs , err )
102102 continue
@@ -217,19 +217,19 @@ var jsonMarshalOpts = protojson.MarshalOptions{
217217// findXdsResources returns XDS resources to patch based on the patch configuration.
218218// If p.Name is empty, all resources of the specified type are returned.
219219// If p.Name is specified, only resources with matching names are returned.
220- func findXdsResources (tCtx * types.ResourceVersionTable , p * ir.JSONPatchConfig ) ([]cachetypes.Resource , error ) {
220+ func findXdsResources (tCtx * types.ResourceVersionTable , gResources * ir. GlobalResources , p * ir.JSONPatchConfig ) ([]cachetypes.Resource , error ) {
221221 var resources []cachetypes.Resource
222222 switch p .Type {
223223 case resourcev3 .ListenerType :
224224 resources = findXdsListeners (tCtx , p .Name )
225225 case resourcev3 .RouteType :
226226 resources = findXdsRouteConfigs (tCtx , p .Name )
227227 case resourcev3 .ClusterType :
228- resources = findXdsClusters (tCtx , p .Name )
228+ resources = findXdsClusters (tCtx , gResources , p .Name )
229229 case resourcev3 .EndpointType :
230230 resources = findXdsEndpoints (tCtx , p .Name )
231231 case resourcev3 .SecretType :
232- resources = findXdsSecrets (tCtx , p .Name )
232+ resources = findXdsSecrets (tCtx , gResources , p .Name )
233233 default :
234234 return nil , fmt .Errorf ("unsupported patch type %s" , p .Type )
235235 }
0 commit comments