Skip to content

Commit aa0a620

Browse files
committed
Add checks around empty includenamespaces
Signed-off-by: Joseph <jvaikath@redhat.com>
1 parent 3c4bfee commit aa0a620

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

pkg/util/wildcard/expand.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import (
99
)
1010

1111
func ShouldExpandWildcards(includes []string, excludes []string) bool {
12+
// Empty includes is equivalent to * (match all) - don't expand
13+
if len(includes) == 0 {
14+
return false
15+
}
16+
1217
wildcardFound := false
1318
for _, include := range includes {
1419
// Special case: "*" alone means "match all" - don't expand

pkg/util/wildcard/expand_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ func TestShouldExpandWildcards(t *testing.T) {
6868
excludes: []string{},
6969
expected: false,
7070
},
71+
{
72+
name: "empty includes with wildcard excludes - should not expand",
73+
includes: []string{},
74+
excludes: []string{"ns*"},
75+
expected: false,
76+
},
7177
{
7278
name: "complex wildcard patterns",
7379
includes: []string{"*-prod"},
@@ -104,6 +110,7 @@ func TestShouldExpandWildcards(t *testing.T) {
104110
excludes: []string{},
105111
expected: false, // plus is literal, not wildcard
106112
},
113+
107114
}
108115

109116
for _, tt := range tests {

0 commit comments

Comments
 (0)