qontract-reconcile 0.10.1rc884__py3-none-any.whl → 0.10.1rc885__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.
Files changed (276) hide show
  1. {qontract_reconcile-0.10.1rc884.dist-info → qontract_reconcile-0.10.1rc885.dist-info}/METADATA +1 -1
  2. {qontract_reconcile-0.10.1rc884.dist-info → qontract_reconcile-0.10.1rc885.dist-info}/RECORD +276 -276
  3. reconcile/acs_rbac.py +1 -2
  4. reconcile/aus/advanced_upgrade_service.py +14 -14
  5. reconcile/aus/aus_label_source.py +1 -2
  6. reconcile/aus/base.py +23 -26
  7. reconcile/aus/cluster_version_data.py +4 -4
  8. reconcile/aus/models.py +2 -3
  9. reconcile/aus/version_gate_approver.py +2 -6
  10. reconcile/aus/version_gates/__init__.py +1 -3
  11. reconcile/aus/version_gates/sts_version_gate_handler.py +2 -3
  12. reconcile/aws_account_manager/integration.py +2 -2
  13. reconcile/aws_ami_cleanup/integration.py +3 -4
  14. reconcile/aws_iam_password_reset.py +2 -5
  15. reconcile/aws_version_sync/integration.py +2 -2
  16. reconcile/blackbox_exporter_endpoint_monitoring.py +2 -5
  17. reconcile/change_owners/approver.py +4 -5
  18. reconcile/change_owners/bundle.py +20 -22
  19. reconcile/change_owners/change_types.py +23 -24
  20. reconcile/change_owners/changes.py +13 -16
  21. reconcile/change_owners/decision.py +2 -5
  22. reconcile/change_owners/diff.py +11 -15
  23. reconcile/change_owners/self_service_roles.py +1 -2
  24. reconcile/change_owners/tester.py +7 -10
  25. reconcile/checkpoint.py +2 -5
  26. reconcile/cli.py +9 -12
  27. reconcile/closedbox_endpoint_monitoring_base.py +8 -11
  28. reconcile/cluster_deployment_mapper.py +2 -5
  29. reconcile/cna/assets/asset.py +4 -7
  30. reconcile/cna/assets/null.py +2 -5
  31. reconcile/cna/integration.py +2 -3
  32. reconcile/cna/state.py +2 -5
  33. reconcile/dashdotdb_base.py +8 -11
  34. reconcile/dashdotdb_cso.py +3 -6
  35. reconcile/dashdotdb_dora.py +10 -14
  36. reconcile/dashdotdb_dvo.py +10 -13
  37. reconcile/dashdotdb_slo.py +5 -8
  38. reconcile/database_access_manager.py +5 -6
  39. reconcile/dynatrace_token_provider/integration.py +2 -5
  40. reconcile/external_resources/integration.py +1 -1
  41. reconcile/external_resources/manager.py +4 -4
  42. reconcile/external_resources/model.py +3 -3
  43. reconcile/external_resources/secrets_sync.py +5 -5
  44. reconcile/external_resources/state.py +5 -5
  45. reconcile/gabi_authorized_users.py +3 -6
  46. reconcile/gcr_mirror.py +1 -1
  47. reconcile/github_org.py +1 -3
  48. reconcile/github_repo_invites.py +2 -5
  49. reconcile/gitlab_housekeeping.py +7 -11
  50. reconcile/gitlab_labeler.py +1 -2
  51. reconcile/gitlab_members.py +2 -5
  52. reconcile/gitlab_permissions.py +1 -3
  53. reconcile/glitchtip/integration.py +2 -5
  54. reconcile/glitchtip_project_alerts/integration.py +3 -6
  55. reconcile/glitchtip_project_dsn/integration.py +4 -7
  56. reconcile/integrations_manager.py +5 -8
  57. reconcile/jenkins/types.py +5 -6
  58. reconcile/jenkins_job_builder.py +9 -12
  59. reconcile/jenkins_roles.py +1 -1
  60. reconcile/jira_watcher.py +2 -2
  61. reconcile/ldap_groups/integration.py +2 -5
  62. reconcile/ocm/types.py +21 -26
  63. reconcile/ocm_addons_upgrade_tests_trigger.py +3 -6
  64. reconcile/ocm_clusters.py +8 -8
  65. reconcile/ocm_internal_notifications/integration.py +1 -2
  66. reconcile/ocm_labels/integration.py +2 -5
  67. reconcile/ocm_machine_pools.py +11 -15
  68. reconcile/ocm_upgrade_scheduler_org_updater.py +2 -5
  69. reconcile/openshift_base.py +27 -29
  70. reconcile/openshift_groups.py +15 -20
  71. reconcile/openshift_namespace_labels.py +8 -14
  72. reconcile/openshift_namespaces.py +5 -8
  73. reconcile/openshift_network_policies.py +2 -4
  74. reconcile/openshift_resources_base.py +19 -29
  75. reconcile/openshift_saas_deploy.py +9 -10
  76. reconcile/openshift_saas_deploy_change_tester.py +7 -10
  77. reconcile/openshift_saas_deploy_trigger_base.py +4 -7
  78. reconcile/openshift_saas_deploy_trigger_cleaner.py +5 -8
  79. reconcile/openshift_saas_deploy_trigger_configs.py +1 -2
  80. reconcile/openshift_saas_deploy_trigger_images.py +1 -2
  81. reconcile/openshift_saas_deploy_trigger_moving_commits.py +1 -2
  82. reconcile/openshift_saas_deploy_trigger_upstream_jobs.py +1 -2
  83. reconcile/openshift_tekton_resources.py +7 -11
  84. reconcile/openshift_upgrade_watcher.py +10 -13
  85. reconcile/openshift_users.py +8 -11
  86. reconcile/oum/base.py +3 -4
  87. reconcile/oum/labelset.py +1 -2
  88. reconcile/oum/metrics.py +2 -2
  89. reconcile/oum/models.py +1 -2
  90. reconcile/oum/standalone.py +2 -3
  91. reconcile/prometheus_rules_tester/integration.py +6 -9
  92. reconcile/quay_membership.py +1 -2
  93. reconcile/quay_mirror.py +12 -13
  94. reconcile/quay_mirror_org.py +10 -10
  95. reconcile/queries.py +4 -7
  96. reconcile/resource_scraper.py +3 -4
  97. reconcile/rhidp/common.py +2 -2
  98. reconcile/saas_auto_promotions_manager/integration.py +5 -6
  99. reconcile/saas_auto_promotions_manager/merge_request_manager/batcher.py +1 -2
  100. reconcile/saas_auto_promotions_manager/publisher.py +5 -6
  101. reconcile/saas_auto_promotions_manager/subscriber.py +3 -4
  102. reconcile/saas_file_validator.py +2 -5
  103. reconcile/signalfx_endpoint_monitoring.py +2 -5
  104. reconcile/skupper_network/integration.py +3 -6
  105. reconcile/skupper_network/models.py +3 -5
  106. reconcile/slack_base.py +4 -7
  107. reconcile/slack_usergroups.py +15 -17
  108. reconcile/sql_query.py +5 -9
  109. reconcile/status_board.py +4 -5
  110. reconcile/statuspage/atlassian.py +14 -15
  111. reconcile/statuspage/integrations/maintenances.py +3 -3
  112. reconcile/statuspage/page.py +8 -8
  113. reconcile/statuspage/state.py +4 -5
  114. reconcile/statuspage/status.py +7 -8
  115. reconcile/templating/lib/rendering.py +8 -8
  116. reconcile/templating/renderer.py +10 -11
  117. reconcile/templating/validator.py +4 -4
  118. reconcile/terraform_aws_route53.py +3 -6
  119. reconcile/terraform_cloudflare_dns.py +9 -12
  120. reconcile/terraform_cloudflare_resources.py +9 -11
  121. reconcile/terraform_cloudflare_users.py +8 -11
  122. reconcile/terraform_init/integration.py +2 -2
  123. reconcile/terraform_repo.py +11 -14
  124. reconcile/terraform_resources.py +20 -21
  125. reconcile/terraform_tgw_attachments.py +32 -36
  126. reconcile/terraform_users.py +6 -7
  127. reconcile/terraform_vpc_resources/integration.py +5 -5
  128. reconcile/test/conftest.py +7 -10
  129. reconcile/test/fixtures.py +1 -1
  130. reconcile/test/saas_auto_promotions_manager/conftest.py +2 -2
  131. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/conftest.py +2 -2
  132. reconcile/test/test_database_access_manager.py +3 -6
  133. reconcile/test/test_gitlab_labeler.py +2 -5
  134. reconcile/test/test_jump_host.py +5 -8
  135. reconcile/test/test_ocm_machine_pools.py +1 -4
  136. reconcile/test/test_openshift_base.py +3 -6
  137. reconcile/test/test_openshift_cluster_bots.py +5 -5
  138. reconcile/test/test_openshift_namespace_labels.py +2 -3
  139. reconcile/test/test_openshift_saas_deploy_trigger_cleaner.py +2 -2
  140. reconcile/test/test_saasherder.py +9 -12
  141. reconcile/test/test_slack_base.py +4 -6
  142. reconcile/test/test_status_board.py +4 -7
  143. reconcile/test/test_terraform_tgw_attachments.py +14 -20
  144. reconcile/typed_queries/alerting_services_settings.py +1 -2
  145. reconcile/typed_queries/app_interface_custom_messages.py +2 -3
  146. reconcile/typed_queries/app_interface_deadmanssnitch_settings.py +1 -3
  147. reconcile/typed_queries/app_interface_repo_url.py +1 -2
  148. reconcile/typed_queries/app_interface_state_settings.py +1 -3
  149. reconcile/typed_queries/app_interface_vault_settings.py +1 -2
  150. reconcile/typed_queries/aws_vpc_requests.py +1 -3
  151. reconcile/typed_queries/aws_vpcs.py +1 -3
  152. reconcile/typed_queries/clusters.py +2 -4
  153. reconcile/typed_queries/clusters_minimal.py +1 -3
  154. reconcile/typed_queries/clusters_with_dms.py +1 -3
  155. reconcile/typed_queries/external_resources.py +3 -4
  156. reconcile/typed_queries/pagerduty_instances.py +1 -2
  157. reconcile/typed_queries/repos.py +2 -3
  158. reconcile/typed_queries/reserved_networks.py +1 -3
  159. reconcile/typed_queries/saas_files.py +49 -59
  160. reconcile/typed_queries/slo_documents.py +1 -3
  161. reconcile/typed_queries/status_board.py +3 -7
  162. reconcile/typed_queries/tekton_pipeline_providers.py +1 -2
  163. reconcile/typed_queries/terraform_namespaces.py +1 -2
  164. reconcile/typed_queries/terraform_tgw_attachments/aws_accounts.py +1 -3
  165. reconcile/utils/acs/base.py +2 -3
  166. reconcile/utils/acs/notifiers.py +3 -3
  167. reconcile/utils/acs/policies.py +3 -3
  168. reconcile/utils/aggregated_list.py +1 -1
  169. reconcile/utils/amtool.py +1 -2
  170. reconcile/utils/aws_api.py +28 -31
  171. reconcile/utils/binary.py +1 -3
  172. reconcile/utils/clusterhealth/providerbase.py +1 -2
  173. reconcile/utils/clusterhealth/telemeter.py +2 -2
  174. reconcile/utils/deadmanssnitch_api.py +1 -2
  175. reconcile/utils/disabled_integrations.py +4 -6
  176. reconcile/utils/environ.py +1 -1
  177. reconcile/utils/expiration.py +3 -7
  178. reconcile/utils/external_resource_spec.py +3 -4
  179. reconcile/utils/external_resources.py +4 -7
  180. reconcile/utils/filtering.py +1 -2
  181. reconcile/utils/git.py +3 -9
  182. reconcile/utils/git_secrets.py +5 -5
  183. reconcile/utils/github_api.py +5 -9
  184. reconcile/utils/gitlab_api.py +2 -3
  185. reconcile/utils/glitchtip/client.py +2 -4
  186. reconcile/utils/glitchtip/models.py +8 -11
  187. reconcile/utils/gql.py +26 -35
  188. reconcile/utils/grouping.py +1 -3
  189. reconcile/utils/imap_client.py +2 -5
  190. reconcile/utils/internal_groups/client.py +1 -2
  191. reconcile/utils/internal_groups/models.py +8 -9
  192. reconcile/utils/jenkins_api.py +4 -4
  193. reconcile/utils/jinja2/extensions.py +1 -1
  194. reconcile/utils/jinja2/filters.py +4 -4
  195. reconcile/utils/jinja2/utils.py +16 -16
  196. reconcile/utils/jira_client.py +10 -11
  197. reconcile/utils/jjb_client.py +14 -17
  198. reconcile/utils/jobcontroller/controller.py +5 -5
  199. reconcile/utils/jobcontroller/models.py +2 -2
  200. reconcile/utils/jsonpath.py +4 -5
  201. reconcile/utils/jump_host.py +7 -8
  202. reconcile/utils/keycloak.py +3 -7
  203. reconcile/utils/ldap_client.py +2 -3
  204. reconcile/utils/lean_terraform_client.py +13 -17
  205. reconcile/utils/membershipsources/app_interface_resolver.py +1 -1
  206. reconcile/utils/membershipsources/models.py +19 -22
  207. reconcile/utils/metrics.py +13 -15
  208. reconcile/utils/mr/base.py +7 -11
  209. reconcile/utils/mr/glitchtip_access_reporter.py +2 -2
  210. reconcile/utils/mr/notificator.py +1 -2
  211. reconcile/utils/oc.py +32 -38
  212. reconcile/utils/oc_connection_parameters.py +24 -25
  213. reconcile/utils/oc_filters.py +2 -3
  214. reconcile/utils/oc_map.py +9 -15
  215. reconcile/utils/ocm/addons.py +7 -10
  216. reconcile/utils/ocm/base.py +38 -39
  217. reconcile/utils/ocm/clusters.py +6 -9
  218. reconcile/utils/ocm/label_sources.py +1 -2
  219. reconcile/utils/ocm/labels.py +3 -6
  220. reconcile/utils/ocm/ocm.py +11 -14
  221. reconcile/utils/ocm/products.py +1 -3
  222. reconcile/utils/ocm/search_filters.py +16 -17
  223. reconcile/utils/ocm/service_log.py +2 -3
  224. reconcile/utils/ocm/sre_capability_labels.py +4 -8
  225. reconcile/utils/ocm/subscriptions.py +1 -3
  226. reconcile/utils/ocm/syncsets.py +2 -4
  227. reconcile/utils/ocm/upgrades.py +5 -9
  228. reconcile/utils/ocm_base_client.py +13 -16
  229. reconcile/utils/openshift_resource.py +5 -11
  230. reconcile/utils/output.py +2 -3
  231. reconcile/utils/pagerduty_api.py +4 -5
  232. reconcile/utils/prometheus.py +2 -2
  233. reconcile/utils/promotion_state.py +4 -5
  234. reconcile/utils/promtool.py +2 -8
  235. reconcile/utils/quay_api.py +12 -22
  236. reconcile/utils/raw_github_api.py +3 -5
  237. reconcile/utils/rosa/rosa_cli.py +6 -6
  238. reconcile/utils/rosa/session.py +6 -7
  239. reconcile/utils/runtime/desired_state_diff.py +3 -8
  240. reconcile/utils/runtime/environment.py +4 -7
  241. reconcile/utils/runtime/integration.py +4 -4
  242. reconcile/utils/runtime/meta.py +1 -2
  243. reconcile/utils/runtime/runner.py +7 -10
  244. reconcile/utils/runtime/sharding.py +22 -27
  245. reconcile/utils/saasherder/interfaces.py +63 -69
  246. reconcile/utils/saasherder/models.py +30 -35
  247. reconcile/utils/saasherder/saasherder.py +37 -53
  248. reconcile/utils/secret_reader.py +17 -19
  249. reconcile/utils/slack_api.py +15 -17
  250. reconcile/utils/smtp_client.py +1 -2
  251. reconcile/utils/sqs_gateway.py +1 -3
  252. reconcile/utils/state.py +1 -2
  253. reconcile/utils/terraform/config_client.py +4 -5
  254. reconcile/utils/terraform_client.py +3 -8
  255. reconcile/utils/terrascript/cloudflare_client.py +4 -10
  256. reconcile/utils/terrascript/cloudflare_resources.py +10 -13
  257. reconcile/utils/terrascript/models.py +2 -3
  258. reconcile/utils/terrascript/resources.py +1 -2
  259. reconcile/utils/terrascript_aws_client.py +30 -38
  260. reconcile/utils/unleash/client.py +4 -7
  261. reconcile/utils/unleash/server.py +2 -2
  262. reconcile/utils/vault.py +8 -11
  263. reconcile/utils/vaultsecretref.py +2 -3
  264. reconcile/utils/vcs.py +7 -8
  265. reconcile/vault_replication.py +4 -8
  266. reconcile/vpc_peerings_validator.py +4 -9
  267. release/version.py +6 -7
  268. tools/app_interface_reporter.py +2 -2
  269. tools/cli_commands/gpg_encrypt.py +3 -6
  270. tools/cli_commands/systems_and_tools.py +4 -7
  271. tools/qontract_cli.py +12 -17
  272. tools/template_validation.py +1 -1
  273. tools/test/conftest.py +3 -6
  274. {qontract_reconcile-0.10.1rc884.dist-info → qontract_reconcile-0.10.1rc885.dist-info}/WHEEL +0 -0
  275. {qontract_reconcile-0.10.1rc884.dist-info → qontract_reconcile-0.10.1rc885.dist-info}/entry_points.txt +0 -0
  276. {qontract_reconcile-0.10.1rc884.dist-info → qontract_reconcile-0.10.1rc885.dist-info}/top_level.txt +0 -0
reconcile/utils/oc.py CHANGED
@@ -17,7 +17,7 @@ from functools import wraps
17
17
  from io import TextIOWrapper
18
18
  from subprocess import Popen
19
19
  from threading import Lock
20
- from typing import Any, Optional, Union
20
+ from typing import Any
21
21
 
22
22
  import urllib3
23
23
  from kubernetes.client import ( # type: ignore[attr-defined]
@@ -157,7 +157,7 @@ class OCDecorators:
157
157
  @wraps(function)
158
158
  def wrapper(*args, **kwargs):
159
159
  result = function(*args, **kwargs)
160
- msg = result[:-1] if isinstance(result, (list, tuple)) else result
160
+ msg = result[:-1] if isinstance(result, list | tuple) else result
161
161
 
162
162
  if not isinstance(msg, OCProcessReconcileTimeDecoratorMsg):
163
163
  return result
@@ -211,7 +211,7 @@ class OCProcessReconcileTimeDecoratorMsg:
211
211
  self,
212
212
  namespace: str,
213
213
  resource: OR,
214
- server: Optional[str],
214
+ server: str | None,
215
215
  slow_oc_reconcile_threshold: float,
216
216
  is_log_slow_oc_reconcile: bool,
217
217
  ):
@@ -255,23 +255,23 @@ class OCCliApiResource:
255
255
  @property
256
256
  def group_version(self):
257
257
  if self.group:
258
- return "{}/{}".format(self.group, self.api_version)
258
+ return f"{self.group}/{self.api_version}"
259
259
  return self.api_version
260
260
 
261
261
 
262
262
  class OCCli: # pylint: disable=too-many-public-methods
263
263
  def __init__(
264
264
  self,
265
- cluster_name: Optional[str],
266
- server: Optional[str],
267
- token: Optional[str],
268
- jh: Optional[Mapping[Any, Any]] = None,
269
- settings: Optional[Mapping[Any, Any]] = None,
265
+ cluster_name: str | None,
266
+ server: str | None,
267
+ token: str | None,
268
+ jh: Mapping[Any, Any] | None = None,
269
+ settings: Mapping[Any, Any] | None = None,
270
270
  init_projects: bool = False,
271
271
  init_api_resources: bool = False,
272
272
  local: bool = False,
273
273
  insecure_skip_tls_verify: bool = False,
274
- connection_parameters: Optional[OCConnectionParameters] = None,
274
+ connection_parameters: OCConnectionParameters | None = None,
275
275
  ):
276
276
  """
277
277
  As of now we have to conform with 2 ways to initialize this client:
@@ -310,10 +310,10 @@ class OCCli: # pylint: disable=too-many-public-methods
310
310
  def _init_old_without_types(
311
311
  self,
312
312
  cluster_name: str,
313
- server: Optional[str],
314
- token: Optional[str],
315
- jh: Optional[Mapping[Any, Any]] = None,
316
- settings: Optional[Mapping[Any, Any]] = None,
313
+ server: str | None,
314
+ token: str | None,
315
+ jh: Mapping[Any, Any] | None = None,
316
+ settings: Mapping[Any, Any] | None = None,
317
317
  init_projects: bool = False,
318
318
  init_api_resources: bool = False,
319
319
  local: bool = False,
@@ -478,9 +478,7 @@ class OCCli: # pylint: disable=too-many-public-methods
478
478
  cmd.extend(["-n", namespace])
479
479
 
480
480
  if "labels" in kwargs:
481
- labels_list = [
482
- "{}={}".format(k, v) for k, v in kwargs.get("labels").items()
483
- ]
481
+ labels_list = [f"{k}={v}" for k, v in kwargs.get("labels").items()]
484
482
 
485
483
  cmd.append("-l")
486
484
  cmd.append(",".join(labels_list))
@@ -785,7 +783,7 @@ class OCCli: # pylint: disable=too-many-public-methods
785
783
  def get_service_account_username(user):
786
784
  namespace = user.split("/")[0]
787
785
  name = user.split("/")[1]
788
- return "system:serviceaccount:{}:{}".format(namespace, name)
786
+ return f"system:serviceaccount:{namespace}:{name}"
789
787
 
790
788
  def get_owned_pods(self, namespace, resource):
791
789
  pods = self.get(namespace, "Pod")["items"]
@@ -1222,15 +1220,15 @@ REQUEST_TIMEOUT = 60
1222
1220
  class OCNative(OCCli):
1223
1221
  def __init__(
1224
1222
  self,
1225
- cluster_name: Optional[str],
1226
- server: Optional[str],
1227
- token: Optional[str],
1228
- jh: Optional[Mapping[Any, Any]] = None,
1229
- settings: Optional[Mapping[Any, Any]] = None,
1223
+ cluster_name: str | None,
1224
+ server: str | None,
1225
+ token: str | None,
1226
+ jh: Mapping[Any, Any] | None = None,
1227
+ settings: Mapping[Any, Any] | None = None,
1230
1228
  init_projects: bool = False,
1231
1229
  local: bool = False,
1232
1230
  insecure_skip_tls_verify: bool = False,
1233
- connection_parameters: Optional[OCConnectionParameters] = None,
1231
+ connection_parameters: OCConnectionParameters | None = None,
1234
1232
  ):
1235
1233
  super().__init__(
1236
1234
  cluster_name,
@@ -1335,9 +1333,7 @@ class OCNative(OCCli):
1335
1333
 
1336
1334
  labels = ""
1337
1335
  if "labels" in kwargs:
1338
- labels_list = [
1339
- "{}={}".format(k, v) for k, v in kwargs.get("labels").items()
1340
- ]
1336
+ labels_list = [f"{k}={v}" for k, v in kwargs.get("labels").items()]
1341
1337
 
1342
1338
  labels = ",".join(labels_list)
1343
1339
 
@@ -1395,7 +1391,7 @@ class OCNative(OCCli):
1395
1391
  raise StatusCodeError(f"[{self.server}]: {e}")
1396
1392
 
1397
1393
 
1398
- OCClient = Union[OCNative, OCCli]
1394
+ OCClient = OCNative | OCCli
1399
1395
 
1400
1396
 
1401
1397
  class OCLocal(OCCli):
@@ -1423,16 +1419,16 @@ class OC:
1423
1419
 
1424
1420
  def __new__(
1425
1421
  cls,
1426
- cluster_name: Optional[str] = None,
1427
- server: Optional[str] = None,
1428
- token: Optional[str] = None,
1429
- jh: Optional[Mapping[Any, Any]] = None,
1430
- settings: Optional[Mapping[Any, Any]] = None,
1422
+ cluster_name: str | None = None,
1423
+ server: str | None = None,
1424
+ token: str | None = None,
1425
+ jh: Mapping[Any, Any] | None = None,
1426
+ settings: Mapping[Any, Any] | None = None,
1431
1427
  init_projects: bool = False,
1432
1428
  init_api_resources: bool = False,
1433
1429
  local: bool = False,
1434
1430
  insecure_skip_tls_verify: bool = False,
1435
- connection_parameters: Optional[OCConnectionParameters] = None,
1431
+ connection_parameters: OCConnectionParameters | None = None,
1436
1432
  ):
1437
1433
  use_native_env = os.environ.get("USE_NATIVE_CLIENT", "")
1438
1434
  use_native = True
@@ -1865,7 +1861,5 @@ class OpenshiftLazyDiscoverer(LazyDiscoverer):
1865
1861
  if len(results) == 1:
1866
1862
  return results[0]
1867
1863
  if not results:
1868
- raise ResourceNotFoundError("No matches found for {}".format(kwargs))
1869
- raise ResourceNotUniqueError(
1870
- "Multiple matches found for {}: {}".format(kwargs, results)
1871
- )
1864
+ raise ResourceNotFoundError(f"No matches found for {kwargs}")
1865
+ raise ResourceNotUniqueError(f"Multiple matches found for {kwargs}: {results}")
@@ -4,7 +4,6 @@ import logging
4
4
  from collections.abc import Iterable
5
5
  from dataclasses import dataclass
6
6
  from typing import (
7
- Optional,
8
7
  Protocol,
9
8
  runtime_checkable,
10
9
  )
@@ -23,13 +22,13 @@ class OCConnectionError(Exception):
23
22
 
24
23
 
25
24
  class Disable(Protocol):
26
- integrations: Optional[list[str]]
25
+ integrations: list[str] | None
27
26
 
28
27
 
29
28
  class Jumphost(Protocol):
30
29
  hostname: str
31
- port: Optional[int]
32
- remote_port: Optional[int]
30
+ port: int | None
31
+ remote_port: int | None
33
32
  known_hosts: str
34
33
  user: str
35
34
 
@@ -41,24 +40,24 @@ class Jumphost(Protocol):
41
40
  class Cluster(Protocol):
42
41
  name: str
43
42
  server_url: str
44
- internal: Optional[bool]
45
- insecure_skip_tls_verify: Optional[bool]
43
+ internal: bool | None
44
+ insecure_skip_tls_verify: bool | None
46
45
 
47
46
  @property
48
- def jump_host(self) -> Optional[Jumphost]: ...
47
+ def jump_host(self) -> Jumphost | None: ...
49
48
 
50
49
  @property
51
- def automation_token(self) -> Optional[HasSecret]: ...
50
+ def automation_token(self) -> HasSecret | None: ...
52
51
 
53
52
  @property
54
- def cluster_admin_automation_token(self) -> Optional[HasSecret]: ...
53
+ def cluster_admin_automation_token(self) -> HasSecret | None: ...
55
54
 
56
55
  @property
57
- def disable(self) -> Optional[Disable]: ...
56
+ def disable(self) -> Disable | None: ...
58
57
 
59
58
 
60
59
  class Namespace(Protocol):
61
- cluster_admin: Optional[bool]
60
+ cluster_admin: bool | None
62
61
 
63
62
  @property
64
63
  def cluster(self) -> Cluster: ...
@@ -82,20 +81,20 @@ class OCConnectionParameters:
82
81
 
83
82
  cluster_name: str
84
83
  server_url: str
85
- is_internal: Optional[bool]
84
+ is_internal: bool | None
86
85
  is_cluster_admin: bool
87
- skip_tls_verify: Optional[bool]
88
- automation_token: Optional[str]
89
- cluster_admin_automation_token: Optional[str]
86
+ skip_tls_verify: bool | None
87
+ automation_token: str | None
88
+ cluster_admin_automation_token: str | None
90
89
  disabled_integrations: list[str]
91
- jumphost_hostname: Optional[str]
92
- jumphost_known_hosts: Optional[str]
93
- jumphost_user: Optional[str]
94
- jumphost_port: Optional[int]
95
- jumphost_key: Optional[str]
96
- jumphost_remote_port: Optional[int]
90
+ jumphost_hostname: str | None
91
+ jumphost_known_hosts: str | None
92
+ jumphost_user: str | None
93
+ jumphost_port: int | None
94
+ jumphost_key: str | None
95
+ jumphost_remote_port: int | None
97
96
  # The local port is currently calculated and set outside of this class
98
- jumphost_local_port: Optional[int]
97
+ jumphost_local_port: int | None
99
98
 
100
99
  @staticmethod
101
100
  def _get_token_verify_server_url(secret: ClusterSecret, cluster: Cluster) -> str:
@@ -112,7 +111,7 @@ class OCConnectionParameters:
112
111
  @staticmethod
113
112
  def _get_automation_token(
114
113
  secret_reader: SecretReaderBase, secret: HasSecret, cluster: Cluster
115
- ) -> Optional[str]:
114
+ ) -> str | None:
116
115
  secret_raw = secret_reader.read_all_secret(secret)
117
116
  return OCConnectionParameters._get_token_verify_server_url(
118
117
  ClusterSecret(
@@ -130,8 +129,8 @@ class OCConnectionParameters:
130
129
  cluster_admin: bool,
131
130
  use_jump_host: bool = True,
132
131
  ) -> OCConnectionParameters:
133
- automation_token: Optional[str] = None
134
- cluster_admin_automation_token: Optional[str] = None
132
+ automation_token: str | None = None
133
+ cluster_admin_automation_token: str | None = None
135
134
 
136
135
  if cluster_admin:
137
136
  if cluster.cluster_admin_automation_token:
@@ -1,6 +1,5 @@
1
1
  from collections.abc import Iterable
2
2
  from typing import (
3
- Optional,
4
3
  Protocol,
5
4
  TypeVar,
6
5
  )
@@ -34,8 +33,8 @@ def filter_namespaces_by_name(
34
33
 
35
34
  def filter_namespaces_by_cluster_and_namespace(
36
35
  namespaces: Iterable[NS],
37
- cluster_names: Optional[Iterable[str]],
38
- namespace_names: Optional[Iterable[str]],
36
+ cluster_names: Iterable[str] | None,
37
+ namespace_names: Iterable[str] | None,
39
38
  ) -> list[NS]:
40
39
  """
41
40
  Filter namespaces by cluster and namespace name.
reconcile/utils/oc_map.py CHANGED
@@ -1,10 +1,6 @@
1
1
  import logging
2
2
  from collections.abc import Iterable
3
3
  from threading import Lock
4
- from typing import (
5
- Optional,
6
- Union,
7
- )
8
4
 
9
5
  from sretoolbox.utils import threaded
10
6
 
@@ -41,15 +37,15 @@ class OCMap:
41
37
  self,
42
38
  connection_parameters: Iterable[OCConnectionParameters],
43
39
  integration: str = "",
44
- internal: Optional[bool] = None,
40
+ internal: bool | None = None,
45
41
  use_jump_host: bool = True,
46
42
  thread_pool_size: int = 1,
47
43
  init_projects: bool = False,
48
44
  init_api_resources: bool = False,
49
- oc_cls: Optional[type[OC]] = None,
45
+ oc_cls: type[OC] | None = None,
50
46
  ):
51
- self._oc_map: dict[str, Union[OCCli, OCLogMsg]] = {}
52
- self._privileged_oc_map: dict[str, Union[OCCli, OCLogMsg]] = {}
47
+ self._oc_map: dict[str, OCCli | OCLogMsg] = {}
48
+ self._privileged_oc_map: dict[str, OCCli | OCLogMsg] = {}
53
49
  self._calling_integration = integration
54
50
  self._internal = internal
55
51
  self._use_jump_host = use_jump_host
@@ -126,7 +122,7 @@ class OCMap:
126
122
  connection_parameters=connection_parameters
127
123
  )
128
124
  try:
129
- oc_client: Union[OCCli, OCLogMsg] = self._oc_cls(
125
+ oc_client: OCCli | OCLogMsg = self._oc_cls(
130
126
  connection_parameters=connection_parameters,
131
127
  init_projects=self._init_projects,
132
128
  init_api_resources=self._init_api_resources,
@@ -142,9 +138,7 @@ class OCMap:
142
138
  privileged,
143
139
  )
144
140
 
145
- def _set_oc(
146
- self, cluster: str, value: Union[OCCli, OCLogMsg], privileged: bool
147
- ) -> None:
141
+ def _set_oc(self, cluster: str, value: OCCli | OCLogMsg, privileged: bool) -> None:
148
142
  with self._lock:
149
143
  if privileged:
150
144
  self._privileged_oc_map[cluster] = value
@@ -160,7 +154,7 @@ class OCMap:
160
154
  pass
161
155
  return False
162
156
 
163
- def get(self, cluster: str, privileged: bool = False) -> Union[OCCli, OCLogMsg]:
157
+ def get(self, cluster: str, privileged: bool = False) -> OCCli | OCLogMsg:
164
158
  cluster_map = self._privileged_oc_map if privileged else self._oc_map
165
159
  return cluster_map.get(
166
160
  cluster,
@@ -200,7 +194,7 @@ def init_oc_map_from_clusters(
200
194
  clusters: Iterable[Cluster],
201
195
  secret_reader: SecretReaderBase,
202
196
  integration: str = "",
203
- internal: Optional[bool] = None,
197
+ internal: bool | None = None,
204
198
  use_jump_host: bool = True,
205
199
  thread_pool_size: int = 1,
206
200
  init_projects: bool = False,
@@ -231,7 +225,7 @@ def init_oc_map_from_namespaces(
231
225
  namespaces: Iterable[Namespace],
232
226
  secret_reader: SecretReaderBase,
233
227
  integration: str = "",
234
- internal: Optional[bool] = None,
228
+ internal: bool | None = None,
235
229
  use_jump_host: bool = True,
236
230
  thread_pool_size: int = 1,
237
231
  init_projects: bool = False,
@@ -1,7 +1,4 @@
1
- from typing import (
2
- Any,
3
- Optional,
4
- )
1
+ from typing import Any
5
2
 
6
3
  from reconcile.utils.ocm.base import (
7
4
  OCMAddonInstallation,
@@ -26,7 +23,7 @@ class AddonService:
26
23
  ocm_api: OCMBaseClient,
27
24
  cluster_id: str,
28
25
  addon_latest_versions: dict[str, str],
29
- required_state: Optional[str],
26
+ required_state: str | None,
30
27
  ) -> list[OCMAddonInstallation]:
31
28
  """
32
29
  Returns a list of Addons installed on a cluster
@@ -37,7 +34,7 @@ class AddonService:
37
34
  :param required_state: only return addons with this state
38
35
  """
39
36
 
40
- params: Optional[dict[str, Any]] = None
37
+ params: dict[str, Any] | None = None
41
38
  if required_state:
42
39
  params = {"search": f"state='{required_state}'"}
43
40
 
@@ -58,7 +55,7 @@ class AddonService:
58
55
  raise NotImplementedError()
59
56
 
60
57
  def get_addon_upgrade_policies(
61
- self, ocm_api: OCMBaseClient, cluster_id: str, addon_id: Optional[str] = None
58
+ self, ocm_api: OCMBaseClient, cluster_id: str, addon_id: str | None = None
62
59
  ) -> list[OCMAddonUpgradePolicy]:
63
60
  raise NotImplementedError()
64
61
 
@@ -88,7 +85,7 @@ class AddonServiceV1(AddonService):
88
85
  return "/api/clusters_mgmt/v1"
89
86
 
90
87
  def get_addon_upgrade_policies(
91
- self, ocm_api: OCMBaseClient, cluster_id: str, addon_id: Optional[str] = None
88
+ self, ocm_api: OCMBaseClient, cluster_id: str, addon_id: str | None = None
92
89
  ) -> list[OCMAddonUpgradePolicy]:
93
90
  results: list[OCMAddonUpgradePolicy] = []
94
91
 
@@ -118,7 +115,7 @@ class AddonServiceV1(AddonService):
118
115
 
119
116
  def _get_addon_upgrade_policy_state(
120
117
  self, ocm_api: OCMBaseClient, cluster_id: str, addon_upgrade_policy_id: str
121
- ) -> Optional[str]:
118
+ ) -> str | None:
122
119
  try:
123
120
  state_data = ocm_api.get(
124
121
  f"{self.addon_base_api_path()}/clusters/{cluster_id}/addon_upgrade_policies/{addon_upgrade_policy_id}/state"
@@ -171,7 +168,7 @@ class AddonServiceV2(AddonService):
171
168
  return "/api/addons_mgmt/v1"
172
169
 
173
170
  def get_addon_upgrade_policies(
174
- self, ocm_api: OCMBaseClient, cluster_id: str, addon_id: Optional[str] = None
171
+ self, ocm_api: OCMBaseClient, cluster_id: str, addon_id: str | None = None
175
172
  ) -> list[OCMAddonUpgradePolicy]:
176
173
  results: list[OCMAddonUpgradePolicy] = []
177
174
 
@@ -2,9 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  from collections.abc import Iterable
4
4
  from datetime import datetime
5
- from enum import Enum
5
+ from enum import Enum, StrEnum
6
6
  from typing import (
7
- Optional,
8
7
  TypeVar,
9
8
  )
10
9
 
@@ -22,8 +21,8 @@ CAPABILITY_MANAGE_CLUSTER_ADMIN = "capability.cluster.manage_cluster_admin"
22
21
 
23
22
 
24
23
  class OCMCollectionLink(BaseModel):
25
- kind: Optional[str] = None
26
- href: Optional[str] = None
24
+ kind: str | None = None
25
+ href: str | None = None
27
26
 
28
27
 
29
28
  class OCMModelLink(OCMCollectionLink):
@@ -76,7 +75,7 @@ class OCMClusterUser(BaseModel):
76
75
  The id represents the user name.
77
76
  """
78
77
 
79
- href: Optional[str] = None
78
+ href: str | None = None
80
79
  kind: str = "User"
81
80
 
82
81
 
@@ -86,7 +85,7 @@ class OCMClusterUserList(BaseModel):
86
85
  """
87
86
 
88
87
  kind: str = "UserList"
89
- href: Optional[str] = None
88
+ href: str | None = None
90
89
  items: list[OCMClusterUser]
91
90
 
92
91
 
@@ -96,8 +95,8 @@ class OCMClusterGroup(BaseModel):
96
95
  """
97
96
 
98
97
  id: OCMClusterGroupId
99
- href: Optional[str] = None
100
- users: Optional[OCMClusterUserList] = None
98
+ href: str | None = None
99
+ users: OCMClusterUserList | None = None
101
100
 
102
101
  def user_ids(self) -> set[str]:
103
102
  """
@@ -135,16 +134,16 @@ class OCMClusterAWSOperatorRole(BaseModel):
135
134
 
136
135
 
137
136
  class OCMAWSSTS(OCMClusterFlag):
138
- role_arn: Optional[str]
139
- support_role_arn: Optional[str]
140
- oidc_endpoint_url: Optional[str]
141
- operator_iam_roles: Optional[list[OCMClusterAWSOperatorRole]]
142
- instance_iam_roles: Optional[dict[str, str]]
143
- operator_role_prefix: Optional[str]
137
+ role_arn: str | None
138
+ support_role_arn: str | None
139
+ oidc_endpoint_url: str | None
140
+ operator_iam_roles: list[OCMClusterAWSOperatorRole] | None
141
+ instance_iam_roles: dict[str, str] | None
142
+ operator_role_prefix: str | None
144
143
 
145
144
 
146
145
  class OCMClusterAWSSettings(BaseModel):
147
- sts: Optional[OCMAWSSTS]
146
+ sts: OCMAWSSTS | None
148
147
 
149
148
  @property
150
149
  def sts_enabled(self) -> bool:
@@ -168,7 +167,7 @@ class OCMClusterAWSSettings(BaseModel):
168
167
  return roles
169
168
 
170
169
  @property
171
- def account_role_prefix(self) -> Optional[str]:
170
+ def account_role_prefix(self) -> str | None:
172
171
  INSTALLER_ROLE_BASE_NAME = "-Installer-Role"
173
172
  installer_role_arn = self.sts.role_arn if self.sts else None
174
173
  if installer_role_arn and installer_role_arn.endswith(INSTALLER_ROLE_BASE_NAME):
@@ -231,19 +230,19 @@ class OCMCluster(BaseModel):
231
230
  product: OCMModelLink
232
231
  identity_providers: OCMCollectionLink
233
232
 
234
- aws: Optional[OCMClusterAWSSettings]
233
+ aws: OCMClusterAWSSettings | None
235
234
 
236
235
  version: OCMClusterVersion
237
236
 
238
237
  hypershift: OCMClusterFlag
239
238
 
240
- console: Optional[OCMClusterConsole]
239
+ console: OCMClusterConsole | None
241
240
 
242
- api: Optional[OCMClusterAPI]
241
+ api: OCMClusterAPI | None
243
242
 
244
- dns: Optional[OCMClusterDns]
243
+ dns: OCMClusterDns | None
245
244
 
246
- external_configuration: Optional[OCMExternalConfiguration]
245
+ external_configuration: OCMExternalConfiguration | None
247
246
 
248
247
  def minor_version(self) -> str:
249
248
  version_info = parse_semver(self.version.raw_id)
@@ -275,15 +274,15 @@ class OCMCluster(BaseModel):
275
274
  )
276
275
 
277
276
  @property
278
- def console_url(self) -> Optional[str]:
277
+ def console_url(self) -> str | None:
279
278
  return self.console.url if self.console else None
280
279
 
281
280
  @property
282
- def api_url(self) -> Optional[str]:
281
+ def api_url(self) -> str | None:
283
282
  return self.api.url if self.api else None
284
283
 
285
284
  @property
286
- def base_domain(self) -> Optional[str]:
285
+ def base_domain(self) -> str | None:
287
286
  return self.dns.base_domain if self.dns else None
288
287
 
289
288
 
@@ -348,7 +347,7 @@ class LabelContainer(BaseModel):
348
347
  def __bool__(self) -> bool:
349
348
  return len(self.labels) > 0
350
349
 
351
- def get(self, name: str) -> Optional[OCMLabel]:
350
+ def get(self, name: str) -> OCMLabel | None:
352
351
  return self.labels.get(name)
353
352
 
354
353
  def __getitem__(self, name: str) -> OCMLabel:
@@ -360,7 +359,7 @@ class LabelContainer(BaseModel):
360
359
  raise ValueError(f"Required label '{name}' does not exist.")
361
360
  return label
362
361
 
363
- def get_label_value(self, name: str) -> Optional[str]:
362
+ def get_label_value(self, name: str) -> str | None:
364
363
  label = self.get(name)
365
364
  if label:
366
365
  return label.value
@@ -370,7 +369,7 @@ class LabelContainer(BaseModel):
370
369
  return {label.key: label.value for label in self.labels.values()}
371
370
 
372
371
 
373
- class OCMServiceLogSeverity(str, Enum):
372
+ class OCMServiceLogSeverity(StrEnum):
374
373
  """
375
374
  Represents the severity of a service log.
376
375
  """
@@ -462,8 +461,8 @@ class OCMSubscription(BaseModel):
462
461
 
463
462
  status: OCMSubscriptionStatus
464
463
 
465
- labels: Optional[list[OCMSubscriptionLabel]] = None
466
- capabilities: Optional[list[OCMCapability]] = None
464
+ labels: list[OCMSubscriptionLabel] | None = None
465
+ capabilities: list[OCMCapability] | None = None
467
466
  """
468
467
  Capabilities are a list of features/features flags that are enabled for a subscription.
469
468
  """
@@ -477,8 +476,8 @@ class OCMOrganization(BaseModel):
477
476
  id: str
478
477
  name: str
479
478
 
480
- labels: Optional[list[OCMOrganizationLabel]] = None
481
- capabilities: Optional[list[OCMCapability]] = None
479
+ labels: list[OCMOrganizationLabel] | None = None
480
+ capabilities: list[OCMCapability] | None = None
482
481
  """
483
482
  Capabilities are a list of features/features flags that are enabled for an organization.
484
483
  """
@@ -509,7 +508,7 @@ class ClusterDetails(BaseModel):
509
508
  return capa is not None and capa.value == value
510
509
 
511
510
 
512
- class OCMOIdentityProviderMappingMethod(str, Enum):
511
+ class OCMOIdentityProviderMappingMethod(StrEnum):
513
512
  ADD = "add"
514
513
  CLAIM = "claim"
515
514
  LOOKUP = "lookup"
@@ -519,8 +518,8 @@ class OCMOIdentityProviderMappingMethod(str, Enum):
519
518
  class OCMOIdentityProvider(BaseModel):
520
519
  type: str
521
520
  name: str
522
- id: Optional[str] = None
523
- href: Optional[str] = None
521
+ id: str | None = None
522
+ href: str | None = None
524
523
 
525
524
 
526
525
  class OCMOIdentityProviderGithub(OCMOIdentityProvider):
@@ -543,7 +542,7 @@ class OCMOIdentityProviderOidcOpenIdClaims(BaseModel):
543
542
 
544
543
  class OCMOIdentityProviderOidcOpenId(BaseModel):
545
544
  client_id: str
546
- client_secret: Optional[str] = None
545
+ client_secret: str | None = None
547
546
  issuer: str
548
547
  claims: OCMOIdentityProviderOidcOpenIdClaims = OCMOIdentityProviderOidcOpenIdClaims(
549
548
  email=["email"],
@@ -579,15 +578,15 @@ class OCMAddonUpgradePolicy(BaseModel):
579
578
  id: str
580
579
  addon_id: str
581
580
  cluster_id: str
582
- next_run: Optional[str]
583
- schedule: Optional[str]
581
+ next_run: str | None
582
+ schedule: str | None
584
583
  schedule_type: str
585
584
  version: str
586
- state: Optional[str]
585
+ state: str | None
587
586
 
588
587
 
589
588
  def build_label_container(
590
- *label_iterables: Optional[Iterable[OCMLabel]],
589
+ *label_iterables: Iterable[OCMLabel] | None,
591
590
  ) -> LabelContainer:
592
591
  """
593
592
  Builds a label container from a list of labels.