// MatchConstraintWithAtLeastOneTag tests a constraint for one single service.
358442
func (c *Constraint) MatchConstraintWithAtLeastOneTag(tags []string) bool {
	for _, tag := range tags {
		if glob.Glob(c.Regex, tag) {
			return true
		}
	}
	return false
}
664504
func matchesAsgTags(tags map[string]string, actual []*autoscaling.TagDescription) bool {
	for k, v := range tags {
		found := false
		for _, a := range actual {
			if aws.StringValue(a.Key) == k {
				if aws.StringValue(a.Value) == v {
					found = true
					break
				}
			}
		}
		if !found {
			return false
		}
	}
	return true
}
1174641
func TagsExtractMeta(tags map[string]interface{}) (InstanceCNS, map[string]interface{}) {
	nativeCNS := InstanceCNS{}
	nativeTags := make(map[string]interface{}, len(tags))
	for k, raw := range tags {
		if _, found := reservedInstanceCNSTags[k]; found {
			switch k {
			case CNSTagDisable:
				b := raw.(bool)
				nativeCNS.Disable = b
			case CNSTagReversePTR:
				s := raw.(string)
				nativeCNS.ReversePTR = s
			case CNSTagServices:
				nativeCNS.Services = strings.Split(raw.(string), ",")
			default:
				// TODO(seanc@): should assert, logic fail
			}
		} else {
			nativeTags[k] = raw
		}
	}

	return nativeCNS, nativeTags
}
237333
func (p *Repository) GetRulesMatching(labels labels.LabelArray) (ingressMatch bool, egressMatch bool) {
	ingressMatch = false
	egressMatch = false
	for _, r := range p.rules {
		rulesMatch := r.EndpointSelector.Matches(labels)
		if rulesMatch {
			if len(r.Ingress) > 0 {
				ingressMatch = true
			}
			if len(r.Egress) > 0 {
				egressMatch = true
			}
		}

		if ingressMatch && egressMatch {
			return
		}
	}
	return
}
268717
func (itype InstanceType) match(cons constraints.Value) (InstanceType, bool) {
	nothing := InstanceType{}
	if cons.Arch != nil {
		itype.Arches = filterArches(itype.Arches, []string{*cons.Arch})
	}
	if itype.Deprecated && !cons.HasInstanceType() {
		return nothing, false
	}
	if cons.HasInstanceType() && itype.Name != *cons.InstanceType {
		return nothing, false
	}
	if len(itype.Arches) == 0 {
		return nothing, false
	}
	if cons.CpuCores != nil && itype.CpuCores < *cons.CpuCores {
		return nothing, false
	}
	if cons.CpuPower != nil && itype.CpuPower != nil && *itype.CpuPower < *cons.CpuPower {
		return nothing, false
	}
	if cons.Mem != nil && itype.Mem < *cons.Mem {
		return nothing, false
	}
	if cons.RootDisk != nil && itype.RootDisk > 0 && itype.RootDisk < *cons.RootDisk {
		return nothing, false
	}
	if cons.Tags != nil && len(*cons.Tags) > 0 && !tagsMatch(*cons.Tags, itype.Tags) {
		return nothing, false
	}
	if cons.HasVirtType() && (itype.VirtType == nil || *itype.VirtType != *cons.VirtType) {
		return nothing, false
	}
	return itype, true
}
812744
func (k *kubernetesClient) ConstraintsValidator(ctx context.ProviderCallContext) (constraints.Validator, error) {
	validator := constraints.NewValidator()
	validator.RegisterUnsupported(unsupportedConstraints)
	return validator, nil
}
357892
func tagIgnoredSSM(t *ssm.Tag) bool {
	filter := []string{"^aws:"}
	for _, v := range filter {
		log.Printf("[DEBUG] Matching %v with %v\n", v, *t.Key)
		r, _ := regexp.MatchString(v, *t.Key)
		if r {
			log.Printf("[DEBUG] Found AWS specific tag %s (val: %s), ignoring.\n", *t.Key, *t.Value)
			return true
		}
	}
	return false
}
50920
func (t *Template) GetAWSServiceCatalogLaunchTemplateConstraintWithName(name string) (*resources.AWSServiceCatalogLaunchTemplateConstraint, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSServiceCatalogLaunchTemplateConstraint:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSServiceCatalogLaunchTemplateConstraint not found", name)
}
634919
func ParseInstanceTag(t string) (*api.Tag, error) {
	switch chunks := strings.SplitN(t, ":", 2); {
	case len(chunks) != 2:
		return nil, fmt.Errorf("%q doesn't look like a tag (a key:value pair)", t)
	case len(t) > 400:
		return nil, fmt.Errorf("the tag is too long, should be <=400 chars: %q", t)
	case !tagKeyRe.MatchString(chunks[0]):
		return nil, fmt.Errorf("invalid tag key in %q (should match %q)", t, tagKeyReStr)
	case strings.HasPrefix(chunks[1], " ") || strings.HasSuffix(chunks[1], " "):
		return nil, fmt.Errorf("invalid tag value in %q (should not start or end with ' ')", t)
	case !tagValRe.MatchString(chunks[1]):
		return nil, fmt.Errorf("invalid tag value in %q (should match %q)", t, tagValReStr)
	default:
		return &api.Tag{
			Key:   chunks[0],
			Value: chunks[1],
		}, nil
	}
}
1088727
func validateConfigBlock(block *common.Block) error {
	envelopeConfig, err := utils.ExtractEnvelope(block, 0)
	if err != nil {
		return errors.Errorf("Failed to %s", err)
	}

	configEnv := &common.ConfigEnvelope{}
	_, err = utils.UnmarshalEnvelopeOfType(envelopeConfig, common.HeaderType_CONFIG, configEnv)
	if err != nil {
		return errors.Errorf("Bad configuration envelope: %s", err)
	}

	if configEnv.Config == nil {
		return errors.New("Nil config envelope Config")
	}

	if configEnv.Config.ChannelGroup == nil {
		return errors.New("Nil channel group")
	}

	if configEnv.Config.ChannelGroup.Groups == nil {
		return errors.New("No channel configuration groups are available")
	}

	_, exists := configEnv.Config.ChannelGroup.Groups[channelconfig.ApplicationGroupKey]
	if !exists {
		return errors.Errorf("Invalid configuration block, missing %s "+
			"configuration group", channelconfig.ApplicationGroupKey)
	}

	return nil
}
994996
func WithTag(name Named, tag string) (NamedTagged, error) {
	if !anchoredTagRegexp.MatchString(tag) {
		return nil, ErrTagInvalidFormat
	}
	if canonical, ok := name.(Canonical); ok {
		return reference{
			name:   name.Name(),
			tag:    tag,
			digest: canonical.Digest(),
		}, nil
	}
	return taggedReference{
		name: name.Name(),
		tag:  tag,
	}, nil
}
2451
func (p *PhysicalUnionScan) matchProperty(prop *requiredProperty, childPlanInfo ...*physicalPlanInfo) *physicalPlanInfo {
	limit := prop.limit
	res := p.GetChildByIndex(0).(PhysicalPlan).matchProperty(convertLimitOffsetToCount(prop), childPlanInfo...)
	np := *p
	np.SetChildren(res.p)
	res.p = &np
	if limit != nil {
		res = addPlanToResponse(limit, res)
	}
	return res
}
140562
func (b *backend) matchesCertificateExtensions(clientCert *x509.Certificate, config *ParsedCert) bool {
	// If no required extensions, nothing to check here
	if len(config.Entry.RequiredExtensions) == 0 {
		return true
	}
	// Fail fast if we have required extensions but no extensions on the cert
	if len(clientCert.Extensions) == 0 {
		return false
	}

	// Build Client Extensions Map for Constraint Matching
	// x509 Writes Extensions in ASN1 with a bitstring tag, which results in the field
	// including its ASN.1 type tag bytes. For the sake of simplicity, assume string type
	// and drop the tag bytes. And get the number of bytes from the tag.
	clientExtMap := make(map[string]string, len(clientCert.Extensions))
	for _, ext := range clientCert.Extensions {
		var parsedValue string
		asn1.Unmarshal(ext.Value, &parsedValue)
		clientExtMap[ext.Id.String()] = parsedValue
	}
	// If any of the required extensions don't match the constraint fails
	for _, requiredExt := range config.Entry.RequiredExtensions {
		reqExt := strings.SplitN(requiredExt, ":", 2)
		clientExtValue, clientExtValueOk := clientExtMap[reqExt[0]]
		if !clientExtValueOk || !glob.Glob(reqExt[1], clientExtValue) {
			return false
		}
	}
	return true
}
734944
func (c *Constraint) matchesPermanodeTypes() []string {
	if c == nil {
		return nil
	}
	if pc := c.Permanode; pc != nil && pc.Attr == "camliNodeType" && pc.Value != "" {
		return []string{pc.Value}
	}
	if lc := c.Logical; lc != nil {
		sa := lc.A.matchesPermanodeTypes()
		sb := lc.B.matchesPermanodeTypes()
		switch lc.Op {
		case "and":
			if len(sa) != 0 {
				return sa
			}
			return sb
		case "or":
			return append(sa, sb...)
		}
	}
	return nil

}
321175
func tagIgnoredSfn(t *sfn.Tag) bool {
	filter := []string{"^aws:"}
	for _, v := range filter {
		log.Printf("[DEBUG] Matching %v with %v\n", v, aws.StringValue(t.Key))
		r, _ := regexp.MatchString(v, aws.StringValue(t.Key))
		if r {
			log.Printf("[DEBUG] Found AWS specific tag %s (val: %s), ignoring.\n", aws.StringValue(t.Key), aws.StringValue(t.Value))
			return true
		}
	}
	return false
}
1015065
func FindGroupFromTag(epgTag string) (*mastercfg.EndpointGroupState, error) {
	stateDriver, err := utils.GetStateDriver()
	if err != nil {
		return nil, err
	}

	epgCfg := &mastercfg.EndpointGroupState{}
	epgCfg.StateDriver = stateDriver

	epgList, err := epgCfg.ReadAll()
	if err != nil {
		return nil, err
	}

	var epg *mastercfg.EndpointGroupState
	found := false
	for _, epgP := range epgList {
		epg = epgP.(*mastercfg.EndpointGroupState)
		if epg.GroupTag == epgTag {
			found = true
			break
		}
	}
	if !found {
		return nil, fmt.Errorf("Couldn't find group matching the tag %s", epgTag)
	}
	return epg, nil
}
1090284
func (mv *Validator) WithTag(tag string) *Validator {
	v := mv.copy()
	v.SetTag(tag)
	return v
}