mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-30 09:51:23 +00:00
Fix Issue 3489.
This commit is contained in:
@@ -294,20 +294,16 @@ func (r *Resource) GetOutermostNameSuffix() string {
|
||||
return nameSuffixes[len(nameSuffixes)-1]
|
||||
}
|
||||
|
||||
func SameEndingSubarray(a, b []string) bool {
|
||||
compareLen := len(b)
|
||||
if len(a) < len(b) {
|
||||
compareLen = len(a)
|
||||
func SameEndingSubarray(shortest, longest []string) bool {
|
||||
if len(shortest) > len(longest) {
|
||||
longest, shortest = shortest, longest
|
||||
}
|
||||
|
||||
if compareLen == 0 {
|
||||
return true
|
||||
diff := len(longest) - len(shortest)
|
||||
if len(shortest) == 0 {
|
||||
return diff == 0
|
||||
}
|
||||
|
||||
alen := len(a) - 1
|
||||
blen := len(b) - 1
|
||||
for i := 0; i <= compareLen-1; i++ {
|
||||
if a[alen-i] != b[blen-i] {
|
||||
for i := len(shortest) - 1; i >= 0; i-- {
|
||||
if longest[i+diff] != shortest[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1196,10 +1196,10 @@ func TestSameEndingSubarray(t *testing.T) {
|
||||
b: []string{},
|
||||
expected: true,
|
||||
},
|
||||
"no1 - TODO(3489) this should be false": {
|
||||
"no1": {
|
||||
a: []string{"a"},
|
||||
b: []string{},
|
||||
expected: true,
|
||||
expected: false,
|
||||
},
|
||||
"no2": {
|
||||
a: []string{"b", "a"},
|
||||
|
||||
Reference in New Issue
Block a user