Skip to content

Commit

Permalink
fix resource order
Browse files Browse the repository at this point in the history
Signed-off-by: huabing zhao <[email protected]>
  • Loading branch information
zhaohuabing committed Oct 17, 2023
1 parent 64509a0 commit f5a2c73
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions pkg/cache/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ type ResponseType int
// ADS expects things to be returned in a specific order.
// See the following issue for details: https://github.com/envoyproxy/go-control-plane/issues/526
const (
Endpoint ResponseType = iota
Cluster
ScopedRoute
Cluster ResponseType = iota
Endpoint
Listener
Route
ScopedRoute
VirtualHost
Listener
Secret
Runtime
ExtensionConfig
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/v3/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (k keys) Len() int {

// Less compares the typeURL and determines what order things should be sent.
func (k keys) Less(i, j int) bool {
return GetResponseType(k[i].TypeURL) > GetResponseType(k[j].TypeURL)
return GetResponseType(k[i].TypeURL) < GetResponseType(k[j].TypeURL)
}

func (k keys) Swap(i, j int) {
Expand Down
16 changes: 8 additions & 8 deletions pkg/cache/v3/order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ func TestOrderKeys(t *testing.T) {
},
}
expected := keys{
{
ID: 2,
TypeURL: resource.ClusterType,
},
{
ID: 1,
TypeURL: resource.EndpointType,
},
{
ID: 4,
TypeURL: resource.ListenerType,
Expand All @@ -45,14 +53,6 @@ func TestOrderKeys(t *testing.T) {
ID: 5,
TypeURL: resource.ScopedRouteType,
},
{
ID: 2,
TypeURL: resource.ClusterType,
},
{
ID: 1,
TypeURL: resource.EndpointType,
},
}

orderedKeys := unorderedKeys
Expand Down

0 comments on commit f5a2c73

Please sign in to comment.