qontract-reconcile 0.10.1rc604__py3-none-any.whl → 0.10.1rc605__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.10.1rc604
3
+ Version: 0.10.1rc605
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
@@ -392,8 +392,8 @@ reconcile/templates/aws_access_key_email.j2,sha256=2MUr1ERmyISzKgHqsWYLd-1Wbl-pe
392
392
  reconcile/templates/email.yml.j2,sha256=OZgczNRgXPj2gVYTgwQyHAQrMGu7xp-e4W1rX19GcrU,690
393
393
  reconcile/templates/jira-checkpoint-missinginfo.j2,sha256=c_Vvg-lEENsB3tgxm9B6Y9igCUQhCnFDYh6xw-zcIbU,570
394
394
  reconcile/templating/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
395
- reconcile/templating/renderer.py,sha256=3wQrVFbm1gdF6Wb1NfCjaXzJ9tTIhFwZO8TlR90eUdc,5086
396
- reconcile/templating/rendering.py,sha256=EWgtnnzjnMFxVkfL7qsvokIvoUhPnJxEr_goy5vgTMo,4526
395
+ reconcile/templating/renderer.py,sha256=IOZN0ASSKqp4JGXZ1BDba4XosD3nCuqhStxHMGBcxDI,5119
396
+ reconcile/templating/rendering.py,sha256=2kMfstQz12FL-Qfh9OBuzAcYY1OggbFQrCYx1nxERSg,4737
397
397
  reconcile/templating/validator.py,sha256=W64nR1eoKVDGewJ4DEX9ZiWWKjFEKg5w5Xi6lrrPBd8,3434
398
398
  reconcile/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
399
399
  reconcile/test/conftest.py,sha256=rQousYrxUz-EwAIbsYO6bIwR1B4CrOz9y_zaUVo2lfI,4466
@@ -709,8 +709,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
709
709
  tools/test/test_qontract_cli.py,sha256=OvalpVRfY4pNmpMaWHHYqBjV68b1eGQjX8SCyTAXb1w,3501
710
710
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
711
711
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
712
- qontract_reconcile-0.10.1rc604.dist-info/METADATA,sha256=8DqZZvzBIt5WiKjrw88w6gjkqWMvmmFJteu3Hskyuyo,2349
713
- qontract_reconcile-0.10.1rc604.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
714
- qontract_reconcile-0.10.1rc604.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
715
- qontract_reconcile-0.10.1rc604.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
716
- qontract_reconcile-0.10.1rc604.dist-info/RECORD,,
712
+ qontract_reconcile-0.10.1rc605.dist-info/METADATA,sha256=bx0cGNR1BJbl-kyvPzH5U9kttb_fURemj1y_idTO9PU,2349
713
+ qontract_reconcile-0.10.1rc605.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
714
+ qontract_reconcile-0.10.1rc605.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
715
+ qontract_reconcile-0.10.1rc605.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
716
+ qontract_reconcile-0.10.1rc605.dist-info/RECORD,,
@@ -2,7 +2,7 @@ import logging
2
2
  import os
3
3
  from abc import ABC, abstractmethod
4
4
  from collections.abc import Callable
5
- from typing import Optional
5
+ from typing import Any, Optional
6
6
 
7
7
  from pydantic import BaseModel
8
8
  from ruamel import yaml
@@ -87,12 +87,12 @@ def unpack_static_variables(
87
87
 
88
88
  def unpack_dynamic_variables(
89
89
  collection_variables: TemplateCollectionVariablesV1, gql: gql.GqlApi
90
- ) -> dict:
90
+ ) -> dict[str, dict[str, Any]]:
91
91
  if not collection_variables.dynamic:
92
92
  return {}
93
+
93
94
  return {
94
- dv.name: list(gql.query(dv.query).values())
95
- for dv in collection_variables.dynamic or []
95
+ dv.name: gql.query(dv.query) or {} for dv in collection_variables.dynamic or []
96
96
  }
97
97
 
98
98
 
@@ -137,7 +137,9 @@ class TemplateRendererIntegration(QontractReconcileIntegration):
137
137
  output = r.render_output()
138
138
 
139
139
  if current_str != output:
140
- print(f"diff in template {template.name} for target_path {target_path}")
140
+ logging.info(
141
+ f"diff for template {template.name} in target path {target_path}"
142
+ )
141
143
  return TemplateOutput(
142
144
  path=target_path,
143
145
  content=output,
@@ -156,12 +158,11 @@ class TemplateRendererIntegration(QontractReconcileIntegration):
156
158
  ruaml_instance = create_ruamel_instance()
157
159
 
158
160
  for c in get_template_collections():
159
- variables = {}
160
161
  if c.variables:
161
- variables.update(
162
- unpack_dynamic_variables(c.variables, gql_no_validation)
163
- )
164
- variables.update(unpack_static_variables(c.variables))
162
+ variables = {
163
+ "dynamic": unpack_dynamic_variables(c.variables, gql_no_validation),
164
+ "static": unpack_static_variables(c.variables),
165
+ }
165
166
 
166
167
  for template in c.templates:
167
168
  output = self.process_template(
@@ -1,10 +1,11 @@
1
+ import logging
1
2
  from abc import ABC, abstractmethod
2
3
  from typing import Any, Optional, Protocol
3
4
 
4
5
  from pydantic import BaseModel
5
6
  from ruamel import yaml
6
7
 
7
- from reconcile.utils.jinja2.utils import process_jinja2_template
8
+ from reconcile.utils.jinja2.utils import Jinja2TemplateError, process_jinja2_template
8
9
  from reconcile.utils.jsonpath import parse_jsonpath
9
10
  from reconcile.utils.secret_reader import SecretReaderBase
10
11
 
@@ -49,11 +50,15 @@ class Renderer(ABC):
49
50
  return {**self.data.variables, "current": self.data.current}
50
51
 
51
52
  def _render_template(self, template: str) -> str:
52
- return process_jinja2_template(
53
- body=template,
54
- vars=self._jinja2_render_kwargs(),
55
- secret_reader=self.secret_reader,
56
- )
53
+ try:
54
+ return process_jinja2_template(
55
+ body=template,
56
+ vars=self._jinja2_render_kwargs(),
57
+ secret_reader=self.secret_reader,
58
+ )
59
+ except Jinja2TemplateError as e:
60
+ logging.error(f"Error rendering template {self.template.name}: {e}")
61
+ raise e
57
62
 
58
63
  @abstractmethod
59
64
  def render_output(self) -> str: