-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sourceNamespace): Regex Support
Signed-off-by: Arthur <[email protected]>
- Loading branch information
1 parent
de76937
commit fe80772
Showing
5 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package regex | ||
|
||
import ( | ||
"github.com/dlclark/regexp2" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func Match(pattern, text string) bool { | ||
compiledRegex, err := regexp2.Compile(pattern, 0) | ||
if err != nil { | ||
log.Warnf("failed to compile pattern %s due to error %v", pattern, err) | ||
return false | ||
} | ||
regexMatch, err := compiledRegex.MatchString(text) | ||
if err != nil { | ||
log.Warnf("failed to match pattern %s due to error %v", pattern, err) | ||
return false | ||
} | ||
return regexMatch | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters