func NewCompoundDetector(locators ...interfaces.LDAPGroupDetector) interfaces.LDAPGroupDetector {
	return &CompoundDetector{locators: locators}
}
NewCompoundDetector returns an LDAPGroupDetector that subsumes some other LDAPGroupDetectors.
This detector checks all subordinate detectors in order to determine if a group exists. If any of
the subordinate detectors raise an error while being queried, the the search is abandoned and the
error returned. All detectors must successfully determine existence for the compound detector to
determine that the group exists.
package groupdetector
import (
	ldapquery "github.com/openshift/library-go/pkg/security/ldapquery"
	"github.com/redhat-cop/group-sync-operator/pkg/provider/ldap/helpers/interfaces"
)
func NewGroupBasedDetector(groupGetter interfaces.LDAPGroupGetter) interfaces.LDAPGroupDetector {
	return &GroupBasedDetector{groupGetter: groupGetter}
}
type GroupBasedDetector struct {
	groupGetter interfaces.LDAPGroupGetter
}
func (l *GroupBasedDetector) Exists(ldapGroupUID string) (bool, error) {
	group, err := l.groupGetter.GroupEntryFor(ldapGroupUID)
	if ldapquery.IsQueryOutOfBoundsError(err) || ldapquery.IsEntryNotFoundError(err) || ldapquery.IsNoSuchObjectError(err) {
		return false, nil
	}
	if err != nil {
		return false, err
	}
	if group == nil {
		return false, nil
	}
	return true, nil
}
func NewMemberBasedDetector(memberExtractor interfaces.LDAPMemberExtractor) interfaces.LDAPGroupDetector {
	return &MemberBasedDetector{memberExtractor: memberExtractor}
}
type MemberBasedDetector struct {
	memberExtractor interfaces.LDAPMemberExtractor
}
func (l *MemberBasedDetector) Exists(ldapGrouUID string) (bool, error) {
	members, err := l.memberExtractor.ExtractMembers(ldapGrouUID)
	if ldapquery.IsQueryOutOfBoundsError(err) || ldapquery.IsEntryNotFoundError(err) || ldapquery.IsNoSuchObjectError(err) {
		return false, nil
	}
	if err != nil {
		return false, err
	}
	if len(members) == 0 {
		return false, nil
	}
	return true, nil
}