qontract-reconcile 0.10.2.dev318__py3-none-any.whl → 0.10.2.dev319__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.2.dev318.dist-info → qontract_reconcile-0.10.2.dev319.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.2.dev318.dist-info → qontract_reconcile-0.10.2.dev319.dist-info}/RECORD +8 -8
- reconcile/terraform_vpc_peerings.py +1 -0
- reconcile/utils/ocm/ocm.py +81 -71
- reconcile/utils/ocm_base_client.py +4 -4
- reconcile/utils/raw_github_api.py +11 -8
- {qontract_reconcile-0.10.2.dev318.dist-info → qontract_reconcile-0.10.2.dev319.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.2.dev318.dist-info → qontract_reconcile-0.10.2.dev319.dist-info}/entry_points.txt +0 -0
{qontract_reconcile-0.10.2.dev318.dist-info → qontract_reconcile-0.10.2.dev319.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: qontract-reconcile
|
3
|
-
Version: 0.10.2.
|
3
|
+
Version: 0.10.2.dev319
|
4
4
|
Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
|
5
5
|
Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
|
6
6
|
Project-URL: repository, https://github.com/app-sre/qontract-reconcile
|
{qontract_reconcile-0.10.2.dev318.dist-info → qontract_reconcile-0.10.2.dev319.dist-info}/RECORD
RENAMED
@@ -111,7 +111,7 @@ reconcile/terraform_repo.py,sha256=vVJfaCV9775FGMMTHfoobaPetSlJMiQ4arNudL2pvh8,1
|
|
111
111
|
reconcile/terraform_resources.py,sha256=AXO3_Ehcg3I6ao7qiKzXC4Mk6BqwMoNooXU50c2zSTA,19555
|
112
112
|
reconcile/terraform_tgw_attachments.py,sha256=P2HivCjT5AlyODy-fu1qAK5355nDEArE8E4NQlIlF7U,18933
|
113
113
|
reconcile/terraform_users.py,sha256=xa-UK2iTy0HRFAGfFQvxTbBaypsqx3O0XGVWIU9yIxI,10659
|
114
|
-
reconcile/terraform_vpc_peerings.py,sha256=
|
114
|
+
reconcile/terraform_vpc_peerings.py,sha256=OMin9ica4_tpZxoDNUX72aO6IC_YgD3rfowJQeinaJY,27822
|
115
115
|
reconcile/vault_replication.py,sha256=trtbB-jDwca822J5I_s0zlwFtlyaiAtqgbPeqp7Cggc,17714
|
116
116
|
reconcile/vpc_peerings_validator.py,sha256=_77eu6DSy6VjTE5mhV-sOIVOGIiBvDEEDCdwwRdrgVQ,7101
|
117
117
|
reconcile/aus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -629,7 +629,7 @@ reconcile/utils/oc.py,sha256=c1O-qqKUNCgPrFNFCzVkgA0TCLY_vKpsaSY3XGMHpRg,65531
|
|
629
629
|
reconcile/utils/oc_connection_parameters.py,sha256=-H2crz0UOVKWlNrexf04ip8Vu57rE2QZLJuurvin1_c,9705
|
630
630
|
reconcile/utils/oc_filters.py,sha256=Tz3OwtbUaYKmxENFls5CtPVzkZDeFXknw53dJe-wbT8,1382
|
631
631
|
reconcile/utils/oc_map.py,sha256=ougQ-Wlsa8ymoE_lPQ7g2LlpsUOsHVeRCLYW_6fjeWU,8976
|
632
|
-
reconcile/utils/ocm_base_client.py,sha256=
|
632
|
+
reconcile/utils/ocm_base_client.py,sha256=niBN-yHiML5ljqKMOabFTaYW9iQ8JAway37BQF2NvtM,6713
|
633
633
|
reconcile/utils/openshift_resource.py,sha256=Nbte4oCzxL27Hrt2vNs2ybV3X3pV4vGJEnErEsiA6UY,24810
|
634
634
|
reconcile/utils/openssl.py,sha256=qdEdSmNXDgx_hhj2psEea6O12cmn3pb4GNhQJtI5l_E,399
|
635
635
|
reconcile/utils/output.py,sha256=wvsyf8NsFTaFHNkc8to75ta8f474Y4TMO4cHyAHEePk,2209
|
@@ -641,7 +641,7 @@ reconcile/utils/promotion_state.py,sha256=McSgGj3oog83ThJCrMR2v8q6Xb_Pxij-HEe_Rb
|
|
641
641
|
reconcile/utils/promtool.py,sha256=YnqwMAzsQVGuBZ1j9zy3UcVPFQVJgBMLzQkxhK_KFkU,3079
|
642
642
|
reconcile/utils/quay_api.py,sha256=ZWjfjzFnIsbKRDcdAnP9tWQezclf53I7VWZJ0gbF2kE,8260
|
643
643
|
reconcile/utils/quay_mirror.py,sha256=dpWCNv5lITwIk6Q9RkmqaQKHNk_JPy27UQEribJ7E-U,1324
|
644
|
-
reconcile/utils/raw_github_api.py,sha256=
|
644
|
+
reconcile/utils/raw_github_api.py,sha256=TlGfpitmqh_aX0V5b231TRQjuY2bAD6_FLvIA5P5a_o,3045
|
645
645
|
reconcile/utils/repo_owners.py,sha256=c6Z-U5TkiRPvuhr_zYWvZG9HZGzoT-l-d2PJ33lGflE,6507
|
646
646
|
reconcile/utils/rest_api_base.py,sha256=MT7tp6CQO2S5aKfVOzw_hipWg7wAGoOqkm4qurI1hEU,4342
|
647
647
|
reconcile/utils/rhcsv2_certs.py,sha256=ZnlUlEI2k6UrljGarkm1ey0znMlQtjeZB7VEfCH1A64,2545
|
@@ -726,7 +726,7 @@ reconcile/utils/ocm/identity_providers.py,sha256=dKed09N8iWmn39tI_MpwgVe47x23eLs
|
|
726
726
|
reconcile/utils/ocm/label_sources.py,sha256=ES_5VP4X6gsRxMFZ95WgbwE_HqqIUo_JRjHjdGYw6Ss,1846
|
727
727
|
reconcile/utils/ocm/labels.py,sha256=CmAgaOEPiaUb4gLtKab9vNkSDJceuREPd4ApgGcIA1U,6240
|
728
728
|
reconcile/utils/ocm/manifests.py,sha256=Q6kgOeiAwLbJY_vO_BEW2oePvbLDZcMZk20YpJJGpOA,1195
|
729
|
-
reconcile/utils/ocm/ocm.py,sha256=
|
729
|
+
reconcile/utils/ocm/ocm.py,sha256=1nBhA_h1SjTwCFF6aMMVRSDw0geg9vs0ul3WfnN2F_M,32748
|
730
730
|
reconcile/utils/ocm/products.py,sha256=UtWpkAvSMCxPOulEB7aV5ZY8ej_rmErlE_HVdm9Gnjk,26021
|
731
731
|
reconcile/utils/ocm/search_filters.py,sha256=09p4Wq1d1HGrDiinf1dmLJ46VtFhkkRCOL4V-N-zwjY,14808
|
732
732
|
reconcile/utils/ocm/service_log.py,sha256=RG1f0MMn6joKaRCAm2xveSJCavdOPP1BVo9FXecDxaI,2018
|
@@ -794,7 +794,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
794
794
|
tools/saas_promotion_state/saas_promotion_state.py,sha256=uQv2QJAmUXP1g2GPIH30WTlvL9soY6m9lefpZEVDM5w,3965
|
795
795
|
tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
|
796
796
|
tools/sre_checkpoints/util.py,sha256=KcYVfa3UmJHVP_ocgrKe8NkrO5IDB9aWEDydSokPcRk,975
|
797
|
-
qontract_reconcile-0.10.2.
|
798
|
-
qontract_reconcile-0.10.2.
|
799
|
-
qontract_reconcile-0.10.2.
|
800
|
-
qontract_reconcile-0.10.2.
|
797
|
+
qontract_reconcile-0.10.2.dev319.dist-info/METADATA,sha256=FNa6A7BaR7ZXxqf7JG1YpJbOmrGsQFwzlwruMjRnGys,24916
|
798
|
+
qontract_reconcile-0.10.2.dev319.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
799
|
+
qontract_reconcile-0.10.2.dev319.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
|
800
|
+
qontract_reconcile-0.10.2.dev319.dist-info/RECORD,,
|
@@ -73,6 +73,7 @@ def _build_infrastructure_assume_role(
|
|
73
73
|
ocm: OCM | None,
|
74
74
|
provided_assume_role: str | None,
|
75
75
|
) -> dict[str, Any] | None:
|
76
|
+
assume_role: str | None = None
|
76
77
|
if provided_assume_role:
|
77
78
|
assume_role = provided_assume_role
|
78
79
|
elif cluster["spec"].get("account"):
|
reconcile/utils/ocm/ocm.py
CHANGED
@@ -21,7 +21,7 @@ from reconcile.utils.ocm_base_client import (
|
|
21
21
|
from reconcile.utils.secret_reader import SecretReader
|
22
22
|
|
23
23
|
if TYPE_CHECKING:
|
24
|
-
from collections.abc import Mapping
|
24
|
+
from collections.abc import Iterable, Mapping, MutableMapping
|
25
25
|
|
26
26
|
from reconcile.ocm.types import OCMSpec
|
27
27
|
|
@@ -83,13 +83,13 @@ class OCM:
|
|
83
83
|
|
84
84
|
def __init__(
|
85
85
|
self,
|
86
|
-
name,
|
87
|
-
org_id,
|
86
|
+
name: str,
|
87
|
+
org_id: str,
|
88
88
|
ocm_env: str,
|
89
89
|
ocm_client: OCMBaseClient,
|
90
|
-
init_provision_shards=False,
|
91
|
-
init_addons=False,
|
92
|
-
init_version_gates=False,
|
90
|
+
init_provision_shards: bool = False,
|
91
|
+
init_addons: bool = False,
|
92
|
+
init_version_gates: bool = False,
|
93
93
|
product_portfolio: OCMProductPortfolio | None = None,
|
94
94
|
):
|
95
95
|
"""Initiates access token and gets clusters information."""
|
@@ -130,7 +130,7 @@ class OCM:
|
|
130
130
|
and cluster["product"]["id"] in self.product_portfolio.product_names
|
131
131
|
)
|
132
132
|
|
133
|
-
def _init_clusters(self, init_provision_shards: bool):
|
133
|
+
def _init_clusters(self, init_provision_shards: bool) -> None:
|
134
134
|
api = f"{CS_API_BASE}/v1/clusters"
|
135
135
|
product_csv = ",".join([f"'{p}'" for p in self.product_portfolio.product_names])
|
136
136
|
params = {
|
@@ -168,19 +168,19 @@ class OCM:
|
|
168
168
|
spec = impl.get_ocm_spec(self.ocm_api, cluster, init_provision_shards)
|
169
169
|
return spec
|
170
170
|
|
171
|
-
def create_cluster(self, name: str, cluster: OCMSpec, dry_run: bool):
|
171
|
+
def create_cluster(self, name: str, cluster: OCMSpec, dry_run: bool) -> None:
|
172
172
|
impl = self.get_product_impl(cluster.spec.product, cluster.spec.hypershift)
|
173
173
|
impl.create_cluster(self.ocm_api, self.org_id, name, cluster, dry_run)
|
174
174
|
|
175
175
|
def update_cluster(
|
176
|
-
self, cluster_name: str, update_spec: Mapping[str, Any], dry_run=False
|
177
|
-
):
|
176
|
+
self, cluster_name: str, update_spec: Mapping[str, Any], dry_run: bool = False
|
177
|
+
) -> None:
|
178
178
|
cluster = self.clusters[cluster_name]
|
179
179
|
cluster_id = self.cluster_ids[cluster_name]
|
180
180
|
impl = self.get_product_impl(cluster.spec.product, cluster.spec.hypershift)
|
181
181
|
impl.update_cluster(self.ocm_api, cluster_id, update_spec, dry_run)
|
182
182
|
|
183
|
-
def get_group_if_exists(self, cluster, group_id):
|
183
|
+
def get_group_if_exists(self, cluster: str, group_id: str) -> dict[str, Any] | None:
|
184
184
|
"""Returns a list of users in a group in a cluster.
|
185
185
|
If the group does not exist, None will be returned.
|
186
186
|
|
@@ -202,7 +202,7 @@ class OCM:
|
|
202
202
|
users = self._get_json(api).get("items", [])
|
203
203
|
return {"users": [u["id"] for u in users]}
|
204
204
|
|
205
|
-
def add_user_to_group(self, cluster, group_id, user):
|
205
|
+
def add_user_to_group(self, cluster: str, group_id: str, user: str) -> None:
|
206
206
|
"""
|
207
207
|
Adds a user to a group in a cluster.
|
208
208
|
|
@@ -218,7 +218,7 @@ class OCM:
|
|
218
218
|
api = f"{CS_API_BASE}/v1/clusters/{cluster_id}/" + f"groups/{group_id}/users"
|
219
219
|
self._post(api, {"id": user})
|
220
220
|
|
221
|
-
def del_user_from_group(self, cluster, group_id, user_id):
|
221
|
+
def del_user_from_group(self, cluster: str, group_id: str, user_id: str) -> None:
|
222
222
|
"""Deletes a user from a group in a cluster.
|
223
223
|
|
224
224
|
:param cluster: cluster name
|
@@ -250,7 +250,9 @@ class OCM:
|
|
250
250
|
switch_role_link = role_grants[0][-1]
|
251
251
|
return awsh.get_account_uid_from_role_link(switch_role_link)
|
252
252
|
|
253
|
-
def get_aws_infrastructure_access_role_grants(
|
253
|
+
def get_aws_infrastructure_access_role_grants(
|
254
|
+
self, cluster: str
|
255
|
+
) -> list[tuple[str, str, str, str]]:
|
254
256
|
"""Returns a list of AWS users (ARN, access level)
|
255
257
|
who have AWS infrastructure access in a cluster.
|
256
258
|
|
@@ -272,8 +274,8 @@ class OCM:
|
|
272
274
|
]
|
273
275
|
|
274
276
|
def get_aws_infrastructure_access_terraform_assume_role(
|
275
|
-
self, cluster, tf_account_id, tf_user
|
276
|
-
):
|
277
|
+
self, cluster: str, tf_account_id: str, tf_user: str | None
|
278
|
+
) -> str | None:
|
277
279
|
role_grants = self.get_aws_infrastructure_access_role_grants(cluster)
|
278
280
|
user_arn = f"arn:aws:iam::{tf_account_id}:user/{tf_user}"
|
279
281
|
for arn, role_id, _, console_url in role_grants:
|
@@ -288,9 +290,11 @@ class OCM:
|
|
288
290
|
role_name = role.replace("roleName=", "")
|
289
291
|
return f"arn:aws:iam::{role_account_id}:role/{role_name}"
|
290
292
|
|
293
|
+
return None
|
294
|
+
|
291
295
|
def add_user_to_aws_infrastructure_access_role_grants(
|
292
|
-
self, cluster, user_arn, access_level
|
293
|
-
):
|
296
|
+
self, cluster: str, user_arn: str, access_level: str
|
297
|
+
) -> None:
|
294
298
|
"""
|
295
299
|
Adds a user to AWS infrastructure access in a cluster.
|
296
300
|
|
@@ -310,8 +314,8 @@ class OCM:
|
|
310
314
|
self._post(api, {"user_arn": user_arn, "role": {"id": access_level}})
|
311
315
|
|
312
316
|
def del_user_from_aws_infrastructure_access_role_grants(
|
313
|
-
self, cluster, user_arn, access_level
|
314
|
-
):
|
317
|
+
self, cluster: str, user_arn: str, access_level: str
|
318
|
+
) -> None:
|
315
319
|
"""
|
316
320
|
Deletes a user from AWS infrastructure access in a cluster.
|
317
321
|
|
@@ -375,7 +379,9 @@ class OCM:
|
|
375
379
|
|
376
380
|
return results
|
377
381
|
|
378
|
-
def create_external_configuration_label(
|
382
|
+
def create_external_configuration_label(
|
383
|
+
self, cluster: str, label: dict[str, str]
|
384
|
+
) -> None:
|
379
385
|
"""Creates a new External Configuration label
|
380
386
|
|
381
387
|
:param cluster: cluster name
|
@@ -390,7 +396,9 @@ class OCM:
|
|
390
396
|
)
|
391
397
|
self._post(api, label)
|
392
398
|
|
393
|
-
def delete_external_configuration_label(
|
399
|
+
def delete_external_configuration_label(
|
400
|
+
self, cluster: str, label: Mapping[str, str]
|
401
|
+
) -> None:
|
394
402
|
"""Deletes an existing External Configuration label
|
395
403
|
|
396
404
|
:param cluster: cluster name
|
@@ -414,14 +422,9 @@ class OCM:
|
|
414
422
|
)
|
415
423
|
self._delete(api)
|
416
424
|
|
417
|
-
def get_machine_pools(self, cluster):
|
418
|
-
"""Returns a list of details of Machine Pools
|
419
|
-
|
420
|
-
:param cluster: cluster name
|
421
|
-
|
422
|
-
:type cluster: string
|
423
|
-
"""
|
424
|
-
results = []
|
425
|
+
def get_machine_pools(self, cluster: str) -> list[dict[str, Any]]:
|
426
|
+
"""Returns a list of details of Machine Pools"""
|
427
|
+
results: list[dict[str, Any]] = []
|
425
428
|
cluster_id = self.cluster_ids.get(cluster)
|
426
429
|
if not cluster_id:
|
427
430
|
return results
|
@@ -436,7 +439,7 @@ class OCM:
|
|
436
439
|
|
437
440
|
return results
|
438
441
|
|
439
|
-
def create_machine_pool(self, cluster, spec):
|
442
|
+
def create_machine_pool(self, cluster: str, spec: Mapping[str, Any]) -> None:
|
440
443
|
"""Creates a new Machine Pool
|
441
444
|
|
442
445
|
:param cluster: cluster name
|
@@ -449,7 +452,7 @@ class OCM:
|
|
449
452
|
api = f"{CS_API_BASE}/v1/clusters/{cluster_id}/machine_pools"
|
450
453
|
self._post(api, spec)
|
451
454
|
|
452
|
-
def update_machine_pool(self, cluster, spec):
|
455
|
+
def update_machine_pool(self, cluster: str, spec: MutableMapping[str, Any]) -> None:
|
453
456
|
"""Updates an existing Machine Pool
|
454
457
|
|
455
458
|
:param cluster: cluster name
|
@@ -460,7 +463,7 @@ class OCM:
|
|
460
463
|
"""
|
461
464
|
cluster_id = self.cluster_ids[cluster]
|
462
465
|
machine_pool_id = spec["id"]
|
463
|
-
labels = spec.get("labels", {})
|
466
|
+
labels: dict[str, str] = spec.get("labels", {})
|
464
467
|
spec["labels"] = labels
|
465
468
|
api = (
|
466
469
|
f"{CS_API_BASE}/v1/clusters/{cluster_id}/machine_pools/"
|
@@ -468,7 +471,7 @@ class OCM:
|
|
468
471
|
)
|
469
472
|
self._patch(api, spec)
|
470
473
|
|
471
|
-
def delete_machine_pool(self, cluster, spec):
|
474
|
+
def delete_machine_pool(self, cluster: str, spec: Mapping[str, Any]) -> None:
|
472
475
|
"""Deletes an existing Machine Pool
|
473
476
|
|
474
477
|
:param cluster: cluster name
|
@@ -485,21 +488,21 @@ class OCM:
|
|
485
488
|
)
|
486
489
|
self._delete(api)
|
487
490
|
|
488
|
-
def get_node_pools(self, cluster):
|
491
|
+
def get_node_pools(self, cluster: str) -> list[dict[str, Any]]:
|
489
492
|
"""Returns a list of details of Node Pools
|
490
493
|
|
491
494
|
:param cluster: cluster name
|
492
495
|
|
493
496
|
:type cluster: string
|
494
497
|
"""
|
495
|
-
results = []
|
498
|
+
results: list[dict[str, Any]] = []
|
496
499
|
cluster_id = self.cluster_ids.get(cluster)
|
497
500
|
if not cluster_id:
|
498
501
|
return results
|
499
502
|
|
500
503
|
return get_node_pools(self._ocm_client, cluster_id)
|
501
504
|
|
502
|
-
def delete_node_pool(self, cluster, spec):
|
505
|
+
def delete_node_pool(self, cluster: str, spec: Mapping[str, Any]) -> None:
|
503
506
|
"""Deletes an existing Node Pool
|
504
507
|
|
505
508
|
:param cluster: cluster name
|
@@ -513,7 +516,7 @@ class OCM:
|
|
513
516
|
api = f"{CS_API_BASE}/v1/clusters/{cluster_id}/node_pools/" + f"{node_pool_id}"
|
514
517
|
self._delete(api)
|
515
518
|
|
516
|
-
def create_node_pool(self, cluster, spec):
|
519
|
+
def create_node_pool(self, cluster: str, spec: Mapping[str, Any]) -> None:
|
517
520
|
"""Creates a new Node Pool
|
518
521
|
|
519
522
|
:param cluster: cluster name
|
@@ -526,7 +529,7 @@ class OCM:
|
|
526
529
|
api = f"{CS_API_BASE}/v1/clusters/{cluster_id}/node_pools"
|
527
530
|
self._post(api, spec)
|
528
531
|
|
529
|
-
def update_node_pool(self, cluster, spec):
|
532
|
+
def update_node_pool(self, cluster: str, spec: MutableMapping[str, Any]) -> None:
|
530
533
|
"""Updates an existing Node Pool
|
531
534
|
|
532
535
|
:param cluster: cluster name
|
@@ -537,19 +540,19 @@ class OCM:
|
|
537
540
|
"""
|
538
541
|
cluster_id = self.cluster_ids[cluster]
|
539
542
|
node_pool_id = spec["id"]
|
540
|
-
labels = spec.get("labels", {})
|
543
|
+
labels: dict[str, str] = spec.get("labels", {})
|
541
544
|
spec["labels"] = labels
|
542
545
|
api = f"{CS_API_BASE}/v1/clusters/{cluster_id}/node_pools/" + f"{node_pool_id}"
|
543
546
|
self._patch(api, spec)
|
544
547
|
|
545
|
-
def get_additional_routers(self, cluster):
|
548
|
+
def get_additional_routers(self, cluster: str) -> list[dict[str, Any]]:
|
546
549
|
"""Returns a list of Additional Application Routers
|
547
550
|
|
548
551
|
:param cluster: cluster name
|
549
552
|
|
550
553
|
:type cluster: string
|
551
554
|
"""
|
552
|
-
results = []
|
555
|
+
results: list[dict[str, Any]] = []
|
553
556
|
cluster_id = self.cluster_ids.get(cluster)
|
554
557
|
if not cluster_id:
|
555
558
|
return results
|
@@ -567,7 +570,7 @@ class OCM:
|
|
567
570
|
|
568
571
|
return results
|
569
572
|
|
570
|
-
def create_additional_router(self, cluster, spec):
|
573
|
+
def create_additional_router(self, cluster: str, spec: Mapping[str, Any]) -> None:
|
571
574
|
"""Creates a new Additional Application Router
|
572
575
|
|
573
576
|
:param cluster: cluster name
|
@@ -580,7 +583,7 @@ class OCM:
|
|
580
583
|
api = f"{CS_API_BASE}/v1/clusters/{cluster_id}/ingresses"
|
581
584
|
self._post(api, spec)
|
582
585
|
|
583
|
-
def delete_additional_router(self, cluster, spec):
|
586
|
+
def delete_additional_router(self, cluster: str, spec: Mapping[str, Any]) -> None:
|
584
587
|
"""Deletes an existing Additional Application Router
|
585
588
|
|
586
589
|
:param cluster: cluster name
|
@@ -594,19 +597,19 @@ class OCM:
|
|
594
597
|
api = f"{CS_API_BASE}/v1/clusters/{cluster_id}/" + f"ingresses/{router_id}"
|
595
598
|
self._delete(api)
|
596
599
|
|
597
|
-
def _init_addons(self):
|
600
|
+
def _init_addons(self) -> None:
|
598
601
|
"""Returns a list of Addons"""
|
599
602
|
api = f"{CS_API_BASE}/v1/addons"
|
600
603
|
self.addons = self._get_json(api).get("items", [])
|
601
604
|
|
602
|
-
def _init_version_gates(self):
|
605
|
+
def _init_version_gates(self) -> None:
|
603
606
|
"""Returns a list of version gates"""
|
604
607
|
if self.version_gates:
|
605
608
|
return
|
606
609
|
api = f"{CS_API_BASE}/v1/version_gates"
|
607
610
|
self.version_gates = self._get_json(api).get("items", [])
|
608
611
|
|
609
|
-
def get_addon(self, id):
|
612
|
+
def get_addon(self, id: str) -> dict[str, Any] | None:
|
610
613
|
for addon in self.addons:
|
611
614
|
addon_id = addon["id"]
|
612
615
|
if id == addon_id:
|
@@ -652,7 +655,7 @@ class OCM:
|
|
652
655
|
|
653
656
|
return results
|
654
657
|
|
655
|
-
def install_addon(self, cluster, spec):
|
658
|
+
def install_addon(self, cluster: str, spec: MutableMapping[str, Any]) -> None:
|
656
659
|
"""Installs an addon on a cluster
|
657
660
|
|
658
661
|
:param cluster: cluster name
|
@@ -714,21 +717,28 @@ class OCM:
|
|
714
717
|
return ret_items
|
715
718
|
return responses[0]
|
716
719
|
|
717
|
-
def _post(
|
720
|
+
def _post(
|
721
|
+
self,
|
722
|
+
api: str,
|
723
|
+
data: Mapping[str, Any] | None = None,
|
724
|
+
params: Mapping[str, str] | None = None,
|
725
|
+
) -> Any:
|
718
726
|
return self._ocm_client.post(
|
719
727
|
api_path=api,
|
720
728
|
data=data,
|
721
729
|
params=params,
|
722
730
|
)
|
723
731
|
|
724
|
-
def _patch(
|
732
|
+
def _patch(
|
733
|
+
self, api: str, data: Mapping[str, Any], params: Mapping[str, str] | None = None
|
734
|
+
) -> None:
|
725
735
|
return self._ocm_client.patch(
|
726
736
|
api_path=api,
|
727
737
|
data=data,
|
728
738
|
params=params,
|
729
739
|
)
|
730
740
|
|
731
|
-
def _delete(self, api):
|
741
|
+
def _delete(self, api: str) -> None:
|
732
742
|
return self._ocm_client.delete(
|
733
743
|
api_path=api,
|
734
744
|
)
|
@@ -762,14 +772,14 @@ class OCMMap:
|
|
762
772
|
|
763
773
|
def __init__(
|
764
774
|
self,
|
765
|
-
clusters=None,
|
766
|
-
namespaces=None,
|
767
|
-
ocms=None,
|
768
|
-
integration="",
|
769
|
-
settings=None,
|
770
|
-
init_provision_shards=False,
|
771
|
-
init_addons=False,
|
772
|
-
init_version_gates=False,
|
775
|
+
clusters: Iterable[Mapping[str, Any]] | None = None,
|
776
|
+
namespaces: Iterable[Mapping[str, Any]] | None = None,
|
777
|
+
ocms: Iterable[Mapping[str, Any]] | None = None,
|
778
|
+
integration: str = "",
|
779
|
+
settings: Mapping[str, Any] | None = None,
|
780
|
+
init_provision_shards: bool = False,
|
781
|
+
init_addons: bool = False,
|
782
|
+
init_version_gates: bool = False,
|
773
783
|
product_portfolio: OCMProductPortfolio | None = None,
|
774
784
|
) -> None:
|
775
785
|
"""Initiates OCM instances for each OCM referenced in a cluster."""
|
@@ -817,12 +827,12 @@ class OCMMap:
|
|
817
827
|
|
818
828
|
def init_ocm_client_from_cluster(
|
819
829
|
self,
|
820
|
-
cluster_info,
|
821
|
-
init_provision_shards,
|
822
|
-
init_addons,
|
823
|
-
init_version_gates,
|
830
|
+
cluster_info: Mapping[str, Any],
|
831
|
+
init_provision_shards: bool,
|
832
|
+
init_addons: bool,
|
833
|
+
init_version_gates: bool,
|
824
834
|
product_portfolio: OCMProductPortfolio | None = None,
|
825
|
-
):
|
835
|
+
) -> None:
|
826
836
|
if self.cluster_disabled(cluster_info):
|
827
837
|
return
|
828
838
|
cluster_name = cluster_info["name"]
|
@@ -842,12 +852,12 @@ class OCMMap:
|
|
842
852
|
|
843
853
|
def init_ocm_client(
|
844
854
|
self,
|
845
|
-
ocm_info,
|
846
|
-
init_provision_shards,
|
847
|
-
init_addons,
|
848
|
-
init_version_gates,
|
855
|
+
ocm_info: Mapping[str, Any],
|
856
|
+
init_provision_shards: bool,
|
857
|
+
init_addons: bool,
|
858
|
+
init_version_gates: bool,
|
849
859
|
product_portfolio: OCMProductPortfolio | None = None,
|
850
|
-
):
|
860
|
+
) -> None:
|
851
861
|
"""
|
852
862
|
Initiate OCM client.
|
853
863
|
Gets the OCM information and initiates an OCM client.
|
@@ -901,7 +911,7 @@ class OCMMap:
|
|
901
911
|
"""Get list of OCM instance names initiated in the OCM map."""
|
902
912
|
return list(self.ocm_map.keys())
|
903
913
|
|
904
|
-
def cluster_disabled(self, cluster_info):
|
914
|
+
def cluster_disabled(self, cluster_info: Mapping[str, Any]) -> bool:
|
905
915
|
"""
|
906
916
|
Checks if the calling integration is disabled in this cluster.
|
907
917
|
|
@@ -918,7 +928,7 @@ class OCMMap:
|
|
918
928
|
|
919
929
|
return False
|
920
930
|
|
921
|
-
def get(self, cluster) -> OCM:
|
931
|
+
def get(self, cluster: str) -> OCM:
|
922
932
|
"""
|
923
933
|
Gets an OCM instance by cluster.
|
924
934
|
|
@@ -49,7 +49,7 @@ class OCMBaseClient:
|
|
49
49
|
self._init_request_headers()
|
50
50
|
|
51
51
|
@retry()
|
52
|
-
def _init_access_token(self):
|
52
|
+
def _init_access_token(self) -> None:
|
53
53
|
data = {
|
54
54
|
"grant_type": "client_credentials",
|
55
55
|
"client_id": self._access_token_client_id,
|
@@ -61,7 +61,7 @@ class OCMBaseClient:
|
|
61
61
|
r.raise_for_status()
|
62
62
|
self._access_token = r.json().get("access_token")
|
63
63
|
|
64
|
-
def _init_request_headers(self):
|
64
|
+
def _init_request_headers(self) -> None:
|
65
65
|
self._session.headers.update({
|
66
66
|
"Authorization": f"Bearer {self._access_token}",
|
67
67
|
"accept": "application/json",
|
@@ -130,7 +130,7 @@ class OCMBaseClient:
|
|
130
130
|
api_path: str,
|
131
131
|
data: Mapping[str, Any],
|
132
132
|
params: Mapping[str, str] | None = None,
|
133
|
-
):
|
133
|
+
) -> None:
|
134
134
|
ocm_request.labels(verb="PATCH", client_id=self._access_token_client_id).inc()
|
135
135
|
r = self._session.patch(
|
136
136
|
f"{self._url}{api_path}",
|
@@ -144,7 +144,7 @@ class OCMBaseClient:
|
|
144
144
|
logging.error(r.text)
|
145
145
|
raise e
|
146
146
|
|
147
|
-
def delete(self, api_path: str):
|
147
|
+
def delete(self, api_path: str) -> None:
|
148
148
|
ocm_request.labels(verb="DELETE", client_id=self._access_token_client_id).inc()
|
149
149
|
r = self._session.delete(f"{self._url}{api_path}", timeout=REQUEST_TIMEOUT_SEC)
|
150
150
|
try:
|
@@ -1,8 +1,11 @@
|
|
1
1
|
import os
|
2
|
+
from typing import Any
|
2
3
|
|
3
4
|
import requests
|
4
5
|
from sretoolbox.utils import retry
|
5
6
|
|
7
|
+
Headers = dict[str, str | bytes | None]
|
8
|
+
|
6
9
|
|
7
10
|
class RawGithubApi:
|
8
11
|
"""
|
@@ -18,10 +21,10 @@ class RawGithubApi:
|
|
18
21
|
"application/vnd.github.dazzler-preview+json"
|
19
22
|
}
|
20
23
|
|
21
|
-
def __init__(self, password):
|
24
|
+
def __init__(self, password: str) -> None:
|
22
25
|
self.password = password
|
23
26
|
|
24
|
-
def headers(self, headers=None):
|
27
|
+
def headers(self, headers: Headers | None = None) -> Headers:
|
25
28
|
if headers is None:
|
26
29
|
headers = {}
|
27
30
|
new_headers = headers.copy()
|
@@ -29,13 +32,13 @@ class RawGithubApi:
|
|
29
32
|
new_headers["Authorization"] = "token %s" % (self.password,)
|
30
33
|
return new_headers
|
31
34
|
|
32
|
-
def patch(self, url):
|
35
|
+
def patch(self, url: str) -> requests.Response:
|
33
36
|
res = requests.patch(url, headers=self.headers(), timeout=60)
|
34
37
|
res.raise_for_status()
|
35
38
|
return res
|
36
39
|
|
37
40
|
@retry()
|
38
|
-
def query(self, url, headers=None):
|
41
|
+
def query(self, url: str, headers: Headers | None = None) -> Any:
|
39
42
|
if headers is None:
|
40
43
|
headers = {}
|
41
44
|
h = self.headers(headers)
|
@@ -64,7 +67,7 @@ class RawGithubApi:
|
|
64
67
|
|
65
68
|
return result
|
66
69
|
|
67
|
-
def org_invitations(self, org):
|
70
|
+
def org_invitations(self, org: str) -> list[str]:
|
68
71
|
invitations = self.query(f"/orgs/{org}/invitations")
|
69
72
|
|
70
73
|
return [
|
@@ -73,7 +76,7 @@ class RawGithubApi:
|
|
73
76
|
if login is not None
|
74
77
|
]
|
75
78
|
|
76
|
-
def team_invitations(self, org_id, team_id):
|
79
|
+
def team_invitations(self, org_id: str, team_id: str) -> list[str]:
|
77
80
|
invitations = self.query(f"/organizations/{org_id}/team/{team_id}/invitations")
|
78
81
|
|
79
82
|
return [
|
@@ -82,10 +85,10 @@ class RawGithubApi:
|
|
82
85
|
if login is not None
|
83
86
|
]
|
84
87
|
|
85
|
-
def repo_invitations(self):
|
88
|
+
def repo_invitations(self) -> list[dict[str, Any]]:
|
86
89
|
return self.query("/user/repository_invitations")
|
87
90
|
|
88
|
-
def accept_repo_invitation(self, invitation_id):
|
91
|
+
def accept_repo_invitation(self, invitation_id: int) -> None:
|
89
92
|
url = self.BASE_URL + f"/user/repository_invitations/{invitation_id}"
|
90
93
|
res = self.patch(url)
|
91
94
|
res.raise_for_status()
|
{qontract_reconcile-0.10.2.dev318.dist-info → qontract_reconcile-0.10.2.dev319.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|