// IsLabelBased returns true whether the L3 source endpoints are selected based
// on labels, i.e. either by setting FromEndpoints or FromEntities, or not
// setting any From field.
18841
func (i *IngressRule) IsLabelBased() bool {
	return len(i.FromRequires)+len(i.FromCIDR)+len(i.FromCIDRSet) == 0
}
208309
func (p *HybridProxier) shouldEndpointsUseUserspace(endpoints *corev1.Endpoints) bool {
	hasEndpoints := false
	for _, subset := range endpoints.Subsets {
		if len(subset.Addresses) > 0 {
			hasEndpoints = true
			break
		}
	}

	if !hasEndpoints {
		if _, ok := endpoints.Annotations[unidlingapi.IdledAtAnnotation]; ok {
			return true
		}
	}

	return false
}
167451
func IsLabel(label string) bool {
	p := strings.Index(label, "/")
	if p <= 0 || p >= len(label)-1 {
		// cannot accept namespace empty nor label empty
		return false
	}
	if strings.LastIndex(label, "/") != p {
		// several slash in the Label
		return false
	}
	return true

}
705095
func (s EntitySlice) GetAsEndpointSelectors() EndpointSelectorSlice {
	slice := EndpointSelectorSlice{}
	for _, e := range s {
		if selector, ok := EntitySelectorMapping[e]; ok {
			slice = append(slice, selector...)
		}
	}

	return slice
}
282291
func NewESFromLabels(lbls ...labels.Label) EndpointSelector {
	ml := map[string]string{}
	for _, lbl := range lbls {
		ml[lbl.GetExtendedKey()] = lbl.Value
	}

	return NewESFromMatchRequirements(ml, nil)
}
760881
func (reg *typeRegistry) IsBaseTypeName(name TypeRef) bool {
	if name != "" {
		lower := strings.ToLower(string(name))
		for _, n := range namesBaseType {
			if lower == strings.ToLower(n) {
				return true
			}
		}
	}
	return false
}
109398
func isBaseType(props SharedProperties) bool {
	if props.IsNonPropertiesObject() {
		return true
	}

	underlyingType := props.GetUnderlyingType()
	if props.IsArray() {
		underlyingType = props.GetArrayType()
	}

	switch underlyingType {
	case "any", "string", "enum", "integer", "number", "boolean":
		return true
	}
	return false
}
912932
func NewBaseDfbReport(StartDate string) *BaseDfbReport {
	s := new(BaseDfbReport)
	s.StartDate = StartDate
	return s
}
570599
func NewBooleanNode(operator lex.Token, args ...Node) *BooleanNode {
	//u.Debugf("NewBinaryNode: %v %v %v", lhArg, operator, rhArg)
	return &BooleanNode{Args: args, Operator: operator}
}
826943
func NewBooleanAnd(Variable node.Node, Expression node.Node) *BooleanAnd {
	return &BooleanAnd{
		FreeFloating: nil,
		Left:         Variable,
		Right:        Expression,
	}
}
1170862
func (p *Paginater) IsLast() bool {
	if p.total == 0 {
		return true
	}
	return p.total > (p.current-1)*p.pagingNum && !p.HasNext()
}
939640
func NewESFromK8sLabelSelector(srcPrefix string, lss ...*metav1.LabelSelector) EndpointSelector {
	var (
		matchLabels      map[string]string
		matchExpressions []metav1.LabelSelectorRequirement
	)
	for _, ls := range lss {
		if ls == nil {
			continue
		}
		if ls.MatchLabels != nil {
			if matchLabels == nil {
				matchLabels = map[string]string{}
			}
			for k, v := range ls.MatchLabels {
				matchLabels[srcPrefix+k] = v
			}
		}
		if ls.MatchExpressions != nil {
			if matchExpressions == nil {
				matchExpressions = make([]metav1.LabelSelectorRequirement, 0, len(ls.MatchExpressions))
			}
			for _, v := range ls.MatchExpressions {
				v.Key = srcPrefix + v.Key
				matchExpressions = append(matchExpressions, v)
			}
		}
	}
	return NewESFromMatchRequirements(matchLabels, matchExpressions)
}
595739
func ValidateDBOptions(binary string, ctx *cli.Context) (*DBConfigs, error) {
	var storeDriver string
	var storeURL string
	var storeURLs string
	etcdURLs := ctx.String("etcd")
	consulURLs := ctx.String("consul")

	if etcdURLs != "" && consulURLs != "" {
		return nil, fmt.Errorf("ambiguous %s db endpoints, both etcd and consul specified: etcd: %s, consul: %s", binary, etcdURLs, consulURLs)
	} else if etcdURLs == "" && consulURLs == "" {
		// if neither etcd or consul is set, try etcd at http://127.0.0.1:2379
		storeDriver = "etcd"
		storeURLs = "http://127.0.0.1:2379"
	} else if etcdURLs != "" {
		storeDriver = "etcd"
		storeURLs = etcdURLs
	} else {
		storeDriver = "consul"
		storeURLs = consulURLs
	}
	for _, endpoint := range FilterEmpty(strings.Split(storeURLs, ",")) {
		_, err := url.Parse(endpoint)
		if err != nil {
			return nil, fmt.Errorf("invalid %s %v endpoint: %v", binary, storeDriver, endpoint)
		}
		// TODO: support multi-endpoints
		storeURL = endpoint
		logrus.Infof("Using %s state db endpoints: %v: %v", binary, storeDriver, storeURL)
		break
	}

	if storeURL == "" {
		return nil, fmt.Errorf("invalid %s %s endpoints: empty", binary, storeDriver)
	}

	return &DBConfigs{
		StoreDriver: storeDriver,
		StoreURL:    storeURL,
	}, nil
}
419530
func (i *ImportRestriction) isAllowed(packageToCheck string) bool {
	// if its not under our root, then its a built-in.  Everything else is under
	// github.com/openshift/origin or github.com/openshift/origin/vendor
	if !strings.HasPrefix(packageToCheck, rootPackage) {
		return true
	}
	if i.isIncludedInRestrictedPackages(packageToCheck) {
		return true
	}

	for _, forbiddenPackageRoot := range i.ForbiddenImportPackageRoots {
		if strings.HasPrefix(forbiddenPackageRoot, "vendor") {
			forbiddenPackageRoot = rootPackage + "/" + forbiddenPackageRoot
		}
		if strings.HasPrefix(packageToCheck, forbiddenPackageRoot) {
			return false
		}
	}
	for _, allowedPackage := range i.AllowedImportPackages {
		if strings.HasPrefix(allowedPackage, "vendor") {
			allowedPackage = rootPackage + "/" + allowedPackage
		}
		if packageToCheck == allowedPackage {
			return true
		}
	}
	for _, allowedPackageRoot := range i.AllowedImportPackageRoots {
		if strings.HasPrefix(allowedPackageRoot, "vendor") {
			allowedPackageRoot = rootPackage + "/" + allowedPackageRoot
		}
		if strings.HasPrefix(packageToCheck, allowedPackageRoot) {
			return true
		}
	}

	return false
}
1216950
func IsBaseRole(role RoleName) bool {
	for _, baseRole := range BaseRoles {
		if role == baseRole {
			return true
		}
	}
	return false
}
225032
func baseDirs(root string, includePatterns []string) ([]string, []string) {
	root = filepath.FromSlash(root)
	bases := make([]string, len(includePatterns))
	newincludes := includePatterns[:]
	for i, v := range includePatterns {
		bdir, trailer := filter.SplitPattern(v)
		if !filepath.IsAbs(bdir) {
			bdir = filepath.Join(root, filepath.FromSlash(bdir))
		}
		if stat, err := os.Lstat(bdir); err == nil {
			if stat.Mode()&os.ModeSymlink != 0 {
				// Case 1: The file exists and is a symlink, so we rebase the
				// include patterns and the base directory
				lnk, err := os.Readlink(bdir)
				if err != nil {
					continue
				}
				if filepath.IsAbs(lnk) {
					bdir = lnk
				} else {
					bdir = filepath.Join(bdir, lnk)
				}
				newincludes[i] = bdir + "/" + trailer
			} else {
				// Case 2: The file exists and is nota symlink, so we leave bdir
				// unmodified.
				bdir = enclosingDir(bdir)
				if bdir == "" {
					bdir = root
				}
			}
		} else {
			bdir = enclosingDir(bdir)
			if bdir == "" {
				bdir = root
			}
		}
		bases[i] = bdir
	}
	return newincludes, bases
}
1157120
func NewBooleanSimple(b bool) BooleanAttribute {
	result := &BooleanSimple{NewAttribute(NORMAL, nil, nil)}
	result.Set(b)
	return result
}