// FindProtos returns a list of protos.
492844
func (s *ProtoService) FindProtos(ctx context.Context) ([]*platform.Proto, error) {
	if s.FindProtosFn == nil {
		return nil, errors.New("not implemented")
	}
	return s.FindProtosFn(ctx)
}
1259989
func (s *Service) FindSources(ctx context.Context, opt platform.FindOptions) ([]*platform.Source, int, error) {
	var ds []*platform.Source
	s.sourceKV.Range(func(k, v interface{}) bool {
		d, ok := v.(*platform.Source)
		if !ok {
			return false
		}
		ds = append(ds, d)
		return true
	})
	return ds, len(ds), nil
}
242894
func (g *GPG) FindPublicKeys(ctx context.Context, search ...string) ([]string, error) {
	kl, err := g.listKeys(ctx, "public", search...)
	if err != nil || kl == nil {
		return nil, err
	}
	if gpg.IsAlwaysTrust(ctx) {
		return kl.Recipients(), nil
	}
	return kl.UseableKeys().Recipients(), nil
}
1247302
func (s *Service) FindMacros(ctx context.Context) ([]*platform.Macro, error) {
	op := OpPrefix + platform.OpFindMacros
	var err error
	var macros []*platform.Macro
	s.macroKV.Range(func(k, v interface{}) bool {
		macro, ok := v.(*platform.Macro)
		if !ok {
			err = &platform.Error{
				Op:  op,
				Msg: fmt.Sprintf("type %T is not a macro", v),
			}
			return false
		}

		macros = append(macros, macro)
		return true
	})

	if err != nil {
		return nil, err
	}

	return macros, nil
}
1140890
func Find(pid int) (p P, ok bool, err error) {
	pr, err := ps.FindProcess(pid)
	if err != nil {
		return P{}, false, err
	}
	path, version, agent, ok, err := isGo(pr)
	if !ok {
		return P{}, false, nil
	}
	return P{
		PID:          pr.Pid(),
		PPID:         pr.PPid(),
		Exec:         pr.Executable(),
		Path:         path,
		BuildVersion: version,
		Agent:        agent,
	}, true, nil
}
16490
func ProtoDescriptors(protoName string) ([]byte, error) {
	if strings.HasSuffix(protoName, ".proto") {
		descriptor := proto.FileDescriptor(protoName)
		if descriptor == nil {
			return nil, constants.ErrProtodescriptor
		}
		return descriptor, nil
	}

	if strings.HasPrefix(protoName, "types.") {
		protoName = strings.Replace(protoName, "types.", "google.protobuf.", 1)
	}
	protoReflectTypePointer := proto.MessageType(protoName)
	if protoReflectTypePointer == nil {
		return nil, constants.ErrProtodescriptor
	}

	protoReflectType := protoReflectTypePointer.Elem()
	protoValue := reflect.New(protoReflectType)
	descriptorMethod, ok := protoReflectTypePointer.MethodByName("Descriptor")
	if !ok {
		return nil, constants.ErrProtodescriptor
	}

	descriptorValue := descriptorMethod.Func.Call([]reflect.Value{protoValue})
	protoDescriptor := descriptorValue[0].Bytes()

	return protoDescriptor, nil
}
444512
func (r *Request) WithProto(proto string) *Request {
	if r.chain.failed() {
		return r
	}
	major, minor, ok := http.ParseHTTPVersion(proto)
	if !ok {
		r.chain.fail(
			"\nunexpected protocol version %q, expected \"HTTP/{major}.{minor}\"",
			proto)
		return r
	}
	r.http.ProtoMajor = major
	r.http.ProtoMinor = minor
	return r
}
964492
func (r Product_Promotion) FindByPromoCode(code *string) (resp datatypes.Container_Product_Promotion, err error) {
	params := []interface{}{
		code,
	}
	err = r.Session.DoRequest("SoftLayer_Product_Promotion", "findByPromoCode", params, &r.Options, &resp)
	return
}
910364
func FindDogfiles(p string) ([]string, error) {
	var dogfilePaths []string

	currentPath, err := filepath.Abs(p)
	if err != nil {
		return nil, err
	}

	for {
		var files []os.FileInfo
		files, err = ioutil.ReadDir(currentPath)
		if err != nil {
			return nil, err
		}

		for _, file := range files {
			if validDogfileName(file.Name()) {
				dogfilePath := path.Join(currentPath, file.Name())
				dogfilePaths = append(dogfilePaths, dogfilePath)
			}
		}

		if len(dogfilePaths) > 0 {
			return dogfilePaths, nil
		}

		nextPath := path.Dir(currentPath)
		if nextPath == currentPath {
			return dogfilePaths, nil
		}
		currentPath = nextPath
	}
}
294768
func (b *Builder) FindTypes() (types.Universe, error) {
	// Take a snapshot of pkgs to iterate, since this will recursively mutate
	// b.parsed. Iterate in a predictable order.
	pkgPaths := []string{}
	for pkgPath := range b.parsed {
		pkgPaths = append(pkgPaths, string(pkgPath))
	}
	sort.Strings(pkgPaths)

	u := types.Universe{}
	for _, pkgPath := range pkgPaths {
		if err := b.findTypesIn(importPathString(pkgPath), &u); err != nil {
			return nil, err
		}
	}
	return u, nil
}
384939
func (m *Message) FromProto(p proto.Message) error {
	ptr := reflect.ValueOf(p)
	if ptr.Type() != m.typ.Type() {
		return fmt.Errorf("bad message type: got %s, expect %s", ptr.Type(), m.typ.Type())
	}

	msg := ptr.Elem()
	for name, fd := range m.typ.fields {
		// Get the field's value from the proto message as reflect.Value. For unused
		// oneof alternatives this is an invalid zero value, we skip them right
		// away. For other fields it is reflect.Value (of fd.typ type) that MAY be
		// nil inside (for unset fields). toStarlarkValue converts such values to
		// starlark.None.
		val := fd.onProtoReflection(msg, reflectFromProto)
		if !val.IsValid() {
			continue
		}
		// Convert the Go value to the corresponding Starlark value and assign it to
		// the field in 'm'.
		sv, err := toStarlarkValue(val)
		if err != nil {
			return fmt.Errorf("cannot recognize value of field %s: %s", name, err)
		}
		if err := m.SetField(name, sv); err != nil {
			return err
		}
	}

	return nil
}
225943
func FindAll() []P {
	pss, err := ps.Processes()
	if err != nil {
		return nil
	}

	var wg sync.WaitGroup
	wg.Add(len(pss))
	found := make(chan P)

	for _, pr := range pss {
		pr := pr
		go func() {
			defer wg.Done()

			path, version, agent, ok, err := isGo(pr)
			if err != nil {
				// TODO(jbd): Return a list of errors.
			}
			if !ok {
				return
			}
			found <- P{
				PID:          pr.Pid(),
				PPID:         pr.PPid(),
				Exec:         pr.Executable(),
				Path:         path,
				BuildVersion: version,
				Agent:        agent,
			}
		}()
	}
	go func() {
		wg.Wait()
		close(found)
	}()
	var results []P
	for p := range found {
		results = append(results, p)
	}
	return results
}
1205029
func (s *MacroService) FindMacros(ctx context.Context) ([]*platform.Macro, error) {
	url, err := newURL(s.Addr, macroPath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("GET", url.String(), nil)
	if err != nil {
		return nil, err
	}

	SetToken(s.Token, req)
	hc := newClient(url.Scheme, s.InsecureSkipVerify)

	resp, err := hc.Do(req)
	if err != nil {
		return nil, err
	}

	if err := CheckError(resp, true); err != nil {
		return nil, err
	}

	var ms getMacrosResponse
	if err := json.NewDecoder(resp.Body).Decode(&ms); err != nil {
		return nil, err
	}

	macros := ms.ToPlatform()
	return macros, nil
}
473989
func (s *InstallationSettings) FindCFPostgresJobs() (jobs []Jobs) {

	jobsList := s.FindJobsByProductID("cf")
	for _, job := range jobsList {
		if isPostgres(job.Identifier, job.GetInstances()) {
			jobs = append(jobs, job)
		}
	}

	return jobs
}
90432
func (s *Service) FindBuckets(ctx context.Context, filter platform.BucketFilter, opt ...platform.FindOptions) ([]*platform.Bucket, int, error) {
	var err error
	bs, pe := s.findBuckets(ctx, filter, opt...)
	if pe != nil {
		pe.Op = OpPrefix + platform.OpFindBuckets
		err = pe
		return nil, 0, err
	}
	return bs, len(bs), nil
}
903731
func Proto3ToResult(qr *querypb.QueryResult) *Result {
	if qr == nil {
		return nil
	}
	return &Result{
		Fields:       qr.Fields,
		RowsAffected: qr.RowsAffected,
		InsertID:     qr.InsertId,
		Rows:         proto3ToRows(qr.Fields, qr.Rows),
		Extras:       qr.Extras,
	}
}
580426
func findResources(isolators types.Isolators) (mem, cpus int64) {
	for _, i := range isolators {
		switch v := i.Value().(type) {
		case *types.ResourceMemory:
			mem = v.Limit().Value()
			// Convert bytes into megabytes
			mem /= 1024 * 1024
		case *types.ResourceCPU:
			cpus = v.Limit().Value()
		}
	}
	return mem, cpus
}