37 Star 396 Fork 71

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
constraint.go 1017 Bytes
一键复制 编辑 原始数据 按行查看 历史
Dan Ramich 提交于 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.6-rc2

搜索帮助

344bd9b3 5694891 D2dac590 5694891