Skip to content

Commit

Permalink
Allow container name regex filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Drab committed Jan 31, 2022
1 parent 70ca4c2 commit 5999d0b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/filters/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package filters
import (
t "github.com/containrrr/watchtower/pkg/types"
"strings"
"regexp"
)

// WatchtowerContainersFilter filters only watchtower containers
Expand All @@ -19,7 +20,9 @@ func FilterByNames(names []string, baseFilter t.Filter) t.Filter {

return func(c t.FilterableContainer) bool {
for _, name := range names {
if (name == c.Name()) || (name == c.Name()[1:]) {
match, _ := (regexp.MatchString(name, c.Name()))
match1, _ := (regexp.MatchString(name, c.Name()[1:]))
if (name == c.Name()) || (name == c.Name()[1:]) || match || match1 {
return baseFilter(c)
}
}
Expand Down

0 comments on commit 5999d0b

Please sign in to comment.