Return the list of (pkgdb) groups to which the user belongs.

    :arg config: a dict containing the fedmsg config
    :arg fas: a fedora.client.fas2.AccountSystem object instanciated and loged
        into FAS.
    :arg username: the name of a user for which we want to retrieve groups
    :return: a list of FAS groups to which the user belongs.

def get_groups_of_user(config, fas, username):
    ''' Return the list of (pkgdb) groups to which the user belongs.

    :arg config: a dict containing the fedmsg config
    :arg fas: a fedora.client.fas2.AccountSystem object instanciated and loged
        into FAS.
    :arg username: the name of a user for which we want to retrieve groups
    :return: a list of FAS groups to which the user belongs.
    '''

    if not _cache.is_configured:
        _cache.configure(**config['fmn.rules.cache'])

    key = cache_key_generator(get_groups_of_user, username)

    def creator():
        if not fas:
            return []
        results = []
        for group in fas.person_by_username(username).get('memberships', []):
            if group['group_type'] == 'pkgdb':
                results.append(group.name)
        return results

    return _cache.get_or_create(key, creator)