mirror of https://github.com/kubernetes/kops.git
Merge pull request #12780 from justinsb/stable_subnet_mapping
Stable-sort subnets by Name
This commit is contained in:
commit
1736db6358
|
@ -455,7 +455,7 @@ func (e *NetworkLoadBalancer) Run(c *fi.Context) error {
|
|||
|
||||
func (e *NetworkLoadBalancer) Normalize() {
|
||||
// We need to sort our arrays consistently, so we don't get spurious changes
|
||||
sort.Stable(OrderSubnetMappingsByID(e.SubnetMappings))
|
||||
sort.Stable(OrderSubnetMappingsByName(e.SubnetMappings))
|
||||
sort.Stable(OrderListenersByPort(e.Listeners))
|
||||
sort.Stable(OrderTargetGroupsByName(e.TargetGroups))
|
||||
}
|
||||
|
|
|
@ -49,6 +49,17 @@ func (a OrderSubnetMappingsByID) Less(i, j int) bool {
|
|||
return v1 < v2
|
||||
}
|
||||
|
||||
// OrderSubnetMappingsByName implements sort.Interface for []Subnet, based on Name
|
||||
type OrderSubnetMappingsByName []*SubnetMapping
|
||||
|
||||
func (a OrderSubnetMappingsByName) Len() int { return len(a) }
|
||||
func (a OrderSubnetMappingsByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a OrderSubnetMappingsByName) Less(i, j int) bool {
|
||||
v1 := fi.StringValue(a[i].Subnet.Name)
|
||||
v2 := fi.StringValue(a[j].Subnet.Name)
|
||||
return v1 < v2
|
||||
}
|
||||
|
||||
func subnetMappingSlicesEqualIgnoreOrder(l, r []*SubnetMapping) bool {
|
||||
lBySubnet := make(map[string]*SubnetMapping)
|
||||
for _, s := range l {
|
||||
|
|
Loading…
Reference in New Issue