[sysadmin-bin] Land a script that mainly generates a list of repositories and their associated maintainers (as take
- From: Andrea Veri <averi src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] Land a script that mainly generates a list of repositories and their associated maintainers (as take
- Date: Thu, 29 Jul 2021 13:43:13 +0000 (UTC)
commit 1d88c22374c7fb2ecc05e500a6277e32a7b308ac
Author: Andrea Veri <averi redhat com>
Date: Thu Jul 29 15:43:06 2021 +0200
Land a script that mainly generates a list of repositories and their associated maintainers (as taken
from ldapmain)
gitlab/gen-ldap-maint-list.py | 62 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
---
diff --git a/gitlab/gen-ldap-maint-list.py b/gitlab/gen-ldap-maint-list.py
new file mode 100755
index 0000000..57f429a
--- /dev/null
+++ b/gitlab/gen-ldap-maint-list.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python3
+
+import gitlab
+import json
+import sys
+
+exec(open("/home/admin/secret/gitlab_rw").read())
+
+gl = gitlab.Gitlab('https://gitlab.gnome.org', GITLAB_PRIVATE_RW_TOKEN, api_version=4)
+
+from optparse import OptionParser
+
+usage = "usage: %prog [options]"
+parser = OptionParser(usage)
+
+parser.add_option("--project_id", "-p",
+ action="store", type=int, dest="project_id",
+ help="GitLab Project ID")
+parser.add_option("--file-path", "-f",
+ action="store", type=str, dest="file_path",
+ help="Path to store the generated json file")
+
+(options, args) = parser.parse_args()
+
+def find_ldap_uid(gl_user_object):
+ user = gl.users.get(gl_user_object.attributes['id'])
+ if len(user.attributes['identities']) > 0:
+ for index, _ in enumerate(user.attributes['identities']):
+ provider = user.attributes['identities'][index]['provider']
+ if provider == 'ldapmain':
+ return user.attributes['identities'][index]['extern_uid'].split(',')[0].replace('uid=',
'')
+
+def gen_maints_list(gl_project_id, file_path):
+ result = {}
+
+ group = gl.groups.get(gl_project_id, with_projects=False)
+ projects = group.projects.list(all=True)
+
+ for p in projects:
+ _p = gl.projects.get(p.attributes['id'])
+ members = _p.members.list()
+
+ result[_p.attributes['path_with_namespace']] = {}
+ result[_p.attributes['path_with_namespace']]['maintainers'] = []
+
+ for maintainer in members:
+ if maintainer.attributes['access_level'] == 40:
+ result[_p.attributes['path_with_namespace']]['maintainers'].append(find_ldap_uid(maintainer))
+
+ with open(file_path, "w") as f:
+ json.dump(result, f)
+
+def main():
+ if len(sys.argv) == 1:
+ parser.print_help()
+ sys.exit(1)
+
+ gen_maints_list(options.project_id, options.file_path)
+
+
+if __name__ == "__main__":
+ main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]