MCPcopy
hub / github.com/akuity/kargo / ParseNamePattern

Function ParseNamePattern

pkg/pattern/matcher.go:30–41  ·  view source on GitHub ↗

ParseNamePattern parses a pattern string and returns a Matcher. It recognizes glob patterns (with "glob:" prefix), regular expressions (with "regex:" or "regexp:" prefix), and exact string matches (without any prefix).

(pattern string)

Source from the content-addressed store, hash-verified

28// It recognizes glob patterns (with "glob:" prefix), regular expressions (with
29// "regex:" or "regexp:" prefix), and exact string matches (without any prefix).
30func ParseNamePattern(pattern string) (Matcher, error) {
31 switch {
32 case strings.HasPrefix(pattern, globPrefix):
33 return NewGlobPattern(strings.TrimPrefix(pattern, globPrefix))
34 case strings.HasPrefix(pattern, regexPrefix):
35 return NewRegexpMatcher(strings.TrimPrefix(pattern, regexPrefix))
36 case strings.HasPrefix(pattern, regexpPrefix):
37 return NewRegexpMatcher(strings.TrimPrefix(pattern, regexpPrefix))
38 default:
39 return NewExactMatcher(pattern)
40 }
41}
42
43// ParsePathPattern parses a pattern string and returns a Matcher.
44// It recognizes glob patterns (with "glob:" prefix), regular expressions (with

Callers 3

autoPromotionAllowedMethod · 0.92
TestParseNamePatternFunction · 0.85

Calls 3

NewGlobPatternFunction · 0.85
NewRegexpMatcherFunction · 0.85
NewExactMatcherFunction · 0.85

Tested by 1

TestParseNamePatternFunction · 0.68