37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
constraint.go 1014 Bytes
一键复制 编辑 原始数据 按行查看 历史
phli 提交于 2018-09-19 16:48 . add bitbucket support in pipeline
package utils
import (
"path/filepath"
"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
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.0-rc14

搜索帮助

0d507c66 1850385 C8b1a773 1850385