// ApplyAll calls the reducer function with every sandbox in the store.
// This operation is asynchronous in the memory store.
// NOTE: Modifications to the store MUST NOT be done by the StoreReducer.
558327
func (c *memoryStore) ApplyAll(apply StoreReducer) {
	wg := new(sync.WaitGroup)
	for _, cont := range c.all() {
		wg.Add(1)
		go func(sandbox *Sandbox) {
			apply(sandbox)
			wg.Done()
		}(cont)
	}

	wg.Wait()
}
829191
func (n *NodeDrainer) drainAllocs(future *structs.BatchFuture, allocs []*structs.Allocation) {
	// Compute the effected jobs and make the transition map
	jobs := make(map[string]*structs.Allocation, 4)
	transitions := make(map[string]*structs.DesiredTransition, len(allocs))
	for _, alloc := range allocs {
		transitions[alloc.ID] = &structs.DesiredTransition{
			Migrate: helper.BoolToPtr(true),
		}
		jobs[alloc.JobID] = alloc
	}

	evals := make([]*structs.Evaluation, 0, len(jobs))
	for job, alloc := range jobs {
		evals = append(evals, &structs.Evaluation{
			ID:          uuid.Generate(),
			Namespace:   alloc.Namespace,
			Priority:    alloc.Job.Priority,
			Type:        alloc.Job.Type,
			TriggeredBy: structs.EvalTriggerNodeDrain,
			JobID:       job,
			Status:      structs.EvalStatusPending,
		})
	}

	// Commit this update via Raft
	var finalIndex uint64
	for _, u := range partitionAllocDrain(defaultMaxIdsPerTxn, transitions, evals) {
		index, err := n.raft.AllocUpdateDesiredTransition(u.Transitions, u.Evals)
		if err != nil {
			future.Respond(0, err)
			return
		}
		finalIndex = index
	}

	future.Respond(finalIndex, nil)
}
720737
func (s *SourcesStore) All(ctx context.Context) ([]chronograf.Source, error) {
	return s.AllF(ctx)
}
1048600
func (multi *KapacitorStore) All(ctx context.Context) ([]chronograf.Server, error) {
	all := []chronograf.Server{}
	kapSet := map[int]struct{}{}

	ok := false
	var err error
	for _, store := range multi.Stores {
		var kaps []chronograf.Server
		kaps, err = store.All(ctx)
		if err != nil {
			// If this Store is unable to return an array of kapacitors, skip to the
			// next Store.
			continue
		}
		ok = true // We've received a response from at least one Store
		for _, kap := range kaps {
			// Enforce that the kapacitor has a unique ID
			// If the ID has been seen before, ignore the kapacitor
			if _, okay := kapSet[kap.ID]; !okay { // We have a new kapacitor
				kapSet[kap.ID] = struct{}{} // We just care that the ID is unique
				all = append(all, kap)
			}
		}
	}
	if !ok {
		return nil, err
	}
	return all, nil
}
789657
func (s *UsersStore) All(ctx context.Context) ([]chronograf.User, error) {
	err := validOrganization(ctx)
	if err != nil {
		return nil, err
	}

	// retrieve all users from the underlying UsersStore
	usrs, err := s.store.All(ctx)
	if err != nil {
		return nil, err
	}

	// Filter users to only contain users that have at least one role
	// in the provided organization.
	us := usrs[:0]
	for _, usr := range usrs {
		roles := usr.Roles[:0]
		// This filters a users roles so that the resulting struct only contains roles
		// from the organization on the UsersStore.
		for _, r := range usr.Roles {
			if r.Organization == s.organization {
				roles = append(roles, r)
			}
		}
		if len(roles) != 0 {
			// Only add users if they have a role in the associated organization
			usr.Roles = roles
			us = append(us, usr)
		}
	}

	return us, nil
}
1286690
func Apply(store *MemoryStore, item events.Event) (err error) {
	return store.Update(func(tx Tx) error {
		switch v := item.(type) {
		case api.EventCreateTask:
			return CreateTask(tx, v.Task)
		case api.EventUpdateTask:
			return UpdateTask(tx, v.Task)
		case api.EventDeleteTask:
			return DeleteTask(tx, v.Task.ID)

		case api.EventCreateService:
			return CreateService(tx, v.Service)
		case api.EventUpdateService:
			return UpdateService(tx, v.Service)
		case api.EventDeleteService:
			return DeleteService(tx, v.Service.ID)

		case api.EventCreateNetwork:
			return CreateNetwork(tx, v.Network)
		case api.EventUpdateNetwork:
			return UpdateNetwork(tx, v.Network)
		case api.EventDeleteNetwork:
			return DeleteNetwork(tx, v.Network.ID)

		case api.EventCreateNode:
			return CreateNode(tx, v.Node)
		case api.EventUpdateNode:
			return UpdateNode(tx, v.Node)
		case api.EventDeleteNode:
			return DeleteNode(tx, v.Node.ID)

		case state.EventCommit:
			return nil
		}
		return errors.New("unrecognized event type")
	})
}
1020773
func (multi *OrganizationsStore) All(ctx context.Context) ([]chronograf.Organization, error) {
	all := []chronograf.Organization{}
	orgSet := map[string]struct{}{}

	ok := false
	var err error
	for _, store := range multi.Stores {
		var orgs []chronograf.Organization
		orgs, err = store.All(ctx)
		if err != nil {
			// If this Store is unable to return an array of orgs, skip to the
			// next Store.
			continue
		}
		ok = true // We've received a response from at least one Store
		for _, org := range orgs {
			// Enforce that the org has a unique ID
			// If the ID has been seen before, ignore the org
			if _, okay := orgSet[org.ID]; !okay { // We have a new org
				orgSet[org.ID] = struct{}{} // We just care that the ID is unique
				all = append(all, org)
			}
		}
	}
	if !ok {
		return nil, err
	}
	return all, nil
}
978611
func (s *PacketStore) All() []packet.Generic {
	s.mutex.RLock()
	defer s.mutex.RUnlock()

	var all []packet.Generic

	for _, pkt := range s.packets {
		all = append(all, pkt)
	}

	return all
}
250468
func (l *CapList) All() []pb.APICap {
	out := make([]pb.APICap, 0, len(l.m))
	for _, c := range l.m {
		out = append(out, pb.APICap{
			ID:                  string(c.ID),
			Enabled:             c.Enabled,
			Deprecated:          c.Deprecated,
			DisabledReason:      c.DisabledReason,
			DisabledReasonMsg:   c.DisabledReasonMsg,
			DisabledAlternative: c.DisabledAlternative,
		})
	}
	sort.Slice(out, func(i, j int) bool {
		return out[i].ID < out[j].ID
	})
	return out
}
213889
func (s *Store) All() []*Future {
	s.RLock()
	defer s.RUnlock()

	all := make([]*Future, 0, len(s.store))

	for _, savedFuture := range s.store {
		all = append(all, savedFuture)
	}

	return all
}
771563
func (store *FileStore) All() []string {
	store.RLock()
	defer store.RUnlock()
	return store.all()
}
354370
func (store *SourcesStore) All(ctx context.Context) ([]chronograf.Source, error) {
	if store.Source != nil {
		return []chronograf.Source{*store.Source}, nil
	}
	return nil, nil
}
642034
func (rs *retributionStore) ForAll(cb func(*retributionInfo) error) error {
	return rs.db.View(func(tx *bbolt.Tx) error {
		// If the bucket does not exist, then there are no pending
		// retributions.
		retBucket := tx.Bucket(retributionBucket)
		if retBucket == nil {
			return nil
		}

		// Otherwise, we fetch each serialized retribution info,
		// deserialize it, and execute the passed in callback function
		// on it.
		return retBucket.ForEach(func(_, retBytes []byte) error {
			ret := &retributionInfo{}
			err := ret.Decode(bytes.NewBuffer(retBytes))
			if err != nil {
				return err
			}

			return cb(ret)
		})
	})
}
718607
func (o groupResourceOverrides) Apply(config *storagebackend.Config, options *StorageCodecConfig) {
	if len(o.etcdLocation) > 0 {
		config.Transport.ServerList = o.etcdLocation
	}
	if len(o.etcdPrefix) > 0 {
		config.Prefix = o.etcdPrefix
	}

	if len(o.mediaType) > 0 {
		options.StorageMediaType = o.mediaType
	}
	if o.serializer != nil {
		options.StorageSerializer = o.serializer
	}
	if o.encoderDecoratorFn != nil {
		options.EncoderDecoratorFn = o.encoderDecoratorFn
	}
	if o.decoderDecoratorFn != nil {
		options.DecoderDecoratorFn = o.decoderDecoratorFn
	}
	if o.transformer != nil {
		config.Transformer = o.transformer
	}
	if o.disablePaging {
		config.Paging = false
	}
}
283802
func (a *AdmissionOptions) ApplyTo(
	c *server.Config,
	informers informers.SharedInformerFactory,
	kubeAPIServerClientConfig *rest.Config,
	pluginInitializers ...admission.PluginInitializer,
) error {
	if a == nil {
		return nil
	}

	if a.PluginNames != nil {
		// pass PluginNames to generic AdmissionOptions
		a.GenericAdmission.EnablePlugins, a.GenericAdmission.DisablePlugins = computePluginNames(a.PluginNames, a.GenericAdmission.RecommendedPluginOrder)
	}

	return a.GenericAdmission.ApplyTo(c, informers, kubeAPIServerClientConfig, pluginInitializers...)
}
225907
func (o *HPAControllerOptions) ApplyTo(cfg *poautosclerconfig.HPAControllerConfiguration) error {
	if o == nil {
		return nil
	}

	cfg.HorizontalPodAutoscalerSyncPeriod = o.HorizontalPodAutoscalerSyncPeriod
	cfg.HorizontalPodAutoscalerDownscaleStabilizationWindow = o.HorizontalPodAutoscalerDownscaleStabilizationWindow
	cfg.HorizontalPodAutoscalerTolerance = o.HorizontalPodAutoscalerTolerance
	cfg.HorizontalPodAutoscalerUseRESTClients = o.HorizontalPodAutoscalerUseRESTClients
	cfg.HorizontalPodAutoscalerCPUInitializationPeriod = o.HorizontalPodAutoscalerCPUInitializationPeriod
	cfg.HorizontalPodAutoscalerInitialReadinessDelay = o.HorizontalPodAutoscalerInitialReadinessDelay

	return nil
}
883809
func Apply(params Params, opts []Opt) {
	for _, opt := range opts {
		opt(params)
	}
}