qontract-reconcile 0.10.1rc742__py3-none-any.whl → 0.10.1rc744__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc742
3
+ Version: 0.10.1rc744
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
@@ -114,7 +114,7 @@ reconcile/terraform_cloudflare_resources.py,sha256=EbQQaoDnZ7brvRCpbFtwlD7KLk2hD
114
114
  reconcile/terraform_cloudflare_users.py,sha256=1EbTHwJgiPkJpMP-Ag340QNgGK3mXn3dcC3DpLakudM,13987
115
115
  reconcile/terraform_repo.py,sha256=c0GZFuY3rCm6VHjHqYbsgOHrEkRWKF_1LrMThsn2XDw,16127
116
116
  reconcile/terraform_resources.py,sha256=BN8XuJwjOt1ztruEAHydkd0YiBlb3fHZ7n0snZtRhck,19356
117
- reconcile/terraform_tgw_attachments.py,sha256=6uIzRWLtFerQZ2yOygv54tGmXbXTvexnFnu_DSG2CNQ,16043
117
+ reconcile/terraform_tgw_attachments.py,sha256=k9Lf0ST65gmI6aUV6HnvxSGcKL7MGx_lN22OXuRGH9Y,16224
118
118
  reconcile/terraform_users.py,sha256=L921n4bD6-XbJeiiMKUI3quRacIkHlFEyvpi5Dcli_8,10374
119
119
  reconcile/terraform_vpc_peerings.py,sha256=rnDH1u93OyzrBM8Hib0HwSnlxZtx4ScRQaZAcn3mx-k,25402
120
120
  reconcile/vault_replication.py,sha256=79GZ_kCimPoQcxkdhkWTQxPOAa46E0mNhf05s_Mk5so,17385
@@ -663,7 +663,7 @@ reconcile/utils/throughput.py,sha256=iP4UWAe2LVhDo69mPPmgo9nQ7RxHD6_GS8MZe-aSiuM
663
663
  reconcile/utils/unleash.py,sha256=1D56CsZfE3ShDtN3IErE1T2eeIwNmxhK-yYbCotJ99E,3601
664
664
  reconcile/utils/vault.py,sha256=S0eHqvZ9N3fya1E8YDaUffEvLk_fdtpzL4rvWn6f828,14991
665
665
  reconcile/utils/vaultsecretref.py,sha256=3Ed2uBy36TzSvL0B-l4FoWQqB2SbBKDKEuUPIO608Bo,931
666
- reconcile/utils/vcs.py,sha256=o1r0n_IrU2El75CED_6sjR2GZGM-exuWsj5F7jONaMU,6779
666
+ reconcile/utils/vcs.py,sha256=uHFyYSHGpsdtiY76XVquq_5IzJTkkghBwWESeCJIeAw,8416
667
667
  reconcile/utils/acs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
668
668
  reconcile/utils/acs/base.py,sha256=kjcxLGIMe8oLNFOxZ_bDcClFqGCL7Auwug5is0yNGbw,2555
669
669
  reconcile/utils/acs/notifiers.py,sha256=2n5blP9N1FdGLZuy3do9bpjd8NKg88kmLNNqhAGn8w4,5013
@@ -777,8 +777,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
777
777
  tools/test/test_qontract_cli.py,sha256=w2l4BHB09k1d-BGJ1jBUNCqDv7zkqYrMHojQXg-21kQ,4155
778
778
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
779
779
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
780
- qontract_reconcile-0.10.1rc742.dist-info/METADATA,sha256=wi7RZmNJAfEGcpm4t3f_762yHlzo-7XlYEJUewqnUS4,2382
781
- qontract_reconcile-0.10.1rc742.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
782
- qontract_reconcile-0.10.1rc742.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
783
- qontract_reconcile-0.10.1rc742.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
784
- qontract_reconcile-0.10.1rc742.dist-info/RECORD,,
780
+ qontract_reconcile-0.10.1rc744.dist-info/METADATA,sha256=sIbstE_GcpNpldwcIVZDvFWxsYWgttSR6hyw9KGJai4,2382
781
+ qontract_reconcile-0.10.1rc744.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
782
+ qontract_reconcile-0.10.1rc744.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
783
+ qontract_reconcile-0.10.1rc744.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
784
+ qontract_reconcile-0.10.1rc744.dist-info/RECORD,,
@@ -39,6 +39,7 @@ from reconcile.typed_queries.terraform_tgw_attachments.aws_accounts import (
39
39
  from reconcile.utils import gql
40
40
  from reconcile.utils.aws_api import AWSApi
41
41
  from reconcile.utils.defer import defer
42
+ from reconcile.utils.disabled_integrations import integration_is_enabled
42
43
  from reconcile.utils.ocm import (
43
44
  OCM,
44
45
  OCMMap,
@@ -381,7 +382,12 @@ def _filter_tgw_accounts(
381
382
  ClusterPeeringConnectionAccountTGWV1, peer_connection
382
383
  )
383
384
  tgw_account_names.add(tgw_peer_connection.account.name)
384
- return [a for a in accounts if a.name in tgw_account_names]
385
+ return [
386
+ a
387
+ for a in accounts
388
+ if a.name in tgw_account_names
389
+ and integration_is_enabled(QONTRACT_INTEGRATION.replace("_", "-"), a)
390
+ ]
385
391
 
386
392
 
387
393
  def _fetch_desired_state_data_source(
reconcile/utils/vcs.py CHANGED
@@ -3,6 +3,8 @@ from __future__ import annotations
3
3
  import logging
4
4
  import re
5
5
  from collections.abc import Iterable
6
+ from dataclasses import dataclass
7
+ from datetime import datetime
6
8
  from enum import Enum
7
9
  from typing import Optional
8
10
 
@@ -29,6 +31,13 @@ class MRCheckStatus(Enum):
29
31
  RUNNING = 3
30
32
 
31
33
 
34
+ @dataclass(order=True)
35
+ class Commit:
36
+ repo: str
37
+ sha: str
38
+ date: datetime
39
+
40
+
32
41
  class VCS:
33
42
  """
34
43
  Abstraction layer for aggregating different Version Control Systems.
@@ -46,17 +55,20 @@ class VCS:
46
55
  gitlab_instances: Iterable[GitlabInstanceV1],
47
56
  app_interface_repo_url: str,
48
57
  dry_run: bool,
49
- allow_deleting_mrs: bool,
50
- allow_opening_mrs: bool,
58
+ allow_deleting_mrs: bool = False,
59
+ allow_opening_mrs: bool = False,
51
60
  gitlab_instance: Optional[GitLabApi] = None,
52
61
  default_gh_token: Optional[str] = None,
53
62
  app_interface_api: Optional[GitLabApi] = None,
63
+ github_api_per_repo_url: Optional[dict[str, GithubRepositoryApi]] = None,
54
64
  ):
55
65
  self._dry_run = dry_run
56
66
  self._allow_deleting_mrs = allow_deleting_mrs
57
67
  self._allow_opening_mrs = allow_opening_mrs
58
68
  self._secret_reader = secret_reader
59
- self._gh_per_repo_url: dict[str, GithubRepositoryApi] = {}
69
+ self._gh_per_repo_url: dict[str, GithubRepositoryApi] = (
70
+ {} if not github_api_per_repo_url else github_api_per_repo_url
71
+ )
60
72
  self._default_gh_token = (
61
73
  default_gh_token
62
74
  if default_gh_token
@@ -151,12 +163,48 @@ class VCS:
151
163
  ) -> str:
152
164
  if bool(self._is_commit_sha_regex.search(ref)):
153
165
  return ref
154
- if "github.com" in repo_url:
166
+ if repo_url.startswith("https://github.com/"):
155
167
  github = self._init_github(repo_url=repo_url, auth_code=auth_code)
156
168
  return github.get_commit_sha(ref=ref)
157
169
  # assume gitlab by default
158
170
  return self._gitlab_instance.get_commit_sha(ref=ref, repo_url=repo_url)
159
171
 
172
+ def get_commits_between(
173
+ self,
174
+ repo_url: str,
175
+ commit_from: str,
176
+ commit_to: str,
177
+ auth_code: Optional[HasSecret],
178
+ ) -> list[Commit]:
179
+ """
180
+ Return a list of commits between two commits.
181
+ Note, that the commit_to is included in the result list, whereas commit_from is not included.
182
+ """
183
+ if repo_url.startswith("https://github.com/"):
184
+ github = self._init_github(repo_url=repo_url, auth_code=auth_code)
185
+ data = github.compare(commit_from=commit_from, commit_to=commit_to)
186
+ return [
187
+ Commit(
188
+ repo=repo_url,
189
+ sha=gh_commit.sha,
190
+ date=gh_commit.commit.committer.date,
191
+ )
192
+ for gh_commit in data
193
+ ]
194
+ # assume gitlab by default
195
+ else:
196
+ data = self._gitlab_instance.repository_compare(
197
+ repo_url=repo_url, ref_from=commit_from, ref_to=commit_to
198
+ )
199
+ return [
200
+ Commit(
201
+ repo=repo_url,
202
+ sha=gl_commit["id"],
203
+ date=datetime.fromisoformat(gl_commit["committed_date"]),
204
+ )
205
+ for gl_commit in data
206
+ ]
207
+
160
208
  def close_app_interface_mr(self, mr: ProjectMergeRequest, comment: str) -> None:
161
209
  if not self._allow_deleting_mrs:
162
210
  logging.info("Deleting MRs is disabled. Skipping.")