|
1 | 1 | from kubernetes import client, config
|
2 | 2 | import gitlab
|
3 | 3 |
|
4 |
| -g = gitlab.Gitlab(context["gitlab_url"] , private_token=context["gitlab_private_key"]) |
| 4 | +g = gitlab.Gitlab(context["gitlab_url"], |
| 5 | + private_token=context["gitlab_private_key"]) |
5 | 6 | gitlab_group = g.groups.get(context["gitlab_group"])
|
6 | 7 |
|
7 | 8 | config.load_incluster_config()
|
8 | 9 | custom_object_api = client.CustomObjectsApi()
|
9 | 10 | anarchy_subject_list = custom_object_api.list_namespaced_custom_object(
|
10 |
| - group="anarchy.gpte.redhat.com", |
11 |
| - version="v1", |
12 |
| - namespace=context["babylon_namespace"], |
13 |
| - plural="anarchysubjects", |
| 11 | + group="anarchy.gpte.redhat.com", |
| 12 | + version="v1", |
| 13 | + namespace=context["babylon_namespace"], |
| 14 | + plural="anarchysubjects", |
14 | 15 | )
|
15 | 16 |
|
16 |
| -def getAnarchySubject(project_id): |
17 |
| - subject = list(filter(lambda x: project_id in x["metadata"]["annotations"]["poolboy.gpte.redhat.com/resource-claim-name"], anarchy_subject_list["items"])) |
18 |
| - if len(subject) > 0: |
19 |
| - return subject[0] |
20 |
| - else: |
21 |
| - return None |
| 17 | + |
| 18 | +def getOCPAnarchySubject(project_id): |
| 19 | + subject = list(filter(lambda x: 'ocp4' in x["metadata"]["annotations"]["poolboy.gpte.redhat.com/resource-claim-name"] |
| 20 | + and project_id in x["metadata"]["annotations"]["poolboy.gpte.redhat.com/resource-claim-name"], anarchy_subject_list["items"])) |
| 21 | + if len(subject) > 0: |
| 22 | + return subject[0] |
| 23 | + else: |
| 24 | + return None |
| 25 | + |
22 | 26 |
|
23 | 27 | context["repositories"] = [
|
24 |
| - { |
25 |
| - "url": project.ssh_url_to_repo, |
26 |
| - "directory": str(project.id), |
27 |
| - "anarchy_subject": getAnarchySubject(str(project.id)) |
28 |
| - } |
29 |
| -for project in gitlab_group.projects.list(all=True, include_subgroups=True)] |
30 |
| - |
31 |
| -context["repositories"] = list(filter(lambda x: x["anarchy_subject"] is not None, context["repositories"])) |
| 28 | + { |
| 29 | + "url": project.ssh_url_to_repo, |
| 30 | + "directory": str(project.id), |
| 31 | + "ocp_anarchy_subject": getOCPAnarchySubject(str(project.id)) |
| 32 | + } |
| 33 | + for project in gitlab_group.projects.list(all=True, include_subgroups=True)] |
| 34 | + |
| 35 | +context["repositories"] = list( |
| 36 | + filter(lambda x: x["ocp_anarchy_subject"] is not None, context["repositories"])) |
32 | 37 |
|
33 | 38 | need_to_process = [element["directory"] for element in context["repositories"]]
|
34 | 39 |
|
|
0 commit comments