// FilterByRelease is a CertificateFilter that returns true if the
// release version matches the regular expression passed in.
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
}
403602
func encodeRelease(rls *rspb.Release) (string, error) {
	b, err := proto.Marshal(rls)
	if err != nil {
		return "", err
	}
	var buf bytes.Buffer
	w, err := gzip.NewWriterLevel(&buf, gzip.BestCompression)
	if err != nil {
		return "", err
	}
	if _, err = w.Write(b); err != nil {
		return "", err
	}
	w.Close()

	return b64.EncodeToString(buf.Bytes()), nil
}
910100
func (r *RepositoryRelease) GetPrerelease() bool {
	if r == nil || r.Prerelease == nil {
		return false
	}
	return *r.Prerelease
}
1130832
func IdentityFilterByProviderType(providerType string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("provider_type = ?", providerType)
	}
}
1172654
func NewCertificateRelease(c *Certificate, r *Release) *CertificateRelease {
	return &CertificateRelease{
		Certificate: c,
		Release:     r,
	}
}
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
}
132599
func FilterByIssuer(iss string) (CertificateFilter, error) {
	issFilter, err := regexp.Compile(iss)
	if err != nil {
		return nil, err
	}

	return func(cm *CertificateMetadata) bool {
		return issFilter.MatchString(cm.Issuer)
	}, nil
}
1130805
func GetReleaseVersions() ([]*Version, error) {
	versions, err := GetVersions()
	if err != nil {
		return nil, err
	}
	var output []*Version
	for _, version := range versions {
		if version.Version.String() != version.FullVersion {
			continue
		}
		output = append(output, version)
	}
	return output, nil
}
153483
func FilterIncorrectIPVersion(ipStrings []string, isIPv6Mode bool) ([]string, []string) {
	return filterWithCondition(ipStrings, isIPv6Mode, utilnet.IsIPv6String)
}
1259332
func (rs *Results) Filter(fn func(Result) bool) *Results {
	results := make(Results, 0)
	for _, result := range *rs {
		if fn(result) {
			results = append(results, result)
		}
	}
	return &results
}
680502
func FilterBySKI(ski string) (CertificateFilter, error) {
	skiFilter, err := regexp.Compile(ski)
	if err != nil {
		return nil, err
	}

	return func(cm *CertificateMetadata) bool {
		return skiFilter.MatchString(cm.SKI)
	}, nil
}
1208918
func GetReleaseByID(id int64) (*Release, error) {
	r := new(Release)
	has, err := x.Id(id).Get(r)
	if err != nil {
		return nil, err
	} else if !has {
		return nil, ErrReleaseNotExist{id, ""}
	}

	return r, r.LoadAttributes()
}
1229661
func FilterByAKI(aki string) (CertificateFilter, error) {
	akiFilter, err := regexp.Compile(aki)
	if err != nil {
		return nil, err
	}

	return func(cm *CertificateMetadata) bool {
		return akiFilter.MatchString(cm.AKI)
	}, nil
}
1123557
func isReleasedTarget(role data.RoleName) bool {
	return role == data.CanonicalTargetsRole || role == trust.ReleasesRole
}
1024552
func (slpp *softLayer_Product_Package_Service) filterProducts(array []*datatypes.Softlayer_Product_Package, predicate func(*datatypes.Softlayer_Product_Package) bool) []datatypes.Softlayer_Product_Package {
	filtered := make([]datatypes.Softlayer_Product_Package, 0)
	for _, element := range array {
		if predicate(element) {
			filtered = append(filtered, *element)
		}
	}
	return filtered
}
1088365
func ReleaseListFilter(filter string) ReleaseListOption {
	return func(opts *options) {
		opts.listReq.Filter = filter
	}
}
136317
func (r Result) Filter(fn func(*resource.Info) bool) Result {
	var result Result
	for _, i := range r {
		if fn(i) {
			result.Append(i)
		}
	}
	return result
}