// FindMacros returns all macros in the store
481433
func (c *Client) FindMacros(ctx context.Context) ([]*platform.Macro, error) {
	op := getOp(platform.OpFindMacros)
	macros := []*platform.Macro{}
	err := c.db.View(func(tx *bolt.Tx) error {
		b := tx.Bucket(macroBucket)
		c := b.Cursor()

		for k, v := c.First(); k != nil; k, v = c.Next() {
			macro := platform.Macro{}

			err := json.Unmarshal(v, &macro)
			if err != nil {
				return &platform.Error{
					Err: err,
					Op:  op,
				}
			}

			macros = append(macros, &macro)
		}

		return nil
	})
	if err != nil {
		return nil, err
	}

	return macros, nil
}
963419
func (t *tree) FindAll(f func(v interface{}) (bool, error)) []Changer {
	ns, err := t.container.root.findAll(func(fn *node) (bool, error) {
		return f(fn.content.value())
	})
	if err != nil {
		return []Changer{&changer{nil, err}}
	}
	var cs []Changer
	for _, n := range ns {
		cs = append(cs, &changer{n, nil})
	}
	return cs
}
112882
func NewMacro(indent, alias string, master, trailing bool, evaluator ParamEvaluator) *Macro {
	return &Macro{
		indent:   indent,
		alias:    alias,
		master:   master,
		trailing: trailing,

		Evaluator: evaluator,
	}
}
1254627
func (s *Service) UpdateMacro(ctx context.Context, id platform.ID, update *platform.MacroUpdate) (*platform.Macro, error) {
	op := OpPrefix + platform.OpUpdateMacro
	macro, err := s.FindMacroByID(ctx, id)
	if err != nil {
		return nil, &platform.Error{
			Op:   op,
			Code: platform.ENotFound,
			Msg:  "macro not found",
			Err:  err,
		}
	}

	if err := update.Apply(macro); err != nil {
		return nil, &platform.Error{
			Op:  op,
			Err: err,
		}
	}

	if err := s.ReplaceMacro(ctx, macro); err != nil {
		return nil, &platform.Error{
			Op:  op,
			Err: err,
		}
	}

	return macro, nil
}
1047489
func (c *Context) GetAll() Store {
	buf := Store{}
	for key, value := range c.getStore() {
		buf[key] = value
	}
	if c.Parent != nil {
		for key, value := range c.Parent.GetAll() {
			buf[key] = value
		}
	}
	return buf
}
554625
func (o *Enterprise) PublicNetworkMacros(info *bambou.FetchingInfo) (PublicNetworkMacrosList, *bambou.Error) {

	var list PublicNetworkMacrosList
	err := bambou.CurrentSession().FetchChildren(o, PublicNetworkMacroIdentity, &list, info)
	return list, err
}
772460
func (e *MirrorKeystore) Find(c *fi.Context) (*MirrorKeystore, error) {
	if vfsKeystore, ok := c.Keystore.(*fi.VFSCAStore); ok {
		if vfsKeystore.VFSPath().Path() == e.MirrorPath.Path() {
			return e, nil
		}
	}

	// TODO: implement Find so that we aren't always mirroring
	glog.V(2).Infof("MirrorKeystore::Find not implemented; always copying (inefficient)")
	return nil, nil
}
64891
func (this *Context) FindAll(re interface{}) Collection {
    r := getRegexp(re)

    matches := r.FindAllSubmatch(this.Bytes(), -1)

    names := make(map[string]int)

    for k, v := range r.SubexpNames() {
        if v != "" {
            names[v] = k
        }
    }

    result := make(Collection, len(matches))
    for i, match := range matches {
        result[i] = &Context {
            Parent: this,
            List: match,
            Names: names,
        }
    }

    return result
}
422859
func (s *Service) FindOrganizations(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error) {
	op := OpPrefix + platform.OpFindOrganizations
	if filter.ID != nil {
		o, err := s.FindOrganizationByID(ctx, *filter.ID)
		if err != nil {
			return nil, 0, &platform.Error{
				Op:  op,
				Err: err,
			}
		}

		return []*platform.Organization{o}, 1, nil
	}

	filterFunc := func(o *platform.Organization) bool { return true }
	if filter.Name != nil {
		filterFunc = func(o *platform.Organization) bool {
			return o.Name == *filter.Name
		}
	}

	orgs, pe := s.filterOrganizations(ctx, filterFunc)
	if pe != nil {
		return nil, 0, &platform.Error{
			Err: pe,
			Op:  op,
		}
	}

	if len(orgs) == 0 {
		return orgs, 0, &platform.Error{
			Code: platform.ENotFound,
			Op:   op,
			Msg:  errOrganizationNotFound,
		}
	}

	return orgs, len(orgs), nil
}
31652
func (s *MacroService) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error) {
	path := macroIDPath(id)
	url, err := newURL(s.Addr, path)
	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 mr macroResponse
	if err := json.NewDecoder(resp.Body).Decode(&mr); err != nil {
		return nil, err
	}

	macro := mr.Macro
	return macro, nil
}
359383
func (s *Service) FindLabels(ctx context.Context, filter influxdb.LabelFilter, opt ...influxdb.FindOptions) ([]*influxdb.Label, error) {
	ls := []*influxdb.Label{}
	err := s.kv.View(ctx, func(tx Tx) error {
		labels, err := s.findLabels(ctx, tx, filter)
		if err != nil {
			return err
		}
		ls = labels
		return nil
	})

	if err != nil {
		return nil, err
	}

	return ls, nil
}
1050531
func (c *ClientV1) FindTools(args params.FindToolsParams) (params.FindToolsResult, error) {
	if err := c.checkCanWrite(); err != nil {
		return params.FindToolsResult{}, err
	}

	if args.AgentStream != "" {
		return params.FindToolsResult{}, errors.New("requesting agent-stream not supported by model")
	}
	return c.api.toolsFinder.FindTools(args)
}
217374
func (ps *Store) GetAll() map[string]*v2.Plugin {
	ps.RLock()
	defer ps.RUnlock()
	return ps.plugins
}
213634
func FindExactTools(env environs.Environ, vers version.Number, series string, arch string) (_ *coretools.Tools, err error) {
	logger.Debugf("finding exact version %s", vers)
	// Construct a tools filter.
	// Discard all that are known to be irrelevant.
	filter := coretools.Filter{
		Number: vers,
		Series: series,
		Arch:   arch,
	}
	streams := PreferredStreams(&vers, env.Config().Development(), env.Config().AgentStream())
	logger.Debugf("looking for agent binaries in streams %v", streams)
	availableTools, err := FindTools(env, vers.Major, vers.Minor, streams, filter)
	if err != nil {
		return nil, err
	}
	if len(availableTools) != 1 {
		return nil, fmt.Errorf("expected one agent binary, got %d agent binaries", len(availableTools))
	}
	return availableTools[0], nil
}
811726
func (s *SourceService) FindSources(ctx context.Context, opt platform.FindOptions) ([]*platform.Source, int, error) {
	u, err := newURL(s.Addr, sourcePath)
	if err != nil {
		return nil, 0, err
	}

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

	SetToken(s.Token, req)

	hc := newClient(u.Scheme, s.InsecureSkipVerify)
	resp, err := hc.Do(req)
	if err != nil {
		return nil, 0, err
	}
	defer resp.Body.Close()

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

	var bs []*platform.Source
	if err := json.NewDecoder(resp.Body).Decode(&bs); err != nil {
		return nil, 0, err
	}

	return bs, len(bs), nil
}
1351643
func (s *Service) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error) {
	op := OpPrefix + platform.OpFindMacroByID
	i, ok := s.macroKV.Load(id.String())
	if !ok {
		return nil, &platform.Error{
			Op:   op,
			Code: platform.ENotFound,
			Msg:  "macro not found",
		}
	}

	macro, ok := i.(*platform.Macro)
	if !ok {
		return nil, &platform.Error{
			Op:  op,
			Msg: fmt.Sprintf("type %T is not a macro", i),
		}
	}

	return macro, nil
}
792492
func FindClusters(tx ReadTx, by By) ([]*api.Cluster, error) {
	checkType := func(by By) error {
		switch by.(type) {
		case byName, byNamePrefix, byIDPrefix, byCustom, byCustomPrefix:
			return nil
		default:
			return ErrInvalidFindBy
		}
	}

	clusterList := []*api.Cluster{}
	appendResult := func(o api.StoreObject) {
		clusterList = append(clusterList, o.(*api.Cluster))
	}

	err := tx.find(tableCluster, by, checkType, appendResult)
	return clusterList, err
}