github.com/argoproj/argo-cd/v3@v3.2.1/util/glob/glob.go (about) 1 package glob 2 3 import ( 4 "github.com/gobwas/glob" 5 log "github.com/sirupsen/logrus" 6 ) 7 8 // Match tries to match a text with a given glob pattern. 9 func Match(pattern, text string, separators ...rune) bool { 10 compiledGlob, err := glob.Compile(pattern, separators...) 11 if err != nil { 12 log.Warnf("failed to compile pattern %s due to error %v", pattern, err) 13 return false 14 } 15 return compiledGlob.Match(text) 16 } 17 18 // MatchWithError tries to match a text with a given glob pattern. 19 // returns error if the glob pattern fails to compile. 20 func MatchWithError(pattern, text string, separators ...rune) (bool, error) { 21 compiledGlob, err := glob.Compile(pattern, separators...) 22 if err != nil { 23 return false, err 24 } 25 return compiledGlob.Match(text), nil 26 }