qontract-reconcile 0.10.1rc874__py3-none-any.whl → 0.10.1rc876__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qontract_reconcile-0.10.1rc874.dist-info → qontract_reconcile-0.10.1rc876.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.1rc874.dist-info → qontract_reconcile-0.10.1rc876.dist-info}/RECORD +9 -9
- reconcile/gitlab_permissions.py +14 -3
- reconcile/terraform_vpc_resources/integration.py +3 -2
- reconcile/test/test_gitlab_permissions.py +22 -3
- reconcile/utils/gitlab_api.py +13 -7
- {qontract_reconcile-0.10.1rc874.dist-info → qontract_reconcile-0.10.1rc876.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.1rc874.dist-info → qontract_reconcile-0.10.1rc876.dist-info}/entry_points.txt +0 -0
- {qontract_reconcile-0.10.1rc874.dist-info → qontract_reconcile-0.10.1rc876.dist-info}/top_level.txt +0 -0
{qontract_reconcile-0.10.1rc874.dist-info → qontract_reconcile-0.10.1rc876.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: qontract-reconcile
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.1rc876
|
4
4
|
Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
|
5
5
|
Home-page: https://github.com/app-sre/qontract-reconcile
|
6
6
|
Author: Red Hat App-SRE Team
|
{qontract_reconcile-0.10.1rc874.dist-info → qontract_reconcile-0.10.1rc876.dist-info}/RECORD
RENAMED
@@ -35,7 +35,7 @@ reconcile/gitlab_labeler.py,sha256=IxE1XM5o4rDOFuR4cM2yAHTy4Uzdg3Nyz2mp7b8Fx1g,4
|
|
35
35
|
reconcile/gitlab_members.py,sha256=M6LwFOrwgvl1NNdOJa1mrQFUon-bEVv1AyhGeLed454,8443
|
36
36
|
reconcile/gitlab_mr_sqs_consumer.py,sha256=O46mdziPgGOndbU-0_UJKJVUaiEoVzJPEgKm4_UvYoI,2571
|
37
37
|
reconcile/gitlab_owners.py,sha256=sn9njaKOtqcvnhi2qtm-faAfAR4zNqflbSuusA9RUuI,13456
|
38
|
-
reconcile/gitlab_permissions.py,sha256=
|
38
|
+
reconcile/gitlab_permissions.py,sha256=rg0woLsVeKcG36AiK1FM2-TGeEf2A15LOreFPlo1OTk,3668
|
39
39
|
reconcile/gitlab_projects.py,sha256=K3tFf_aD1W4Ijp5q-9Qek3kwFGEWPcZ1kd7tzFJ4GyQ,1781
|
40
40
|
reconcile/integrations_manager.py,sha256=J_VV-HINI7YNav2NPIolePZkll-7VBuBXWAyMNhsM_Q,9535
|
41
41
|
reconcile/jenkins_base.py,sha256=0Gocu3fU2YTltaxBlbDQOUvP-7CP2OSQV1ZRwtWeVXw,875
|
@@ -472,7 +472,7 @@ reconcile/terraform_init/integration.py,sha256=xcFKTc_or3xB3kE_I3OECNkkgbwALIwwd
|
|
472
472
|
reconcile/terraform_init/merge_request.py,sha256=3CYtgSd7Q9zjKg4wsDz437EPCRfGeZZ8fZ0Y-ChKXJY,1475
|
473
473
|
reconcile/terraform_init/merge_request_manager.py,sha256=fMcT6hbdEF3nFATJpvr8BedvQHq_MzFkgVJSloBNwOQ,3101
|
474
474
|
reconcile/terraform_vpc_resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
475
|
-
reconcile/terraform_vpc_resources/integration.py,sha256=
|
475
|
+
reconcile/terraform_vpc_resources/integration.py,sha256=hQX5JWrC-MSwICs4FMJ_pbTa5eTQP6VrmE58z_XYclg,8204
|
476
476
|
reconcile/terraform_vpc_resources/merge_request.py,sha256=loRymUigCIvaaT0s_NzktZchh-DGRQnCICdBSCAcFPY,1503
|
477
477
|
reconcile/terraform_vpc_resources/merge_request_manager.py,sha256=Vj2nuQbQyrL4q_il1My-bLxYNh_r3YXqX45P8fwtP6Q,3259
|
478
478
|
reconcile/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -502,7 +502,7 @@ reconcile/test/test_github_repo_invites.py,sha256=UVaDlxSxi5iooyUbz8F11d7cvINHLK
|
|
502
502
|
reconcile/test/test_gitlab_housekeeping.py,sha256=Sn5rERCp28sMiBx5vJaQ5yy80y37GouMClejmXocsT8,10068
|
503
503
|
reconcile/test/test_gitlab_labeler.py,sha256=vFLUJXSIaCduj6wSqgw7Fg7FhlopaDnYI5SLzNHtLoY,4362
|
504
504
|
reconcile/test/test_gitlab_members.py,sha256=kaCOA02eZSrSMkzHmaLwWW3LY6Af0ciLSEP4PlMLvOU,9949
|
505
|
-
reconcile/test/test_gitlab_permissions.py,sha256=
|
505
|
+
reconcile/test/test_gitlab_permissions.py,sha256=vPFEsdjyP-lO8pc2rN6acMns3Sjz9YJs16msbBR8DZc,2736
|
506
506
|
reconcile/test/test_instrumented_wrappers.py,sha256=CZzhnQH0c4i7-Rxjg7-0dfFMvVPegLHL46z5NHOOCwo,608
|
507
507
|
reconcile/test/test_integrations_manager.py,sha256=l6KwSFT0NS9VSR-b_9z_ZEGXDWH3EMitUEMC_1h8Xkk,38184
|
508
508
|
reconcile/test/test_jenkins_worker_fleets.py,sha256=o1jlT7OBBSgu0M3iI4xMdz_x6SciF7yhNBpLk5gTJfg,2361
|
@@ -654,7 +654,7 @@ reconcile/utils/filtering.py,sha256=zZnHH0u0SaTDyzuFXZ_mREURGLvjEqQIQy4z-7QBVlc,
|
|
654
654
|
reconcile/utils/git.py,sha256=BdxXFgQ1XOZpS-4qb3qMsKTCFDG8MlE26rv1jAhvCkM,1560
|
655
655
|
reconcile/utils/git_secrets.py,sha256=0wGNL5mvDtVPRuu3vEQgld1Am64gIDJHtmu1_ZKxMAI,1973
|
656
656
|
reconcile/utils/github_api.py,sha256=_bttNxYKeam_tLVe27L7O4gKqSn6CeyuFnJn8tSaUVY,2488
|
657
|
-
reconcile/utils/gitlab_api.py,sha256=
|
657
|
+
reconcile/utils/gitlab_api.py,sha256=UGOm0FOzh4O6_DlAThp_Prj2bD9xsLMx5_xLm9Js0ZI,29248
|
658
658
|
reconcile/utils/gpg.py,sha256=EKG7_fdMv8BMlV5yUdPiqoTx-KrzmVSEAl2sLkaKwWI,1123
|
659
659
|
reconcile/utils/gql.py,sha256=o8TLe9zW_zf_vOYC4yAy7mP5UvSR4eq3JKa4rxy1KjI,14277
|
660
660
|
reconcile/utils/grouping.py,sha256=kWKivD14eAkiDneH_VIl_XyUdcVVQgiaKA9sLsuD2dw,441
|
@@ -837,8 +837,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
|
|
837
837
|
tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jrss,4941
|
838
838
|
tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
|
839
839
|
tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
|
840
|
-
qontract_reconcile-0.10.
|
841
|
-
qontract_reconcile-0.10.
|
842
|
-
qontract_reconcile-0.10.
|
843
|
-
qontract_reconcile-0.10.
|
844
|
-
qontract_reconcile-0.10.
|
840
|
+
qontract_reconcile-0.10.1rc876.dist-info/METADATA,sha256=oxwU_YgBkaunVNYBiF9X_96t_sVTbOp8dDhuBtvZjbc,2273
|
841
|
+
qontract_reconcile-0.10.1rc876.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
842
|
+
qontract_reconcile-0.10.1rc876.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
|
843
|
+
qontract_reconcile-0.10.1rc876.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
|
844
|
+
qontract_reconcile-0.10.1rc876.dist-info/RECORD,,
|
reconcile/gitlab_permissions.py
CHANGED
@@ -2,6 +2,7 @@ import itertools
|
|
2
2
|
import logging
|
3
3
|
from typing import Any
|
4
4
|
|
5
|
+
from gitlab.const import MAINTAINER_ACCESS
|
5
6
|
from sretoolbox.utils import threaded
|
6
7
|
|
7
8
|
from reconcile import queries
|
@@ -78,12 +79,22 @@ def share_project_with_group_members(
|
|
78
79
|
|
79
80
|
def share_project_with_group(gl: GitLabApi, repos: list[str], dry_run: bool) -> None:
|
80
81
|
# get repos not owned by app-sre
|
81
|
-
|
82
|
+
non_app_sre_project_repos = {repo for repo in repos if "/app-sre/" not in repo}
|
82
83
|
group_id, shared_projects = gl.get_group_id_and_shared_projects(APP_SRE_GROUP_NAME)
|
83
|
-
shared_project_repos =
|
84
|
-
repos_to_share =
|
84
|
+
shared_project_repos = shared_projects.keys()
|
85
|
+
repos_to_share = non_app_sre_project_repos - shared_project_repos
|
86
|
+
repos_to_reshare = {
|
87
|
+
repo
|
88
|
+
for repo in non_app_sre_project_repos
|
89
|
+
if (group_data := shared_projects.get(repo))
|
90
|
+
and group_data["group_access_level"] < MAINTAINER_ACCESS
|
91
|
+
}
|
85
92
|
for repo in repos_to_share:
|
86
93
|
gl.share_project_with_group(repo_url=repo, group_id=group_id, dry_run=dry_run)
|
94
|
+
for repo in repos_to_reshare:
|
95
|
+
gl.share_project_with_group(
|
96
|
+
repo_url=repo, group_id=group_id, dry_run=dry_run, reshare=True
|
97
|
+
)
|
87
98
|
|
88
99
|
|
89
100
|
def early_exit_desired_state(*args, **kwargs) -> dict[str, Any]:
|
@@ -72,8 +72,9 @@ class TerraformVpcResources(QontractReconcileIntegration[TerraformVpcResourcesPa
|
|
72
72
|
for request in requests:
|
73
73
|
# Skiping requests that don't have outputs,
|
74
74
|
# this happens because we are not filtering the requests
|
75
|
-
# when running the integration for a single account with --account-name
|
76
|
-
|
75
|
+
# when running the integration for a single account with --account-name.
|
76
|
+
# We also don't want to create outputs for deleted requets.
|
77
|
+
if request.account.name not in outputs.keys() or request.delete:
|
77
78
|
continue
|
78
79
|
|
79
80
|
outputs_per_request[request.identifier] = []
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from unittest.mock import MagicMock, create_autospec
|
2
2
|
|
3
3
|
import pytest
|
4
|
-
from gitlab.v4.objects import CurrentUser, GroupMember
|
4
|
+
from gitlab.v4.objects import CurrentUser, GroupMember
|
5
5
|
from pytest_mock import MockerFixture
|
6
6
|
|
7
7
|
from reconcile import gitlab_permissions
|
@@ -51,7 +51,26 @@ def test_run_share_with_group(
|
|
51
51
|
).return_value = True
|
52
52
|
mocked_gl.get_group_id_and_shared_projects.return_value = (
|
53
53
|
1234,
|
54
|
-
|
54
|
+
{"https://test.com": {"group_access_level": 30}},
|
55
55
|
)
|
56
56
|
gitlab_permissions.run(False, thread_pool_size=1)
|
57
|
-
mocked_gl.share_project_with_group.
|
57
|
+
mocked_gl.share_project_with_group.assert_called_once_with(
|
58
|
+
repo_url="https://test-gitlab.com", group_id=1234, dry_run=False
|
59
|
+
)
|
60
|
+
|
61
|
+
|
62
|
+
def test_run_reshare_with_group(
|
63
|
+
mocked_queries: MagicMock, mocker: MockerFixture, mocked_gl: MagicMock
|
64
|
+
) -> None:
|
65
|
+
mocker.patch("reconcile.gitlab_permissions.GitLabApi").return_value = mocked_gl
|
66
|
+
mocker.patch(
|
67
|
+
"reconcile.gitlab_permissions.get_feature_toggle_state"
|
68
|
+
).return_value = True
|
69
|
+
mocked_gl.get_group_id_and_shared_projects.return_value = (
|
70
|
+
1234,
|
71
|
+
{"https://test-gitlab.com": {"group_access_level": 30}},
|
72
|
+
)
|
73
|
+
gitlab_permissions.run(False, thread_pool_size=1)
|
74
|
+
mocked_gl.share_project_with_group.assert_called_once_with(
|
75
|
+
repo_url="https://test-gitlab.com", group_id=1234, dry_run=False, reshare=True
|
76
|
+
)
|
reconcile/utils/gitlab_api.py
CHANGED
@@ -29,7 +29,6 @@ from gitlab.const import (
|
|
29
29
|
from gitlab.v4.objects import (
|
30
30
|
CurrentUser,
|
31
31
|
Group,
|
32
|
-
GroupProject,
|
33
32
|
Project,
|
34
33
|
ProjectIssue,
|
35
34
|
ProjectMergeRequest,
|
@@ -259,7 +258,12 @@ class GitLabApi: # pylint: disable=too-many-public-methods
|
|
259
258
|
return None
|
260
259
|
|
261
260
|
def share_project_with_group(
|
262
|
-
self,
|
261
|
+
self,
|
262
|
+
repo_url: str,
|
263
|
+
group_id: int,
|
264
|
+
dry_run: bool,
|
265
|
+
access: str = "maintainer",
|
266
|
+
reshare: bool = False,
|
263
267
|
) -> None:
|
264
268
|
project = self.get_project(repo_url)
|
265
269
|
if project is None:
|
@@ -282,22 +286,24 @@ class GitLabApi: # pylint: disable=too-many-public-methods
|
|
282
286
|
return None
|
283
287
|
logging.info(["add_group_as_maintainer", repo_url, group_id])
|
284
288
|
if not dry_run:
|
289
|
+
if reshare:
|
290
|
+
gitlab_request.labels(integration=INTEGRATION_NAME).inc()
|
291
|
+
project.unshare(group_id)
|
285
292
|
gitlab_request.labels(integration=INTEGRATION_NAME).inc()
|
286
293
|
project.share(group_id, access_level)
|
287
294
|
|
288
295
|
def get_group_id_and_shared_projects(
|
289
296
|
self, group_name: str
|
290
|
-
) -> tuple[int,
|
297
|
+
) -> tuple[int, dict[str, Any]]:
|
291
298
|
gitlab_request.labels(integration=INTEGRATION_NAME).inc()
|
292
299
|
group = self.gl.groups.get(group_name)
|
293
300
|
shared_projects = self.get_items(group.projects.list, all=True)
|
294
|
-
return group.id,
|
295
|
-
project
|
301
|
+
return group.id, {
|
302
|
+
project.web_url: shared_group
|
296
303
|
for project in shared_projects
|
297
304
|
for shared_group in project.shared_with_groups
|
298
305
|
if shared_group["group_id"] == group.id
|
299
|
-
|
300
|
-
]
|
306
|
+
}
|
301
307
|
|
302
308
|
@staticmethod
|
303
309
|
def _is_bot_username(username: str) -> bool:
|
File without changes
|
File without changes
|
{qontract_reconcile-0.10.1rc874.dist-info → qontract_reconcile-0.10.1rc876.dist-info}/top_level.txt
RENAMED
File without changes
|