func()

in pkg/gcptarget/matcher.go [31:60]


func (m *matcher) Match(review interface{}) (bool, error) {
	reviewObj, ok := review.(map[string]interface{})
	if !ok {
		return false, ErrInvalidReview
	}
	ancestryPath, ok := reviewObj["ancestry_path"].(string)
	if !ok {
		return false, ErrInvalidAncestryPath
	}

	matchAncestries := false
	for _, pattern := range m.ancestries {
		g := glob.MustCompile(pattern, '/')
		if g.Match(ancestryPath) {
			matchAncestries = true
			break
		}
	}
	if !matchAncestries {
		return false, nil
	}

	for _, pattern := range m.excludedAncestries {
		g := glob.MustCompile(pattern, '/')
		if g.Match(ancestryPath) {
			return false, nil
		}
	}
	return true, nil
}