// hasRoles checks if the influx source has roles or not
190613
func (s *Service) hasRoles(ctx context.Context, ts chronograf.TimeSeries) (chronograf.RolesStore, bool) {
	store, err := ts.Roles(ctx)
	if err != nil {
		return nil, false
	}
	return store, true
}
160399
func (c *Client) Roles(ctx context.Context) (chronograf.RolesStore, error) {
	return nil, fmt.Errorf("roles not support in open-source InfluxDB.  Roles are support in Influx Enterprise")
}
971154
func (meta Meta) HasPermission(mode roles.PermissionMode, context *qor.Context) bool {
	if meta.Permission == nil {
		return true
	}
	var roles = []interface{}{}
	for _, role := range context.Roles {
		roles = append(roles, role)
	}
	return meta.Permission.HasPermission(mode, roles...)
}
381433
func (t *TimeSeries) Roles(ctx context.Context) (chronograf.RolesStore, error) {
	return t.RolesF(ctx)
}
640064
func (s *Principal) SetRoles(v []*PermissionInfo) *Principal {
	s.Roles = v
	return s
}
893018
func (db *Database) AddRole(role string, isAdmin bool) error {
	sec, err := db.GetSecurity()
	if err != nil {
		return err
	}
	roles := func() *[]string {
		if isAdmin {
			return &sec.Admins.Roles
		} else {
			return &sec.Members.Roles
		}
	}
	//Make sure the role isn't already there (couchdb will let you add it twice :/ )
	for _, r := range *roles() {
		if r == role {
			//already there, just return
			return nil
		}
	}
	rolesarr := roles()
	*rolesarr = append(*rolesarr, role)
	return db.SaveSecurity(*sec)
}
787861
func (p *MySQLPrivilege) FindRole(user string, host string, role *auth.RoleIdentity) bool {
	rec := p.matchUser(user, host)
	r := p.matchUser(role.Username, role.Hostname)
	if rec != nil && r != nil {
		key := rec.User + "@" + rec.Host
		return p.RoleGraph[key].Find(role.Username, role.Hostname)
	}
	return false
}
1051451
func (u *UserV2) AddRole(name string) {
	for _, r := range u.Spec.Roles {
		if r == name {
			return
		}
	}
	u.Spec.Roles = append(u.Spec.Roles, name)
}
575149
func (s *GetIdentityPoolRolesOutput) SetRoles(v map[string]*string) *GetIdentityPoolRolesOutput {
	s.Roles = v
	return s
}
551835
func (r roleResponse) asServerRole(ctx context.Context, c *client) (ServerRole, error) {
	switch r.Role {
	case "SINGLE":
		switch r.Mode {
		case "resilient":
			if err := c.echo(ctx); IsNoLeader(err) {
				return ServerRoleSinglePassive, nil
			} else if err != nil {
				return ServerRoleUndefined, WithStack(err)
			}
			return ServerRoleSingleActive, nil
		default:
			return ServerRoleSingle, nil
		}
	case "PRIMARY":
		return ServerRoleDBServer, nil
	case "COORDINATOR":
		return ServerRoleCoordinator, nil
	case "AGENT":
		return ServerRoleAgent, nil
	case "UNDEFINED":
		return ServerRoleUndefined, nil
	default:
		return ServerRoleUndefined, nil
	}
}
1138340
func (s *State) HasResources() bool {
	if s == nil {
		return false
	}
	for _, ms := range s.Modules {
		if len(ms.Resources) > 0 {
			return true
		}
	}
	return false
}
355959
func (rm *RoleManager) PrintRoles() error {
	line := ""
	rm.allRoles.Range(func(_, value interface{}) bool {
		if text := value.(*Role).toString(); text != "" {
			if line == "" {
				line = text
			} else {
				line += ", " + text
			}
		}
		return true
	})
	log.LogPrint(line)
	return nil
}
72038
func (m *MetaClient) UserRoles(ctx context.Context) (map[string]Roles, error) {
	res, err := m.Roles(ctx, nil)
	if err != nil {
		return nil, err
	}

	userRoles := make(map[string]Roles)
	for _, role := range res.Roles {
		for _, u := range role.Users {
			ur, ok := userRoles[u]
			if !ok {
				ur = Roles{}
			}
			ur.Roles = append(ur.Roles, role)
			userRoles[u] = ur
		}
	}
	return userRoles, nil
}
741953
func (r *repository) ListRoles() ([]RoleWithSignatures, error) {
	if err := r.updateTUF(false); err != nil {
		return nil, err
	}
	return NewReadOnly(r.tufRepo).ListRoles()
}
670608
func (r *reader) ListRoles() ([]RoleWithSignatures, error) {
	// Get all role info from our updated keysDB, can be empty
	roles := r.tufRepo.GetAllLoadedRoles()

	var roleWithSigs []RoleWithSignatures

	// Populate RoleWithSignatures with Role from keysDB and signatures from TUF metadata
	for _, role := range roles {
		roleWithSig := RoleWithSignatures{Role: *role, Signatures: nil}
		switch role.Name {
		case data.CanonicalRootRole:
			roleWithSig.Signatures = r.tufRepo.Root.Signatures
		case data.CanonicalTargetsRole:
			roleWithSig.Signatures = r.tufRepo.Targets[data.CanonicalTargetsRole].Signatures
		case data.CanonicalSnapshotRole:
			roleWithSig.Signatures = r.tufRepo.Snapshot.Signatures
		case data.CanonicalTimestampRole:
			roleWithSig.Signatures = r.tufRepo.Timestamp.Signatures
		default:
			if !data.IsDelegation(role.Name) {
				continue
			}
			if _, ok := r.tufRepo.Targets[role.Name]; ok {
				// We'll only find a signature if we've published any targets with this delegation
				roleWithSig.Signatures = r.tufRepo.Targets[role.Name].Signatures
			}
		}
		roleWithSigs = append(roleWithSigs, roleWithSig)
	}
	return roleWithSigs, nil
}
266496
func (m *Mounter) HasMounts(sourcePath string) int {
	m.Lock()
	defer m.Unlock()

	v, ok := m.mounts[sourcePath]
	if !ok {
		return 0
	}
	return len(v.Mountpoint)
}
919035
func hasOrganizationAdmin(roles *roles, organizatioName string) bool {
	for _, role := range roles.Role {
		if role.Name == "orgadmin" && role.Organization == organizatioName {
			return true
		}
	}

	return false
}