qontract-reconcile 0.9.1rc268__py3-none-any.whl → 0.9.1rc269__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.9.1rc268
3
+ Version: 0.9.1rc269
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
@@ -173,6 +173,7 @@ reconcile/gql_definitions/cna/queries/cna_provisioners.py,sha256=MxCdDVZkB_tBYTV
173
173
  reconcile/gql_definitions/cna/queries/cna_resources.py,sha256=B8deNpCTpRDLuJIULT4zSArPocMTsYTdweOZj5wtGdc,2728
174
174
  reconcile/gql_definitions/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
175
175
  reconcile/gql_definitions/common/app_code_component_repos.py,sha256=kWjhUj-_BQCYIbzxGXVJA0UbrWmNc8QXqubqMo8kdqU,1853
176
+ reconcile/gql_definitions/common/app_interface_repo_settings.py,sha256=Pu2k0gTWQIg94CQCUEjyM3iE9CE6LGFSkXpWi_vrDI4,1758
176
177
  reconcile/gql_definitions/common/app_interface_state_settings.py,sha256=-u159W101xGOYM-MHD8PCrP6YNZ0CkiFOBFZ05Afyi0,2525
177
178
  reconcile/gql_definitions/common/app_interface_vault_settings.py,sha256=GEjbO_R9qSWy-tyLoSR8P1usQ3QPA8kxIofd507xJzs,1789
178
179
  reconcile/gql_definitions/common/clusters.py,sha256=qr8gnFH71pYUGijReg0NvaQ7LF8u3pRvp1wG_8a43ig,24303
@@ -257,7 +258,7 @@ reconcile/jenkins/types.py,sha256=-WMs4TsCEcbJNF_n-615Fealk08boBYZcTzVUk3Wlns,26
257
258
  reconcile/ocm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
258
259
  reconcile/ocm/types.py,sha256=gCuVra66cIk2Wvoj8PQ-hvsZiozFDFXxUOilPdC0w-c,3138
259
260
  reconcile/saas_auto_promotions_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
260
- reconcile/saas_auto_promotions_manager/integration.py,sha256=9_B8VmynFhlp5hgX5ZyIHO8wVkghTLcajurSUhpuhlw,6101
261
+ reconcile/saas_auto_promotions_manager/integration.py,sha256=EAQipdFjlwbKUENTlnd_UKoUYy3LHjRD9K-LXFOvFe0,6208
261
262
  reconcile/saas_auto_promotions_manager/publisher.py,sha256=gdzR7jNDKy130pO6J-UNwXI__EXgiREzdaXvNkE3Bhg,1845
262
263
  reconcile/saas_auto_promotions_manager/subscriber.py,sha256=JsS_wrCGZC3-86kHSUTq8veLpdGH6XFL_zqlXKx-eNk,5891
263
264
  reconcile/saas_auto_promotions_manager/merge_request_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -266,7 +267,7 @@ reconcile/saas_auto_promotions_manager/merge_request_manager/merge_request_manag
266
267
  reconcile/saas_auto_promotions_manager/merge_request_manager/renderer.py,sha256=Lfwii68Tiobk8bU1JYco3OosYAd0A-0lvyLtSykeCWk,4598
267
268
  reconcile/saas_auto_promotions_manager/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
268
269
  reconcile/saas_auto_promotions_manager/utils/saas_files_inventory.py,sha256=aQ-rVGjJfD0eAWFwU0ocOGTF5BHld-49yBwSmgKtUvg,8371
269
- reconcile/saas_auto_promotions_manager/utils/vcs.py,sha256=VJYAaf7mBpPpyKqL-qCXmWscPYSVrZHEdhQy31Wp3qI,5197
270
+ reconcile/saas_auto_promotions_manager/utils/vcs.py,sha256=wIB3DUazVpmysKuKmHZZ_yG9d04givRBulXrUuZyOgw,5240
270
271
  reconcile/skupper_network/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
271
272
  reconcile/skupper_network/integration.py,sha256=jF5uPhePnWq4axnxxarEQ_tw71WBxYoTZZUoi9JrZ6M,9831
272
273
  reconcile/skupper_network/models.py,sha256=5mTONziFFDx3NJamKzdCrVHXPNfQ6dYIlwxoSBeRihQ,11403
@@ -416,6 +417,7 @@ reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_mult
416
417
  reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_with_auto_promote.py,sha256=bGT1dlFk2NGOvAa1U4t4eNpWvVUxLMIFI-8sp0W_4nk,2643
417
418
  reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_without_auto_promote.py,sha256=6EYKmXDN9ckkMvdUBZlUiunCKuwQ9UmnPijKvXU8iZo,2170
418
419
  reconcile/typed_queries/__init__.py,sha256=rRk4CyslLsBr4vAh1pIPgt6s3P4R1M9NSEPLnyQgBpk,61
420
+ reconcile/typed_queries/app_interface_repo_url.py,sha256=ePr_nvjDeyZPR4sHsDQFubV2gslj9lPUSzIWWhm0syo,609
419
421
  reconcile/typed_queries/app_interface_state_settings.py,sha256=ytNAf3feg8JwmdCC4vO1WtVb-Ok5_ZtNAL3mXe2d1Pw,479
420
422
  reconcile/typed_queries/app_interface_vault_settings.py,sha256=N0GiRYDzlPipTOMM50ieR08BxsXaGAga6GxiIKjQDS8,1002
421
423
  reconcile/typed_queries/clusters.py,sha256=mjEudUxMl0pqT0CIbDhgRONLQqfhTvDPS4SVyl0zIpM,393
@@ -560,8 +562,8 @@ tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y
560
562
  tools/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
561
563
  tools/test/test_qontract_cli.py,sha256=awwTHEc2DWlykuqGIYM0WOBoSL0KRnOraCLk3C7izis,1401
562
564
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
563
- qontract_reconcile-0.9.1rc268.dist-info/METADATA,sha256=3TjHR7ZeexPt4pYZB7mBrqFis9R4dm9EO8XynkGF_ks,2287
564
- qontract_reconcile-0.9.1rc268.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
565
- qontract_reconcile-0.9.1rc268.dist-info/entry_points.txt,sha256=aIVvB7OTCxYu0QkONzBPfFEyg68Pr8KUVKEEm4ChDVc,333
566
- qontract_reconcile-0.9.1rc268.dist-info/top_level.txt,sha256=j0CHPIc8TsVRB50wOz_jhxjjaRyCJB3NOQeXhuHS67c,34
567
- qontract_reconcile-0.9.1rc268.dist-info/RECORD,,
565
+ qontract_reconcile-0.9.1rc269.dist-info/METADATA,sha256=VlnVDPpU3MlQuXOcadFEk2X00DdrPfEDbZYFqDDePgs,2287
566
+ qontract_reconcile-0.9.1rc269.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
567
+ qontract_reconcile-0.9.1rc269.dist-info/entry_points.txt,sha256=aIVvB7OTCxYu0QkONzBPfFEyg68Pr8KUVKEEm4ChDVc,333
568
+ qontract_reconcile-0.9.1rc269.dist-info/top_level.txt,sha256=j0CHPIc8TsVRB50wOz_jhxjjaRyCJB3NOQeXhuHS67c,34
569
+ qontract_reconcile-0.9.1rc269.dist-info/RECORD,,
@@ -0,0 +1,60 @@
1
+ """
2
+ Generated by qenerate plugin=pydantic_v1. DO NOT MODIFY MANUALLY!
3
+ """
4
+ from collections.abc import Callable # noqa: F401 # pylint: disable=W0611
5
+ from datetime import datetime # noqa: F401 # pylint: disable=W0611
6
+ from enum import Enum # noqa: F401 # pylint: disable=W0611
7
+ from typing import ( # noqa: F401 # pylint: disable=W0611
8
+ Any,
9
+ Optional,
10
+ Union,
11
+ )
12
+
13
+ from pydantic import ( # noqa: F401 # pylint: disable=W0611
14
+ BaseModel,
15
+ Extra,
16
+ Field,
17
+ Json,
18
+ )
19
+
20
+
21
+ DEFINITION = """
22
+ query AppInterfaceRepoSettings {
23
+ settings: app_interface_settings_v1 {
24
+ repoUrl
25
+ }
26
+ }
27
+ """
28
+
29
+
30
+ class ConfiguredBaseModel(BaseModel):
31
+ class Config:
32
+ smart_union = True
33
+ extra = Extra.forbid
34
+
35
+
36
+ class AppInterfaceSettingsV1(ConfiguredBaseModel):
37
+ repo_url: str = Field(..., alias="repoUrl")
38
+
39
+
40
+ class AppInterfaceRepoSettingsQueryData(ConfiguredBaseModel):
41
+ settings: Optional[list[AppInterfaceSettingsV1]] = Field(..., alias="settings")
42
+
43
+
44
+ def query(query_func: Callable, **kwargs: Any) -> AppInterfaceRepoSettingsQueryData:
45
+ """
46
+ This is a convenience function which queries and parses the data into
47
+ concrete types. It should be compatible with most GQL clients.
48
+ You do not have to use it to consume the generated data classes.
49
+ Alternatively, you can also mime and alternate the behavior
50
+ of this function in the caller.
51
+
52
+ Parameters:
53
+ query_func (Callable): Function which queries your GQL Server
54
+ kwargs: optional arguments that will be passed to the query function
55
+
56
+ Returns:
57
+ AppInterfaceRepoSettingsQueryData: queried data parsed into generated classes
58
+ """
59
+ raw_data: dict[Any, Any] = query_func(DEFINITION, **kwargs)
60
+ return AppInterfaceRepoSettingsQueryData(**raw_data)
@@ -21,6 +21,7 @@ from reconcile.saas_auto_promotions_manager.utils.saas_files_inventory import (
21
21
  SaasFilesInventory,
22
22
  )
23
23
  from reconcile.saas_auto_promotions_manager.utils.vcs import VCS
24
+ from reconcile.typed_queries.app_interface_repo_url import get_app_interface_repo_url
24
25
  from reconcile.typed_queries.app_interface_vault_settings import (
25
26
  get_app_interface_vault_settings,
26
27
  )
@@ -123,11 +124,11 @@ def init_external_dependencies(
123
124
  default=False,
124
125
  )
125
126
  secret_reader = create_secret_reader(use_vault=vault_settings.vault)
126
- gitlab_instances = get_gitlab_instances()
127
127
  vcs = VCS(
128
128
  secret_reader=secret_reader,
129
129
  github_orgs=get_github_orgs(),
130
- gitlab_instances=gitlab_instances,
130
+ gitlab_instances=get_gitlab_instances(),
131
+ app_interface_repo_url=get_app_interface_repo_url(),
131
132
  dry_run=dry_run,
132
133
  allow_deleting_mrs=allow_deleting_mrs,
133
134
  allow_opening_mrs=allow_opening_mrs,
@@ -33,6 +33,7 @@ class VCS:
33
33
  secret_reader: SecretReaderBase,
34
34
  github_orgs: Iterable[GithubOrgV1],
35
35
  gitlab_instances: Iterable[GitlabInstanceV1],
36
+ app_interface_repo_url: str,
36
37
  dry_run: bool,
37
38
  allow_deleting_mrs: bool,
38
39
  allow_opening_mrs: bool,
@@ -45,7 +46,8 @@ class VCS:
45
46
  self._default_gh_token = self._get_default_gh_token(github_orgs=github_orgs)
46
47
  self._gitlab_instance = self._gitlab_api(gitlab_instances=gitlab_instances)
47
48
  self._app_interface_api = self._init_app_interface_api(
48
- gitlab_instances=gitlab_instances
49
+ gitlab_instances=gitlab_instances,
50
+ app_interface_repo_url=app_interface_repo_url,
49
51
  )
50
52
  self._is_commit_sha_regex = re.compile(r"^[0-9a-f]{40}$")
51
53
 
@@ -91,12 +93,14 @@ class VCS:
91
93
  )
92
94
 
93
95
  def _init_app_interface_api(
94
- self, gitlab_instances: Iterable[GitlabInstanceV1]
96
+ self,
97
+ gitlab_instances: Iterable[GitlabInstanceV1],
98
+ app_interface_repo_url: str,
95
99
  ) -> GitLabApi:
96
100
  return GitLabApi(
97
101
  list(gitlab_instances)[0].dict(by_alias=True),
98
102
  secret_reader=self._secret_reader,
99
- project_url="https://gitlab.cee.redhat.com/service/app-interface",
103
+ project_url=app_interface_repo_url,
100
104
  )
101
105
 
102
106
  def get_commit_sha(
@@ -107,9 +111,8 @@ class VCS:
107
111
  if "github.com" in repo_url:
108
112
  github = self._init_github(repo_url=repo_url, auth_code=auth_code)
109
113
  return github.get_commit_sha(ref=ref)
110
- if "gitlab.cee" in repo_url:
111
- return self._gitlab_instance.get_commit_sha(ref=ref, repo_url=repo_url)
112
- raise RuntimeError(f"Unsupported Repo URL {repo_url}")
114
+ # assume gitlab by default
115
+ return self._gitlab_instance.get_commit_sha(ref=ref, repo_url=repo_url)
113
116
 
114
117
  def close_app_interface_mr(self, mr: ProjectMergeRequest, comment: str) -> None:
115
118
  if not self._dry_run and self._allow_deleting_mrs:
@@ -0,0 +1,16 @@
1
+ from collections.abc import Callable
2
+ from typing import Optional
3
+
4
+ from reconcile.gql_definitions.common.app_interface_repo_settings import query
5
+ from reconcile.utils import gql
6
+ from reconcile.utils.exceptions import AppInterfaceSettingsError
7
+
8
+
9
+ def get_app_interface_repo_url(query_func: Optional[Callable] = None) -> str:
10
+ if not query_func:
11
+ gqlapi = gql.get_api()
12
+ query_func = gqlapi.query
13
+ data = query(query_func=query_func)
14
+ if data.settings and len(data.settings) == 1:
15
+ return data.settings[0].repo_url
16
+ raise AppInterfaceSettingsError("repoUrl not uniquely defined")