qontract-reconcile 0.10.1rc1030__py3-none-any.whl → 0.10.1rc1032__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 (46) hide show
  1. {qontract_reconcile-0.10.1rc1030.dist-info → qontract_reconcile-0.10.1rc1032.dist-info}/METADATA +1 -1
  2. {qontract_reconcile-0.10.1rc1030.dist-info → qontract_reconcile-0.10.1rc1032.dist-info}/RECORD +46 -46
  3. reconcile/aws_support_cases_sos.py +1 -1
  4. reconcile/cli.py +1 -1
  5. reconcile/dynatrace_token_provider/integration.py +2 -2
  6. reconcile/endpoints_discovery/merge_request.py +10 -6
  7. reconcile/github_org.py +1 -1
  8. reconcile/gitlab_permissions.py +22 -130
  9. reconcile/ocm_aws_infrastructure_access.py +2 -2
  10. reconcile/openshift_base.py +2 -2
  11. reconcile/openshift_cluster_bots.py +1 -1
  12. reconcile/openshift_namespaces.py +1 -1
  13. reconcile/openshift_resources_base.py +2 -2
  14. reconcile/openshift_saas_deploy_change_tester.py +1 -1
  15. reconcile/openshift_saas_deploy_trigger_base.py +1 -1
  16. reconcile/query_validator.py +2 -2
  17. reconcile/terraform_aws_route53.py +2 -2
  18. reconcile/test/test_closedbox_endpoint_monitoring.py +5 -5
  19. reconcile/test/test_gitlab_permissions.py +9 -97
  20. reconcile/test/test_openshift_resource.py +2 -2
  21. reconcile/test/test_openshift_resources_base.py +7 -7
  22. reconcile/test/test_openshift_serviceaccount_tokens.py +7 -5
  23. reconcile/test/test_terraform_vpc_peerings.py +2 -2
  24. reconcile/utils/acs/base.py +1 -1
  25. reconcile/utils/acs/notifiers.py +1 -1
  26. reconcile/utils/aws_api.py +1 -1
  27. reconcile/utils/config.py +2 -4
  28. reconcile/utils/external_resources.py +1 -1
  29. reconcile/utils/gitlab_api.py +43 -7
  30. reconcile/utils/gql.py +1 -1
  31. reconcile/utils/jinja2/utils.py +1 -1
  32. reconcile/utils/jobcontroller/controller.py +3 -3
  33. reconcile/utils/mr/__init__.py +8 -8
  34. reconcile/utils/ocm/__init__.py +2 -2
  35. reconcile/utils/saasherder/__init__.py +1 -1
  36. reconcile/utils/saasherder/saasherder.py +5 -5
  37. reconcile/utils/state.py +2 -2
  38. reconcile/utils/terraform_client.py +1 -1
  39. reconcile/utils/terrascript_aws_client.py +1 -1
  40. reconcile/utils/unleash/__init__.py +2 -2
  41. reconcile/utils/vcs.py +2 -2
  42. tools/app_interface_reporter.py +7 -7
  43. tools/qontract_cli.py +21 -45
  44. {qontract_reconcile-0.10.1rc1030.dist-info → qontract_reconcile-0.10.1rc1032.dist-info}/WHEEL +0 -0
  45. {qontract_reconcile-0.10.1rc1030.dist-info → qontract_reconcile-0.10.1rc1032.dist-info}/entry_points.txt +0 -0
  46. {qontract_reconcile-0.10.1rc1030.dist-info → qontract_reconcile-0.10.1rc1032.dist-info}/top_level.txt +0 -0
@@ -5,7 +5,7 @@ from .client import (
5
5
  )
6
6
 
7
7
  __all__ = [
8
- "get_feature_toggles",
9
- "get_feature_toggle_state",
10
8
  "get_feature_toggle_default",
9
+ "get_feature_toggle_state",
10
+ "get_feature_toggles",
11
11
  ]
reconcile/utils/vcs.py CHANGED
@@ -129,7 +129,7 @@ class VCS:
129
129
  gitlab_instances: Iterable[GitlabInstanceV1],
130
130
  ) -> GitLabApi:
131
131
  return GitLabApi(
132
- list(gitlab_instances)[0].dict(by_alias=True),
132
+ next(iter(gitlab_instances)).dict(by_alias=True),
133
133
  secret_reader=self._secret_reader,
134
134
  )
135
135
 
@@ -139,7 +139,7 @@ class VCS:
139
139
  app_interface_repo_url: str,
140
140
  ) -> GitLabApi:
141
141
  return GitLabApi(
142
- list(gitlab_instances)[0].dict(by_alias=True),
142
+ next(iter(gitlab_instances)).dict(by_alias=True),
143
143
  secret_reader=self._secret_reader,
144
144
  project_url=app_interface_repo_url,
145
145
  )
@@ -338,10 +338,10 @@ def get_apps_data(date, month_delta=1, thread_pool_size=10):
338
338
  validt_mx[cluster][namespace] = {}
339
339
  if validation not in validt_mx[cluster][namespace]:
340
340
  validt_mx[cluster][namespace][validation] = {}
341
- if status not in validt_mx[cluster][namespace][validation]: # noqa: E501
342
- validt_mx[cluster][namespace][validation][status] = {} # noqa: E501
341
+ if status not in validt_mx[cluster][namespace][validation]:
342
+ validt_mx[cluster][namespace][validation][status] = {}
343
343
  value = int(sample.value)
344
- validt_mx[cluster][namespace][validation][status] = value # noqa: E501
344
+ validt_mx[cluster][namespace][validation][status] = value
345
345
  for family in text_string_to_metric_families(slo_metrics):
346
346
  for sample in family.samples:
347
347
  if sample.name == "serviceslometrics":
@@ -358,14 +358,14 @@ def get_apps_data(date, month_delta=1, thread_pool_size=10):
358
358
  slo_mx[cluster] = {}
359
359
  if namespace not in slo_mx[cluster]:
360
360
  slo_mx[cluster][namespace] = {}
361
- if slo_doc_name not in slo_mx[cluster][namespace]: # pylint: disable=line-too-long # noqa: E501
361
+ if slo_doc_name not in slo_mx[cluster][namespace]: # pylint: disable=line-too-long
362
362
  slo_mx[cluster][namespace][slo_doc_name] = {}
363
- if slo_name not in slo_mx[cluster][namespace][slo_doc_name]: # noqa: E501
364
- slo_mx[cluster][namespace][slo_doc_name][slo_name] = { # noqa: E501
363
+ if slo_name not in slo_mx[cluster][namespace][slo_doc_name]:
364
+ slo_mx[cluster][namespace][slo_doc_name][slo_name] = {
365
365
  sample.labels["type"]: sample.value
366
366
  }
367
367
  else:
368
- slo_mx[cluster][namespace][slo_doc_name][slo_name].update({ # pylint: disable=line-too-long # noqa: E501
368
+ slo_mx[cluster][namespace][slo_doc_name][slo_name].update({ # pylint: disable=line-too-long
369
369
  sample.labels["type"]: sample.value
370
370
  })
371
371
  app["container_vulnerabilities"] = vuln_mx
tools/qontract_cli.py CHANGED
@@ -1124,14 +1124,14 @@ def cidr_blocks(ctx, for_cluster: int, mask: int) -> None:
1124
1124
 
1125
1125
  avail_addr = ipaddress.ip_address(latest_cluster_cidr["to"]) + 1
1126
1126
 
1127
- print(f"INFO: Latest available network address: {str(avail_addr)}")
1127
+ print(f"INFO: Latest available network address: {avail_addr!s}")
1128
1128
  try:
1129
1129
  result_cidr_block = str(ipaddress.ip_network((avail_addr, mask)))
1130
1130
  except ValueError:
1131
1131
  print(f"ERROR: Invalid CIDR Mask {mask} Provided.")
1132
1132
  sys.exit(1)
1133
- print(f"INFO: You are reserving {str(2 ** (32 - mask))} network addresses.")
1134
- print(f"\nYou can use: {str(result_cidr_block)}")
1133
+ print(f"INFO: You are reserving {2 ** (32 - mask)!s} network addresses.")
1134
+ print(f"\nYou can use: {result_cidr_block!s}")
1135
1135
  else:
1136
1136
  ctx.obj["options"]["sort"] = False
1137
1137
  print_output(ctx.obj["options"], cidrs, columns)
@@ -1744,17 +1744,8 @@ def roles(ctx, org_username):
1744
1744
 
1745
1745
  user = users[0]
1746
1746
 
1747
- roles = []
1748
-
1749
- def add(d):
1750
- for i, r in enumerate(roles):
1751
- if all(d[k] == r[k] for k in ("type", "name", "resource")):
1752
- roles.insert(
1753
- i + 1, {"type": "", "name": "", "resource": "", "ref": d["ref"]}
1754
- )
1755
- return
1756
-
1757
- roles.append(d)
1747
+ # type, name, resource, [ref]
1748
+ roles: dict[(str, str, str), set] = defaultdict(set)
1758
1749
 
1759
1750
  for role in user["roles"]:
1760
1751
  role_name = role["path"]
@@ -1771,53 +1762,38 @@ def roles(ctx, org_username):
1771
1762
  if "team" in p:
1772
1763
  r_name += "/" + p["team"]
1773
1764
 
1774
- add({
1775
- "type": "permission",
1776
- "name": p["name"],
1777
- "resource": r_name,
1778
- "ref": role_name,
1779
- })
1765
+ roles[("permission", p["name"], r_name)].add(role_name)
1780
1766
 
1781
1767
  for aws in role.get("aws_groups") or []:
1782
1768
  for policy in aws["policies"]:
1783
- add({
1784
- "type": "aws",
1785
- "name": policy,
1786
- "resource": aws["account"]["name"],
1787
- "ref": aws["path"],
1788
- })
1769
+ roles[("aws", policy, aws["account"]["name"])].add(aws["path"])
1789
1770
 
1790
1771
  for a in role.get("access") or []:
1791
1772
  if a["cluster"]:
1792
1773
  cluster_name = a["cluster"]["name"]
1793
- add({
1794
- "type": "cluster",
1795
- "name": a["clusterRole"],
1796
- "resource": cluster_name,
1797
- "ref": role_name,
1798
- })
1774
+ roles[("cluster", a["clusterRole"], cluster_name)].add(role_name)
1799
1775
  elif a["namespace"]:
1800
1776
  ns_name = a["namespace"]["name"]
1801
- add({
1802
- "type": "namespace",
1803
- "name": a["role"],
1804
- "resource": ns_name,
1805
- "ref": role_name,
1806
- })
1777
+ roles[("namespace", a["role"], ns_name)].add(role_name)
1807
1778
 
1808
1779
  for s in role.get("self_service") or []:
1809
1780
  for d in s.get("datafiles") or []:
1810
1781
  name = d.get("name")
1811
1782
  if name:
1812
- add({
1813
- "type": "saas_file",
1814
- "name": "owner",
1815
- "resource": name,
1816
- "ref": role_name,
1817
- })
1783
+ roles[("saas_file", "owner", name)].add(role_name)
1818
1784
 
1819
1785
  columns = ["type", "name", "resource", "ref"]
1820
- print_output(ctx.obj["options"], roles, columns)
1786
+ rows = [
1787
+ {
1788
+ "type": k[0],
1789
+ "name": k[1],
1790
+ "resource": k[2],
1791
+ "ref": ref,
1792
+ }
1793
+ for k, v in roles.items()
1794
+ for ref in v
1795
+ ]
1796
+ print_output(ctx.obj["options"], rows, columns)
1821
1797
 
1822
1798
 
1823
1799
  @get.command()