// Matches returns true if the given object's labels and fields (as
// returned by s.GetAttrs) match s.Label and s.Field. An error is
// returned if s.GetAttrs fails.
184557
func (s *SelectionPredicate) Matches(obj runtime.Object) (bool, error) {
	if s.Empty() {
		return true, nil
	}
	labels, fields, err := s.GetAttrs(obj)
	if err != nil {
		return false, err
	}
	matched := s.Label.Matches(labels)
	if matched && s.Field != nil {
		matched = matched && s.Field.Matches(fields)
	}
	return matched, nil
}
505011
func (s EntitySlice) Matches(ctx labels.LabelArray) bool {
	for _, entity := range s {
		if entity.Matches(ctx) {
			return true
		}
	}

	return false
}
705901
func Matches(file string, patterns []string) (bool, error) {
	pm, err := NewPatternMatcher(patterns)
	if err != nil {
		return false, err
	}
	file = filepath.Clean(file)

	if file == "." {
		// Don't let them exclude everything, kind of silly.
		return false, nil
	}

	return pm.Matches(file)
}
445486
func matches(s string, set stringset.Set) bool {
	return set.Has(s) || set.Len() == 0
}
980277
func (matcher *EqualImageMatcher) Match(actual interface{}) (success bool, err error) {
	if actual == nil && matcher.Expected == nil {
		return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead.  This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
	}

	a, ok := actual.(image.Image)
	if !ok {
		return false, fmt.Errorf("actual must be of type image.Image")
	}

	e, ok := matcher.Expected.(image.Image)
	if !ok {
		return false, fmt.Errorf("expected must be of type image.Image")
	}

	if a.Bounds().Dx() != e.Bounds().Dx() {
		return false, fmt.Errorf("Different width values %d != %d", a.Bounds().Dx(), e.Bounds().Dx())
	}

	if a.Bounds().Dy() != e.Bounds().Dy() {
		return false, fmt.Errorf("Different height values %d != %d", a.Bounds().Dy(), e.Bounds().Dy())
	}

	for x := 0; x < a.Bounds().Dx(); x++ {
		for y := 0; y < a.Bounds().Dy(); y++ {
			if a.At(x, y) != e.At(x, y) {
				return false, fmt.Errorf("pixels don't match at %d %d. %d != %d", x, y, a.At(x, y), e.At(x, y))
			}
		}
	}

	return true, nil
}
1099635
func (o *objectCountEvaluator) Matches(resourceQuota *corev1.ResourceQuota, item runtime.Object) (bool, error) {
	return Matches(resourceQuota, item, o.MatchingResources, MatchesNoScopeFunc)
}
881348
func (n *EndpointSelector) Matches(lblsToMatch k8sLbls.Labels) bool {

	// Try to update cached requirements for this EndpointSelector if possible.
	if n.requirements == nil {
		n.requirements = labelSelectorToRequirements(n.LabelSelector)
		// Nil indicates that requirements failed validation in some way,
		// so we cannot parse the labels for matching purposes; thus, we cannot
		// match if labels cannot be parsed, so return false.
		if n.requirements == nil {
			return false
		}
	}

	for k := range n.MatchLabels {
		if k == labels.LabelSourceReservedKeyPrefix+labels.IDNameAll {
			return true
		}
	}

	for _, req := range *n.requirements {
		if !req.Matches(lblsToMatch) {
			return false
		}
	}
	return true
}
1141739
func (f *PropertyFilter) matches(ctx *Context, ref types.ManagedObjectReference, change *types.PropertyChange) bool {
	var kind reflect.Type

	for _, p := range f.Spec.PropSet {
		if p.Type != ref.Type {
			if kind == nil {
				kind = getManagedObject(ctx.Map.Get(ref)).Type()
			}
			// e.g. ManagedEntity, ComputeResource
			field, ok := kind.FieldByName(p.Type)
			if !(ok && field.Anonymous) {
				continue
			}
		}

		if isTrue(p.All) {
			return true
		}

		for _, name := range p.PathSet {
			if name == change.Name {
				return true
			}

			// strings.HasPrefix("runtime.powerState", "runtime") == parent field matches
			if strings.HasPrefix(change.Name, name) {
				if obj := ctx.Map.Get(ref); obj != nil { // object may have since been deleted
					change.Name = name
					change.Val, _ = fieldValue(reflect.ValueOf(obj), name)
				}

				return true
			}
		}
	}

	return false
}
548675
func Matches(buf []byte) bool {
	kind, _ := Match(buf)
	return kind != types.Unknown
}
643712
func Match(payload FullPayloadInfo, pattern string) bool {
	pattern = strings.ToLower(pattern)

	switch {
	case strings.ToLower(payload.Name) == pattern:
		return true
	case strings.ToLower(payload.Type) == pattern:
		return true
	case strings.ToLower(payload.ID) == pattern:
		return true
	case strings.ToLower(payload.Status) == pattern:
		return true
	case strings.ToLower(payload.Unit) == pattern:
		return true
	case strings.ToLower(payload.Machine) == pattern:
		return true
	default:
		for _, tag := range payload.Labels {
			if strings.ToLower(tag) == pattern {
				return true
			}
		}
	}
	return false
}
828457
func (node *Node) Match(keys []string) bool {
	sort.Strings(keys)
	return node.match(keys)
}
454146
func (v *Validator) Match(field string, regex *regexp.Regexp) *ValidationResult {
	if !regex.MatchString(v.data.Get(field)) {
		return v.addMatchError(field)
	} else {
		return validationOk
	}
}
1154398
func (fn typeFunc) Matches(types []reflect.Type) bool {
	if len(fn.Extra) != len(types) {
		return false
	}
	// reorder the items in array types and fn.Extra
	// convert the type into string and sort them, check if they are matched
	varMap := make(map[reflect.Type]bool)
	for i := range fn.Extra {
		varMap[fn.Extra[i]] = true
	}
	for i := range types {
		if _, found := varMap[types[i]]; !found {
			return false
		}
	}
	return true
}
1105834
func (fn typeFunc) Matches(types []reflect.Type) bool {
	if len(fn.Extra) != len(types) {
		return false
	}
	for i := range types {
		if fn.Extra[i] != types[i] {
			return false
		}
	}
	return true
}
1194154
func Match(ctx context.Context, expectedVersion string) bool {
	return If(GetVersion(ctx), expectedVersion)
}
761411
func (self *Constraint) Match(version string) bool {
	return Compare(version, self.version, self.operator)
}
890290
func whereLabelValueMatches(containers Context, label, pattern string) (Context, error) {
	rx, err := regexp.Compile(pattern)
	if err != nil {
		return nil, err
	}

	return generalizedWhereLabel("whereLabelValueMatches", containers, label, func(value string, ok bool) bool {
		return ok && rx.MatchString(value)
	})
}