mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 13:55:55 +00:00
Expand testing of simplifyNotSourceSlice for partitions
This commit is contained in:
parent
19da23be28
commit
5e54f253d7
@ -296,15 +296,16 @@ func (p *rbacPermission) Flatten() *envoy_rbac_v3.Permission {
|
||||
return andPermissions(parts)
|
||||
}
|
||||
|
||||
// simplifyNotSourceSlice will collapse NotSources elements together if any element is
|
||||
// a subset of another.
|
||||
// For example "default/web" is a subset of "default/*" because it is covered by the wildcard.
|
||||
func simplifyNotSourceSlice(notSources []structs.ServiceName) []structs.ServiceName {
|
||||
if len(notSources) <= 1 {
|
||||
return notSources
|
||||
}
|
||||
|
||||
// Collapse NotSources elements together if any element is a subset of
|
||||
// another.
|
||||
|
||||
// Sort, keeping the least wildcarded elements first.
|
||||
// More specific elements have a higher precedence over more wildcarded elements.
|
||||
sort.SliceStable(notSources, func(i, j int) bool {
|
||||
return countWild(notSources[i]) < countWild(notSources[j])
|
||||
})
|
||||
|
@ -887,14 +887,3 @@ func makeServiceNameSlice(slice []string) []structs.ServiceName {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func unmakeServiceNameSlice(slice []structs.ServiceName) []string {
|
||||
if len(slice) == 0 {
|
||||
return nil
|
||||
}
|
||||
var out []string
|
||||
for _, src := range slice {
|
||||
out = append(out, src.String())
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user