-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cache: Sort HTTP Settings and Backend Pool slices (#319)
- Loading branch information
1 parent
6971d51
commit 2055e21
Showing
7 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// ------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
// -------------------------------------------------------------------------------------------- | ||
|
||
package sorter | ||
|
||
import ( | ||
n "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network" | ||
) | ||
|
||
// BySettingsName is a facility to sort slices of ApplicationGatewayBackendHTTPSettings by Name | ||
type BySettingsName []n.ApplicationGatewayBackendHTTPSettings | ||
|
||
func (a BySettingsName) Len() int { return len(a) } | ||
func (a BySettingsName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } | ||
func (a BySettingsName) Less(i, j int) bool { | ||
return getSettingsName(a[i]) < getSettingsName(a[j]) | ||
} | ||
|
||
func getSettingsName(setting n.ApplicationGatewayBackendHTTPSettings) string { | ||
if setting.Name == nil { | ||
return "" | ||
} | ||
return *setting.Name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// ------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
// -------------------------------------------------------------------------------------------- | ||
|
||
package sorter | ||
|
||
import ( | ||
n "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-12-01/network" | ||
) | ||
|
||
// ByBackendPoolName is a facility to sort slices of ApplicationGatewayBackendAddressPool by Name | ||
type ByBackendPoolName []n.ApplicationGatewayBackendAddressPool | ||
|
||
func (a ByBackendPoolName) Len() int { return len(a) } | ||
func (a ByBackendPoolName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } | ||
func (a ByBackendPoolName) Less(i, j int) bool { | ||
return getPoolName(a[i]) < getPoolName(a[j]) | ||
} | ||
|
||
func getPoolName(pool n.ApplicationGatewayBackendAddressPool) string { | ||
if pool.Name == nil { | ||
return "" | ||
} | ||
return *pool.Name | ||
} |