qontract-reconcile 0.10.2.dev219__py3-none-any.whl → 0.10.2.dev221__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.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev219
3
+ Version: 0.10.2.dev221
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
@@ -629,7 +629,7 @@ reconcile/utils/gpg.py,sha256=EKG7_fdMv8BMlV5yUdPiqoTx-KrzmVSEAl2sLkaKwWI,1123
629
629
  reconcile/utils/gql.py,sha256=C0thIm_k9MBldfqwHzyqtYZk9sIvMdm9IbbnXLGwjD8,14158
630
630
  reconcile/utils/grouping.py,sha256=vr9SFHZ7bqmHYrvYcEZt-Er3-yQYfAAdq5sHLZVmXPY,456
631
631
  reconcile/utils/helm.py,sha256=wC1h0GylhDFeZ6hZEtYy2giAGIIQroaQhkAtURoSlI8,3893
632
- reconcile/utils/helpers.py,sha256=womAD2bKPUAFOjHvNPAe_2Hsb-oVTxuQiYPGeR-Thp0,1772
632
+ reconcile/utils/helpers.py,sha256=koyAtYnxsUVx-HIn6GpedcUE-ekz_VtoYDkiZ0iv8ik,1795
633
633
  reconcile/utils/imap_client.py,sha256=h8YDiCSCvroErhpH_-KGYI7Y2WU2Q2oSpuxDFbOkSbY,1989
634
634
  reconcile/utils/instrumented_wrappers.py,sha256=VqT4s0Bdicv224-uSeSaugtHXm-xJ3oSeBiqj0QQRiU,1942
635
635
  reconcile/utils/jenkins_api.py,sha256=RaKuZmO7_lbI-hE6c_Pq2a6CQdmBVj7BcP2jR68cIbI,7081
@@ -651,13 +651,13 @@ reconcile/utils/oc_map.py,sha256=ougQ-Wlsa8ymoE_lPQ7g2LlpsUOsHVeRCLYW_6fjeWU,897
651
651
  reconcile/utils/ocm_base_client.py,sha256=t5kxhklEqOpenXPkXiwQIk8d3D7hIUndBm5qGusS0bc,6681
652
652
  reconcile/utils/openshift_resource.py,sha256=DI-e04f4NqEUFJ_9HzjY-QMhFt7o2XVauM09mzMC5Vs,24716
653
653
  reconcile/utils/openssl.py,sha256=QVvhzhpChq_4Daf_5wE1qeZJr4thg3DDjJPn4bOPD4E,365
654
- reconcile/utils/output.py,sha256=dj3tE_sj3x8ssnAV6hCGmsRI9ttqUUFsIH1r7RujNA8,2038
654
+ reconcile/utils/output.py,sha256=wvsyf8NsFTaFHNkc8to75ta8f474Y4TMO4cHyAHEePk,2209
655
655
  reconcile/utils/pagerduty_api.py,sha256=_24i9S_4X7nlvHb-7clXRE0p1BG4ODjOzKxWO-F9WgI,7627
656
656
  reconcile/utils/parse_dhms_duration.py,sha256=TONpLnec5gHeF7k815YNJpQyDjXhkxZIcv9s8ffbTSY,1840
657
657
  reconcile/utils/password_validator.py,sha256=XwuWg-8CPlcuG7dl_oQ1G1h2gSVSnfMym_VkuprpWVg,2183
658
658
  reconcile/utils/prometheus.py,sha256=Ad0rwLbxRuuYjHwkwJloHEdK0bvy42h-p-HIT1DhDhs,3832
659
659
  reconcile/utils/promotion_state.py,sha256=McSgGj3oog83ThJCrMR2v8q6Xb_Pxij-HEe_RbDu8cg,3946
660
- reconcile/utils/promtool.py,sha256=xmPBWEApkk0L2qZBAvTxakNXxfTz-tVLPFxGnpsxXnM,2831
660
+ reconcile/utils/promtool.py,sha256=xPK4ejsXtK0csj7BVAs49IkilGWgWpHiC2j_oPAp4rQ,2831
661
661
  reconcile/utils/quay_api.py,sha256=uE_jxcdy3ViHtYFAfwDQuFDaO7Pr6AAPoVnmORbyHio,7822
662
662
  reconcile/utils/quay_mirror.py,sha256=dpWCNv5lITwIk6Q9RkmqaQKHNk_JPy27UQEribJ7E-U,1324
663
663
  reconcile/utils/raw_github_api.py,sha256=2WKtE8ABYYB9UGOAh9N_kLkksBWL3320Z2_scteZddI,2805
@@ -815,7 +815,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
815
815
  tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
816
816
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
817
817
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
818
- qontract_reconcile-0.10.2.dev219.dist-info/METADATA,sha256=-wCSzoFu4nVFyPf8EWli9O7kQ8EDxTwL_IuetzJZApg,24555
819
- qontract_reconcile-0.10.2.dev219.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
820
- qontract_reconcile-0.10.2.dev219.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
821
- qontract_reconcile-0.10.2.dev219.dist-info/RECORD,,
818
+ qontract_reconcile-0.10.2.dev221.dist-info/METADATA,sha256=ULhOVhcm1skrHzQUR1v8GulsYxMPU2MCwHXPSmRcpiY,24555
819
+ qontract_reconcile-0.10.2.dev221.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
820
+ qontract_reconcile-0.10.2.dev221.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
821
+ qontract_reconcile-0.10.2.dev221.dist-info/RECORD,,
@@ -4,6 +4,7 @@ import re
4
4
  import string
5
5
  from collections import Counter
6
6
  from collections.abc import (
7
+ Generator,
7
8
  Iterable,
8
9
  Mapping,
9
10
  )
@@ -17,11 +18,12 @@ DEFAULT_TOGGLE_LEVEL = logging.ERROR
17
18
 
18
19
 
19
20
  @contextmanager
20
- def toggle_logger(log_level: int = DEFAULT_TOGGLE_LEVEL):
21
+ def toggle_logger(log_level: int = DEFAULT_TOGGLE_LEVEL) -> Generator[logging.Logger]:
21
22
  logger = logging.getLogger()
22
23
  default_level = logger.level
23
24
  try:
24
- yield logger.setLevel(log_level) # type: ignore[func-returns-value]
25
+ logger.setLevel(log_level)
26
+ yield logger
25
27
  finally:
26
28
  logger.setLevel(default_level)
27
29
 
reconcile/utils/output.py CHANGED
@@ -41,26 +41,40 @@ def print_output(
41
41
  return formatted_content
42
42
 
43
43
 
44
- def format_table(content, columns, table_format="simple") -> str:
44
+ def _format_cell(cell: dict, column: str, table_format: str) -> dict | str:
45
+ # example: for column 'cluster.name'
46
+ # cell = item['cluster']['name']
47
+ raw_data = cell
48
+ for token in column.split("."):
49
+ raw_data = raw_data.get(token) or {}
50
+ if raw_data == {}:
51
+ return ""
52
+
53
+ if not isinstance(raw_data, list | str):
54
+ return raw_data
55
+
56
+ data = ""
57
+ if isinstance(raw_data, str):
58
+ data = raw_data
59
+
60
+ if isinstance(raw_data, list):
61
+ if table_format == "github":
62
+ data = "<br />".join(raw_data)
63
+ else:
64
+ data = "\n".join(raw_data)
65
+
66
+ if table_format == "github":
67
+ return data.replace("|", "&#124;")
68
+
69
+ return data
70
+
71
+
72
+ def format_table(
73
+ content: Iterable[dict], columns: Iterable[str], table_format: str = "simple"
74
+ ) -> str:
45
75
  headers = [column.upper() for column in columns]
46
76
  table_data = []
47
77
  for item in content:
48
- row_data = []
49
- for column in columns:
50
- # example: for column 'cluster.name'
51
- # cell = item['cluster']['name']
52
- cell = item
53
- for token in column.split("."):
54
- cell = cell.get(token) or {}
55
- if cell == {}:
56
- cell = ""
57
- if isinstance(cell, list):
58
- if table_format == "github":
59
- cell = "<br />".join(cell)
60
- else:
61
- cell = "\n".join(cell)
62
- if table_format == "github" and isinstance(cell, str):
63
- cell = cell.replace("|", "&#124;")
64
- row_data.append(cell)
78
+ row_data = [_format_cell(item, column, table_format) for column in columns]
65
79
  table_data.append(row_data)
66
80
  return tabulate(table_data, headers=headers, tablefmt=table_format)
@@ -9,7 +9,7 @@ import yaml
9
9
  from reconcile.utils.defer import defer
10
10
  from reconcile.utils.structs import CommandExecutionResult
11
11
 
12
- PROMTOOL_VERSION = ["2.54.1"]
12
+ PROMTOOL_VERSION = ["2.55.1"]
13
13
  PROMTOOL_VERSION_REGEX = r"^promtool,\sversion\s([\d]+\.[\d]+\.[\d]+).+$"
14
14
 
15
15