File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -284,9 +284,9 @@ func (f Filter) roleRefFilter() sieveFunc {
284
284
return previousIdSelectedByGvk (roleRefGvk )
285
285
}
286
286
287
- func prefixSuffixEquals (other resource.ResCtx ) sieveFunc {
287
+ func prefixSuffixEquals (other resource.ResCtx , allowEmpty bool ) sieveFunc {
288
288
return func (r * resource.Resource ) bool {
289
- return r .PrefixesSuffixesEquals (other )
289
+ return r .PrefixesSuffixesEquals (other , allowEmpty )
290
290
}
291
291
}
292
292
@@ -325,7 +325,10 @@ func (f Filter) selectReferral(
325
325
if len (candidates ) == 1 {
326
326
return candidates [0 ], nil
327
327
}
328
- candidates = doSieve (candidates , prefixSuffixEquals (f .Referrer ))
328
+ candidates = doSieve (candidates , prefixSuffixEquals (f .Referrer , true ))
329
+ if len (candidates ) > 1 {
330
+ candidates = doSieve (candidates , prefixSuffixEquals (f .Referrer , false ))
331
+ }
329
332
if len (candidates ) == 1 {
330
333
return candidates [0 ], nil
331
334
}
Original file line number Diff line number Diff line change @@ -290,12 +290,18 @@ func (r *Resource) getCsvAnnotation(name string) []string {
290
290
// PrefixesSuffixesEquals is conceptually doing the same task
291
291
// as OutermostPrefixSuffix but performs a deeper comparison
292
292
// of the suffix and prefix slices.
293
- func (r * Resource ) PrefixesSuffixesEquals (o ResCtx ) bool {
294
- eitherPrefixEmpty := len (r .GetNamePrefixes ()) == 0 || len (o .GetNamePrefixes ()) == 0
295
- eitherSuffixEmpty := len (r .GetNameSuffixes ()) == 0 || len (o .GetNameSuffixes ()) == 0
293
+ func (r * Resource ) PrefixesSuffixesEquals (o ResCtx , allowEmpty bool ) bool {
294
+ if allowEmpty {
295
+ eitherPrefixEmpty := len (r .GetNamePrefixes ()) == 0 || len (o .GetNamePrefixes ()) == 0
296
+ eitherSuffixEmpty := len (r .GetNameSuffixes ()) == 0 || len (o .GetNameSuffixes ()) == 0
296
297
297
- return (eitherPrefixEmpty || utils .SameEndingSubSlice (r .GetNamePrefixes (), o .GetNamePrefixes ())) &&
298
- (eitherSuffixEmpty || utils .SameEndingSubSlice (r .GetNameSuffixes (), o .GetNameSuffixes ()))
298
+ return (eitherPrefixEmpty || utils .SameEndingSubSlice (r .GetNamePrefixes (), o .GetNamePrefixes ())) &&
299
+ (eitherSuffixEmpty || utils .SameEndingSubSlice (r .GetNameSuffixes (), o .GetNameSuffixes ()))
300
+ } else {
301
+ return utils .SameEndingSubSlice (r .GetNamePrefixes (), o .GetNamePrefixes ()) &&
302
+ utils .SameEndingSubSlice (r .GetNameSuffixes (), o .GetNameSuffixes ())
303
+
304
+ }
299
305
}
300
306
301
307
// RemoveBuildAnnotations removes annotations created by the build process.
You can’t perform that action at this time.
0 commit comments