Skip to content

Commit

Permalink
Invalid target (-t) should not panic (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
joanlopez authored Oct 2, 2023
1 parent f89e55f commit 66c7eb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/grizzly/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ func (r *Resource) MatchesTarget(targets []string) bool {
dotKey := r.Key()
slashKey := fmt.Sprintf("%s/%s", r.Kind(), UID)
for _, target := range targets {
g := glob.MustCompile(target)
g, err := glob.Compile(target)
if err != nil {
continue
}

if g.Match(slashKey) || g.Match(dotKey) {
return true
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/grizzly/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ func (r *registry) ResourceMatchesTarget(handler Handler, UID string, targets []
slashKey := fmt.Sprintf("%s/%s", handler.Kind(), UID)
dotKey := fmt.Sprintf("%s.%s", handler.Kind(), UID)
for _, target := range targets {
g := glob.MustCompile(target)
g, err := glob.Compile(target)
if err != nil {
continue
}

if g.Match(slashKey) || g.Match(dotKey) {
return true
}
Expand Down

0 comments on commit 66c7eb0

Please sign in to comment.