mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
* feat(sourceNamespace): Regex Support Signed-off-by: Arthur <[email protected]> * feat(sourceNamespace): Separate exactMatch into patternMatch Signed-off-by: Arthur <[email protected]> --------- Signed-off-by: Arthur <[email protected]>
21 lines
471 B
Go
21 lines
471 B
Go
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
|
|
}
|