mirror of https://github.com/hashicorp/consul
Expand testing of simplifyNotSourceSlice for partitions
parent
19da23be28
commit
5e54f253d7
|
@ -296,15 +296,16 @@ func (p *rbacPermission) Flatten() *envoy_rbac_v3.Permission {
|
||||||
return andPermissions(parts)
|
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 {
|
func simplifyNotSourceSlice(notSources []structs.ServiceName) []structs.ServiceName {
|
||||||
if len(notSources) <= 1 {
|
if len(notSources) <= 1 {
|
||||||
return notSources
|
return notSources
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collapse NotSources elements together if any element is a subset of
|
|
||||||
// another.
|
|
||||||
|
|
||||||
// Sort, keeping the least wildcarded elements first.
|
// 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 {
|
sort.SliceStable(notSources, func(i, j int) bool {
|
||||||
return countWild(notSources[i]) < countWild(notSources[j])
|
return countWild(notSources[i]) < countWild(notSources[j])
|
||||||
})
|
})
|
||||||
|
|
|
@ -887,14 +887,3 @@ func makeServiceNameSlice(slice []string) []structs.ServiceName {
|
||||||
}
|
}
|
||||||
return out
|
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…
Reference in New Issue