37 Star 403 Fork 75

GVPrancher/rancher

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
constraint.go 1017 Bytes
Copy Edit Raw Blame History
Dan Ramich authored 2019-06-12 13:38 . goimport linting changes
package utils
import (
"path/filepath"
v3 "github.com/rancher/types/apis/project.cattle.io/v3"
)
func MatchAll(cs *v3.Constraints, execution *v3.PipelineExecution) bool {
if cs == nil {
return true
}
m := GetEnvVarMap(execution)
return Match(cs.Branch, m[EnvGitBranch]) &&
Match(cs.Event, m[EnvEvent])
}
func Match(c *v3.Constraint, v string) bool {
if c == nil {
return true
}
if Excludes(c, v) {
return false
}
if Includes(c, v) {
return true
}
if len(c.Include) == 0 {
return true
}
return false
}
// Includes returns true if the string matches the include patterns.
func Includes(c *v3.Constraint, v string) bool {
for _, pattern := range c.Include {
if ok, _ := filepath.Match(pattern, v); ok {
return true
}
}
return false
}
// Excludes returns true if the string matches the exclude patterns.
func Excludes(c *v3.Constraint, v string) bool {
for _, pattern := range c.Exclude {
if ok, _ := filepath.Match(pattern, v); ok {
return true
}
}
return false
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.13

Search