// Filter CAA records by property
969227
func newCAASet(CAAs []*dns.CAA) *CAASet {
	var filtered CAASet

	for _, caaRecord := range CAAs {
		switch strings.ToLower(caaRecord.Tag) {
		case "issue":
			filtered.Issue = append(filtered.Issue, caaRecord)
		case "issuewild":
			filtered.Issuewild = append(filtered.Issuewild, caaRecord)
		case "iodef":
			filtered.Iodef = append(filtered.Iodef, caaRecord)
		default:
			filtered.Unknown = append(filtered.Unknown, caaRecord)
		}
	}

	return &filtered
}
837339
func (api *ZoneAPI) FilterBy(key string, value interface{}) *ZoneAPI {
	api.filterBy(key, value, false)
	return api
}
76179
func (p *fooBarQueryProperty) Filter(op string, value interface{}) *fooBarQueryBuilder {
	switch op {
	case "<=":
		p.LessThanOrEqual(value)
	case ">=":
		p.GreaterThanOrEqual(value)
	case "<":
		p.LessThan(value)
	case ">":
		p.GreaterThan(value)
	case "=":
		p.Equal(value)
	default:
		p.bldr.q = p.bldr.q.Filter(p.name+" "+op, value) // error raised by native query
	}
	if p.bldr.plugin != nil {
		p.bldr.plugin.Filter(p.name, op, value)
	}
	return p.bldr
}
923867
func (api *SimpleMonitorAPI) FilterBy(key string, value interface{}) *SimpleMonitorAPI {
	api.filterBy(key, value, false)
	return api
}
46628
func (f *aclFilter) filterCoordinates(coords *structs.Coordinates) {
	c := *coords
	for i := 0; i < len(c); i++ {
		node := c[i].Node
		if f.allowNode(node) {
			continue
		}
		f.logger.Printf("[DEBUG] consul: dropping node %q from result due to ACLs", node)
		c = append(c[:i], c[i+1:]...)
		i--
	}
	*coords = c
}
589534
func (c ActionCollection) FilterToCardMembershipChangeActions() ActionCollection {
	newSlice := make(ActionCollection, 0, len(c))
	for _, action := range c {
		if action.DidChangeCardMembership() || action.DidArchiveCard() || action.DidUnarchiveCard() {
			newSlice = append(newSlice, action)
		}
	}
	return newSlice
}
1324915
func (f *aclFilter) filterPreparedQueries(queries *structs.PreparedQueries) {
	// Management tokens can see everything with no filtering.
	if f.authorizer.ACLWrite() {
		return
	}

	// Otherwise, we need to see what the token has access to.
	ret := make(structs.PreparedQueries, 0, len(*queries))
	for _, query := range *queries {
		// If no prefix ACL applies to this query then filter it, since
		// we know at this point the user doesn't have a management
		// token, otherwise see what the policy says.
		prefix, ok := query.GetACLPrefix()
		if !ok || !f.authorizer.PreparedQueryRead(prefix) {
			f.logger.Printf("[DEBUG] consul: dropping prepared query %q from result due to ACLs", query.ID)
			continue
		}

		// Redact any tokens if necessary. We make a copy of just the
		// pointer so we don't mess with the caller's slice.
		final := query
		f.redactPreparedQueryTokens(&final)
		ret = append(ret, final)
	}
	*queries = ret
}
1296008
func (sm *ServiceMap) filter(other ServiceMap) {
	for svcPortName := range *sm {
		// skip the delete for Update event.
		if _, ok := other[svcPortName]; ok {
			delete(*sm, svcPortName)
		}
	}
}
810220
func (p *propertySet) filterAllocs(allocs []*structs.Allocation, filterTerminal bool) []*structs.Allocation {
	n := len(allocs)
	for i := 0; i < n; i++ {
		remove := false
		if filterTerminal {
			remove = allocs[i].TerminalStatus()
		}

		// If the constraint is on the task group filter the allocations to just
		// those on the task group
		if p.taskGroup != "" {
			remove = remove || allocs[i].TaskGroup != p.taskGroup
		}

		if remove {
			allocs[i], allocs[n-1] = allocs[n-1], nil
			i--
			n--
		}
	}
	return allocs[:n]
}
232098
func (api *IconAPI) FilterBy(key string, value interface{}) *IconAPI {
	api.filterBy(key, value, false)
	return api
}
546595
func FilterByRelease(version string) (CertificateFilter, error) {
	verFilter, err := regexp.Compile(version)
	if err != nil {
		return nil, err
	}

	return func(cm *CertificateMetadata) bool {
		for _, rel := range cm.Releases {
			if verFilter.MatchString(rel.Version) {
				return true
			}
		}
		return false
	}, nil
}
547481
func (c *Console) FilterBuilders(perms access.Permissions) {
	okBuilderIDs := make([]string, 0, len(c.Builders))
	for _, id := range c.Builders {
		if bucket := extractBucket(id); bucket != "" && !perms.Can(bucket, access.AccessBucket) {
			continue
		}
		okBuilderIDs = append(okBuilderIDs, id)
	}
	c.Builders = okBuilderIDs
	okBuilders := make([]*config.Builder, 0, len(c.Def.Builders))
	// A single builder entry could have multiple builder names.
	for _, b := range c.Def.Builders {
		okNames := make([]string, 0, len(b.Name))
		for _, name := range b.Name {
			if bucket := extractBucket(name); bucket != "" && !perms.Can(bucket, access.AccessBucket) {
				continue
			}
			okNames = append(okNames, name)
		}
		b.Name = okNames
		if len(b.Name) > 0 {
			okBuilders = append(okBuilders, b)
		}
	}
	c.Def.Builders = okBuilders
}
392959
func FilterBySubject(subj string) (CertificateFilter, error) {
	subjFilter, err := regexp.Compile(subj)
	if err != nil {
		return nil, err
	}

	return func(cm *CertificateMetadata) bool {
		return subjFilter.MatchString(cm.Subject)
	}, nil
}
501254
func filterStatusData(status map[string]interface{}) map[string]interface{} {
	out := make(map[string]interface{})
	for name, value := range status {
		// use a set here if we end up with a larger whitelist
		if name == "relation-id" {
			out[name] = value
		}
	}
	return out
}
268866
func Filter(chains [][]*x509.Certificate, f RankingFunc) [][]*x509.Certificate {
	// If there are no chain or only 1 chain, we are done.
	if len(chains) <= 1 {
		return chains
	}

	bestChain := chains[0]
	var candidateChains [][]*x509.Certificate
	for _, chain := range chains {
		r := f(bestChain, chain)
		if r < 0 {
			bestChain = chain
			candidateChains = [][]*x509.Certificate{chain}
		} else if r == 0 {
			candidateChains = append(candidateChains, chain)
		}
	}
	return candidateChains
}
752245
func Filter(addrs []ma.Multiaddr) []ma.Multiaddr {
	raddrs := make([]ma.Multiaddr, 0, len(addrs))
	for _, addr := range addrs {
		if isRelayAddr(addr) {
			continue
		}
		raddrs = append(raddrs, addr)
	}
	return raddrs
}
55441
func (a *AliasAddAction) Filter(filter Query) *AliasAddAction {
	a.filter = filter
	return a
}