-
Notifications
You must be signed in to change notification settings - Fork 199
/
factory.go
41 lines (32 loc) · 1 KB
/
factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package path_matcher
type PathMatcherOptions struct {
BasePath string
IncludeGlobs []string
ExcludeGlobs []string
DockerignorePatterns []string
Matchers []PathMatcher
}
func NewPathMatcher(options PathMatcherOptions) PathMatcher {
var matchers []PathMatcher
if len(options.IncludeGlobs) != 0 {
matchers = append(matchers, newIncludePathMatcher(options.IncludeGlobs))
}
if len(options.ExcludeGlobs) != 0 {
matchers = append(matchers, newExcludePathMatcher(options.ExcludeGlobs))
}
if options.DockerignorePatterns != nil {
matchers = append(matchers, newDockerfileIgnorePathMatcher(options.DockerignorePatterns))
}
if len(options.Matchers) != 0 {
matchers = append(matchers, options.Matchers...)
}
if len(matchers) == 0 {
matchers = append(matchers, NewTruePathMatcher())
}
var matcher PathMatcher
matcher = NewMultiPathMatcher(matchers...)
if options.BasePath != "" {
matcher = newBasePathMatcher(options.BasePath, matcher)
}
return matcher
}