// GroupByName satisfies AccountProvider.
func (m *MockProvider) GroupByName(name string) (*accounts.Group, error) {
	for _, g := range m.Grps {
		if name == g.Name {
			return g, m.Err
		}
	}
	return nil, accounts.GroupNameNotFound(name)
}
示例#2
0
// GroupByName satisfies AccountProvider.
func (s *cachingStore) GroupByName(name string) (*accounts.Group, error) {
	s.RLock()
	defer s.RUnlock()
	g, ok := s.groupsByName[name]
	if ok {
		return g, nil
	}
	ch := make(chan struct{})
	logger.Info("Triggering refresh due to missing group.")
	go func() { s.updateWaiters <- ch }()
	// Do not block on update.
	return nil, accounts.GroupNameNotFound(name)
}
示例#3
0
// GroupByName satisfies AccountProvider.
func (s *cachingStore) GroupByName(name string) (*accounts.Group, error) {
	s.RLock()
	defer s.RUnlock()
	if name == sudoersGroupName {
		return s.sudoersGroup(), nil
	}
	g, ok := s.groupsByName[name]
	if ok {
		return g, nil
	}
	logger.Info("Triggering refresh due to missing group.")
	// Do not block on update.
	go func() { s.updateWaiters <- nil }()
	return nil, accounts.GroupNameNotFound(name)
}