Fix name in a configMapRef missing hash #5047 (#5236)

* Add regression tests

* Update PrefixesSuffixesEquals function

* Try empty prefix/suffix but fall back on duplicates

* Run gofmt

* Remove newline

* Revert unnecessary gofmt change

* Add comment
This commit is contained in:
Jonathan King
2024-04-02 20:44:11 +01:00
committed by GitHub
parent ed2ca23400
commit b3d1df2644
3 changed files with 206 additions and 9 deletions

View File

@@ -284,9 +284,9 @@ func (f Filter) roleRefFilter() sieveFunc {
return previousIdSelectedByGvk(roleRefGvk)
}
func prefixSuffixEquals(other resource.ResCtx) sieveFunc {
func prefixSuffixEquals(other resource.ResCtx, allowEmpty bool) sieveFunc {
return func(r *resource.Resource) bool {
return r.PrefixesSuffixesEquals(other)
return r.PrefixesSuffixesEquals(other, allowEmpty)
}
}
@@ -325,7 +325,10 @@ func (f Filter) selectReferral(
if len(candidates) == 1 {
return candidates[0], nil
}
candidates = doSieve(candidates, prefixSuffixEquals(f.Referrer))
candidates = doSieve(candidates, prefixSuffixEquals(f.Referrer, true))
if len(candidates) > 1 {
candidates = doSieve(candidates, prefixSuffixEquals(f.Referrer, false))
}
if len(candidates) == 1 {
return candidates[0], nil
}