@@ -10,8 +10,8 @@ type Condition struct {
1010 IfLabeled []string `mapstructure:"if-labeled,omitempty"`
1111 SkipIfLabeled []string `mapstructure:"skip-if-labeled,omitempty"`
1212 Filter struct {
13- Pattern string `mapstructure:"pattern ,omitempty"`
14- Extension string `mapstructure:"extension ,omitempty"`
13+ Patterns [] string `mapstructure:"patterns ,omitempty"`
14+ Extensions [] string `mapstructure:"extensions ,omitempty"`
1515 } `mapstructure:"filter,omitempty"`
1616}
1717
@@ -30,30 +30,42 @@ func (c *Condition) checkIfLabeled(meta EventData) bool {
3030}
3131
3232func (c * Condition ) checkPattern (meta EventData ) bool {
33- if c .Filter .Pattern == "" {
33+ if len ( c .Filter .Patterns ) == 0 {
3434 return true
3535 } else {
36- re , err := regexp .Compile (c .Filter .Pattern )
37- if err != nil {
38- util .Logger .Error ("Unable to compile regex '%s'. %s" , c .Filter .Pattern , err )
36+ compiled := make ([]* regexp.Regexp , 0 )
37+ for _ , pattern := range c .Filter .Patterns {
38+ re , err := regexp .Compile (pattern )
39+ if err != nil {
40+ util .Logger .Warning ("Unable to compile regex '%s'. %s" , pattern , err )
41+ continue
42+ }
43+ compiled = append (compiled , re )
44+ }
45+ if len (compiled ) == 0 {
46+ util .Logger .Error ("All configured patterns have failed to compile" )
3947 return false
4048 }
4149 for _ , check := range meta .GetFileNames () {
42- if re .MatchString (check ) {
43- return true
50+ for _ , reg := range compiled {
51+ if reg .MatchString (check ) {
52+ return true
53+ }
4454 }
4555 }
4656 }
4757 return false
4858}
4959
5060func (c * Condition ) checkExt (meta EventData ) bool {
51- if c .Filter .Extension == "" {
61+ if len ( c .Filter .Extensions ) == 0 {
5262 return true
5363 } else {
5464 for _ , check := range meta .GetFileExtensions () {
55- if c .Filter .Extension == check {
56- return true
65+ for _ , ext := range c .Filter .Extensions {
66+ if ext == check {
67+ return true
68+ }
5769 }
5870 }
5971 }
0 commit comments