Support for alternative user ids
Do not restrict on launchpad id only. Also allow github_id (for complimentary projects) and ldap_id (for OpenDayLight community) Closes bug 1411678 Change-Id: Ia811092cb6754e9d1dc28b0f3b55ccb1d04809b9
This commit is contained in:
parent
953ab3164c
commit
ec52ec1c78
|
@ -1623,6 +1623,17 @@
|
||||||
"user_name": "Cindy Pallares",
|
"user_name": "Cindy Pallares",
|
||||||
"emails": ["cindy.pallaresq@gmail.com", "cpallares@redhat.com", "cpallare@redhat.com"]
|
"emails": ["cindy.pallaresq@gmail.com", "cpallares@redhat.com", "cpallare@redhat.com"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"github_id": "cpuguy83",
|
||||||
|
"companies": [
|
||||||
|
{
|
||||||
|
"company_name": "Docker",
|
||||||
|
"end_date": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"user_name": "Brian Goff",
|
||||||
|
"emails": ["cpuguy83@gmail.com"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"launchpad_id": "craige",
|
"launchpad_id": "craige",
|
||||||
"companies": [
|
"companies": [
|
||||||
|
|
|
@ -12,9 +12,15 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^[a-z\\d\\.-]+$"
|
"pattern": "^[a-z\\d\\.-]+$"
|
||||||
},
|
},
|
||||||
|
"github_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"gerrit_id": {
|
"gerrit_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"ldap_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"user_name": {
|
"user_name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -44,7 +50,7 @@
|
||||||
"minItems": 1
|
"minItems": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["launchpad_id", "user_name", "emails"],
|
"required": ["user_name", "emails"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,6 +35,12 @@
|
||||||
{%if gerrit_id %}
|
{%if gerrit_id %}
|
||||||
<div>Gerrit: <a href="https://review.openstack.org/#/q/owner:${gerrit_id},n,z" target="_blank">${gerrit_id}</a></div>
|
<div>Gerrit: <a href="https://review.openstack.org/#/q/owner:${gerrit_id},n,z" target="_blank">${gerrit_id}</a></div>
|
||||||
{%/if%}
|
{%/if%}
|
||||||
|
{%if github_id %}
|
||||||
|
<div>Github: <a href="https://github.com/${github_id}" target="_blank">${github_id}</a></div>
|
||||||
|
{%/if%}
|
||||||
|
{%if ldap_id %}
|
||||||
|
<div>LDAP: ${ldap_id}</div>
|
||||||
|
{%/if%}
|
||||||
{%if core %}
|
{%if core %}
|
||||||
<div>Core in:
|
<div>Core in:
|
||||||
{%each( index, value ) core %}
|
{%each( index, value ) core %}
|
||||||
|
|
|
@ -40,7 +40,9 @@ def _normalize_user(user):
|
||||||
user['user_id'] = user_processor.make_user_id(
|
user['user_id'] = user_processor.make_user_id(
|
||||||
launchpad_id=user.get('launchpad_id'),
|
launchpad_id=user.get('launchpad_id'),
|
||||||
emails=user.get('emails'),
|
emails=user.get('emails'),
|
||||||
gerrit_id=user.get('gerrit_id'))
|
gerrit_id=user.get('gerrit_id'),
|
||||||
|
github_id=user.get('user_id'),
|
||||||
|
ldap_id=user.get('ldap_id'))
|
||||||
|
|
||||||
|
|
||||||
def _normalize_users(users):
|
def _normalize_users(users):
|
||||||
|
|
|
@ -180,8 +180,8 @@ class RecordProcessor(object):
|
||||||
merged_user = {} # merged user profile
|
merged_user = {} # merged user profile
|
||||||
|
|
||||||
# collect ordinary fields
|
# collect ordinary fields
|
||||||
for key in ['seq', 'user_name', 'user_id', 'gerrit_id',
|
for key in ['seq', 'user_name', 'user_id', 'gerrit_id', 'github_id',
|
||||||
'launchpad_id', 'companies', 'static']:
|
'launchpad_id', 'companies', 'static', 'ldap_id']:
|
||||||
value = next((v.get(key) for v in user_profiles if v.get(key)),
|
value = next((v.get(key) for v in user_profiles if v.get(key)),
|
||||||
None)
|
None)
|
||||||
if value:
|
if value:
|
||||||
|
|
|
@ -20,13 +20,17 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def make_user_id(emails=None, launchpad_id=None, gerrit_id=None,
|
def make_user_id(emails=None, launchpad_id=None, gerrit_id=None,
|
||||||
member_id=None):
|
member_id=None, github_id=None, ldap_id=None):
|
||||||
if launchpad_id or emails:
|
if launchpad_id or emails:
|
||||||
return launchpad_id or emails[0]
|
return launchpad_id or emails[0]
|
||||||
if gerrit_id:
|
if gerrit_id:
|
||||||
return 'gerrit:%s' % gerrit_id
|
return 'gerrit:%s' % gerrit_id
|
||||||
if member_id:
|
if member_id:
|
||||||
return 'member:%s' % member_id
|
return 'member:%s' % member_id
|
||||||
|
if github_id:
|
||||||
|
return 'github:%s' % github_id
|
||||||
|
if ldap_id:
|
||||||
|
return 'ldap:%s' % ldap_id
|
||||||
|
|
||||||
|
|
||||||
def store_user(runtime_storage_inst, user):
|
def store_user(runtime_storage_inst, user):
|
||||||
|
@ -54,16 +58,27 @@ def store_user(runtime_storage_inst, user):
|
||||||
if user.get('gerrit_id'):
|
if user.get('gerrit_id'):
|
||||||
runtime_storage_inst.set_by_key('user:gerrit:%s' % user['gerrit_id'],
|
runtime_storage_inst.set_by_key('user:gerrit:%s' % user['gerrit_id'],
|
||||||
user)
|
user)
|
||||||
|
if user.get('github_id'):
|
||||||
|
runtime_storage_inst.set_by_key('user:github:%s' % user['github_id'],
|
||||||
|
user)
|
||||||
|
if user.get('ldap_id'):
|
||||||
|
runtime_storage_inst.set_by_key('user:ldap:%s' % user['ldap_id'],
|
||||||
|
user)
|
||||||
for email in user.get('emails') or []:
|
for email in user.get('emails') or []:
|
||||||
runtime_storage_inst.set_by_key('user:%s' % email, user)
|
runtime_storage_inst.set_by_key('user:%s' % email, user)
|
||||||
|
|
||||||
|
|
||||||
def load_user(runtime_storage_inst, seq=None, user_id=None, email=None,
|
def load_user(runtime_storage_inst, seq=None, user_id=None, email=None,
|
||||||
launchpad_id=None, gerrit_id=None, member_id=None):
|
launchpad_id=None, gerrit_id=None, member_id=None,
|
||||||
|
github_id=None, ldap_id=None):
|
||||||
if gerrit_id:
|
if gerrit_id:
|
||||||
key = 'gerrit:%s' % gerrit_id
|
key = 'gerrit:%s' % gerrit_id
|
||||||
elif member_id:
|
elif member_id:
|
||||||
key = 'member:%s' % member_id
|
key = 'member:%s' % member_id
|
||||||
|
elif github_id:
|
||||||
|
key = 'github:%s' % github_id
|
||||||
|
elif ldap_id:
|
||||||
|
key = 'ldap:%s' % ldap_id
|
||||||
else:
|
else:
|
||||||
key = seq or user_id or launchpad_id or email
|
key = seq or user_id or launchpad_id or email
|
||||||
if key:
|
if key:
|
||||||
|
|
|
@ -80,8 +80,10 @@ class TestConfigFiles(testtools.TestCase):
|
||||||
def _verify_users_in_alphabetical_order(self, file_name):
|
def _verify_users_in_alphabetical_order(self, file_name):
|
||||||
users = self._read_file(file_name)['users']
|
users = self._read_file(file_name)['users']
|
||||||
self._verify_ordering(
|
self._verify_ordering(
|
||||||
users, key=lambda x: x['launchpad_id'],
|
users, key=lambda x: (x.get('launchpad_id') or x.get('ldap_id') or
|
||||||
msg='List of users should be ordered by launchpad id')
|
x.get('github_id')),
|
||||||
|
msg='List of users should be ordered by launchpad id or ldap id '
|
||||||
|
'or github id')
|
||||||
|
|
||||||
def test_users_in_alphabetical_order(self):
|
def test_users_in_alphabetical_order(self):
|
||||||
self._verify_users_in_alphabetical_order('etc/default_data.json')
|
self._verify_users_in_alphabetical_order('etc/default_data.json')
|
||||||
|
|
Loading…
Reference in New Issue