qontract-reconcile 0.10.1rc924__py3-none-any.whl → 0.10.1rc925__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.1rc924
3
+ Version: 0.10.1rc925
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
@@ -463,11 +463,11 @@ reconcile/templates/jira-checkpoint-missinginfo.j2,sha256=c_Vvg-lEENsB3tgxm9B6Y9
463
463
  reconcile/templates/rosa-classic-cluster-creation.sh.j2,sha256=FVBmnR2FmVModhqOYNBInhF8zk0Qnj9og9KHK5-X9v0,2361
464
464
  reconcile/templates/rosa-hcp-cluster-creation.sh.j2,sha256=2wTdv9qvapCvT8NSi_hq8sXhpFSaxRX-V6Cao1diCI8,2393
465
465
  reconcile/templating/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
466
- reconcile/templating/renderer.py,sha256=oUUiHHSgD5bcUN3Xf-yoEezAf3LjqN-2GlYhQUTPIZY,13067
466
+ reconcile/templating/renderer.py,sha256=GjjYPDmiP0zvTDxOr_vAniqN9UHcSMiv-biPUvy8NzM,13091
467
467
  reconcile/templating/validator.py,sha256=5f9f35PCHOOdjb7KZquL2YdabyuAUokPDa4xutSEHIQ,5360
468
468
  reconcile/templating/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
469
- reconcile/templating/lib/merge_request_manager.py,sha256=4oe3EwQOP7CZSraocivbRzzOuVb0ooElaUS2_DGsF50,5603
470
- reconcile/templating/lib/model.py,sha256=fb6FYYLQjmoh2DjVKO7TEWCuDPf1Q34xmOx0M9Z07ek,324
469
+ reconcile/templating/lib/merge_request_manager.py,sha256=P4IbblzXbubjlaxAYoahHFADUNIXLepfqwzdnHPs8OY,5608
470
+ reconcile/templating/lib/model.py,sha256=Y1PeEP-koHKiH46JSwv4-PGRGQtcxZa9VmjTiuI6Lxs,889
471
471
  reconcile/templating/lib/rendering.py,sha256=6kt8NCCwB4vLKYal7KtRmBDguIC1p_PIQCRr-vL7p5w,5504
472
472
  reconcile/terraform_init/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
473
473
  reconcile/terraform_init/integration.py,sha256=glQ9uy8Kj2aTQXCAupwSFeih7reX_xMX_UuWW_ywBMU,6100
@@ -844,8 +844,8 @@ tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jr
844
844
  tools/test/test_saas_promotion_state.py,sha256=dy4kkSSAQ7bC0Xp2CociETGN-2aABEfL6FU5D9Jl00Y,6056
845
845
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
846
846
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
847
- qontract_reconcile-0.10.1rc924.dist-info/METADATA,sha256=lDNUw1z1rLZBkUJGhvbJutmyOh-8hG0mfjXu2C88-Ck,2273
848
- qontract_reconcile-0.10.1rc924.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
849
- qontract_reconcile-0.10.1rc924.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
850
- qontract_reconcile-0.10.1rc924.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
851
- qontract_reconcile-0.10.1rc924.dist-info/RECORD,,
847
+ qontract_reconcile-0.10.1rc925.dist-info/METADATA,sha256=JJstPmbQ_muKOcYIt2w0XSiI3q4MlNNDRsJ0enydTfk,2273
848
+ qontract_reconcile-0.10.1rc925.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
849
+ qontract_reconcile-0.10.1rc925.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
850
+ qontract_reconcile-0.10.1rc925.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
851
+ qontract_reconcile-0.10.1rc925.dist-info/RECORD,,
@@ -136,7 +136,7 @@ class MergeRequestManager(MergeRequestManagerBase[TemplateInfo]):
136
136
 
137
137
  output = data.data
138
138
  collections = {o.input.collection for o in output}
139
- collection_hashes = {o.input.collection_hash for o in output}
139
+ collection_hashes = {o.input.calc_template_hash() for o in output}
140
140
  additional_labels = {label for o in output for label in o.input.labels}
141
141
  # From the way the code is written, we can assert that there is only one collection and one template hash
142
142
  assert len(collections) == 1
@@ -1,12 +1,30 @@
1
+ from typing import Any
2
+
3
+ from deepdiff import DeepHash
1
4
  from pydantic import BaseModel
2
5
 
6
+ from reconcile.gql_definitions.templating.template_collection import (
7
+ TemplateV1,
8
+ )
9
+
3
10
 
4
11
  class TemplateInput(BaseModel):
5
12
  collection: str
6
- collection_hash: str
13
+ templates: list[TemplateV1] = []
14
+ variables: list[dict[str, Any]] = []
15
+ collection_hash: str = ""
7
16
  enable_auto_approval: bool = False
8
17
  labels: list[str] = []
9
18
 
19
+ def calc_template_hash(self) -> str:
20
+ if not self.collection_hash:
21
+ hashable = {
22
+ "templates": sorted(self.templates, key=lambda x: x.name),
23
+ "variables": self.variables,
24
+ }
25
+ self.collection_hash = DeepHash(hashable)[hashable]
26
+ return self.collection_hash
27
+
10
28
 
11
29
  class TemplateOutput(BaseModel):
12
30
  input: TemplateInput
@@ -7,7 +7,6 @@ from collections.abc import Callable
7
7
  from pathlib import Path
8
8
  from typing import Any, Self
9
9
 
10
- from deepdiff import DeepHash
11
10
  from ruamel import yaml
12
11
 
13
12
  from reconcile.gql_definitions.templating.template_collection import (
@@ -187,14 +186,6 @@ def unpack_dynamic_variables(
187
186
  return dynamic
188
187
 
189
188
 
190
- def calc_template_hash(c: TemplateCollectionV1, variables: dict[str, Any]) -> str:
191
- hashable = {
192
- "templates": sorted(c.templates, key=lambda x: x.name),
193
- "variables": variables,
194
- }
195
- return DeepHash(hashable)[hashable]
196
-
197
-
198
189
  class TemplateRendererIntegrationParams(PydanticRunParams):
199
190
  clone_repo: bool = False
200
191
  app_interface_data_path: str | None
@@ -276,11 +267,11 @@ class TemplateRendererIntegration(QontractReconcileIntegration):
276
267
  self,
277
268
  collection: TemplateCollectionV1,
278
269
  gql_api: GqlApi,
279
- dry_run: bool,
280
270
  persistence: FilePersistence,
281
271
  ruamel_instance: yaml.YAML,
272
+ input: TemplateInput,
282
273
  each: dict[str, Any],
283
- ) -> None:
274
+ ) -> list[TemplateOutput]:
284
275
  variables = {}
285
276
  if collection.variables:
286
277
  variables = {
@@ -289,20 +280,17 @@ class TemplateRendererIntegration(QontractReconcileIntegration):
289
280
  ),
290
281
  "static": unpack_static_variables(collection.variables, each),
291
282
  }
283
+ input.variables.append(variables)
292
284
 
293
- with PersistenceTransaction(persistence, dry_run) as p:
294
- input = TemplateInput(
295
- collection=collection.name,
296
- collection_hash=calc_template_hash(collection, variables),
297
- enable_auto_approval=collection.enable_auto_approval or False,
298
- labels=collection.additional_mr_labels or [],
285
+ outputs: list[TemplateOutput] = []
286
+ for template in collection.templates:
287
+ output = self.process_template(
288
+ template, variables, persistence, ruamel_instance, input
299
289
  )
300
- for template in collection.templates:
301
- output = self.process_template(
302
- template, variables, p, ruamel_instance, input
303
- )
304
- if not dry_run and output:
305
- p.write([output])
290
+ if output:
291
+ outputs.append(output)
292
+
293
+ return outputs
306
294
 
307
295
  def reconcile(
308
296
  self,
@@ -317,15 +305,27 @@ class TemplateRendererIntegration(QontractReconcileIntegration):
317
305
  for_each_items: list[dict[str, Any]] = [{}]
318
306
  if c.for_each and c.for_each.items:
319
307
  for_each_items = c.for_each.items
320
- for item in for_each_items:
321
- self.reconcile_template_collection(
322
- c,
323
- gql_no_validation,
324
- dry_run,
325
- persistence,
326
- ruamel_instance,
327
- item,
328
- )
308
+ input = TemplateInput(
309
+ collection=c.name,
310
+ templates=c.templates,
311
+ enable_auto_approval=c.enable_auto_approval or False,
312
+ labels=c.additional_mr_labels or [],
313
+ )
314
+ with PersistenceTransaction(persistence, dry_run) as p:
315
+ outputs: list[TemplateOutput] = []
316
+ for item in for_each_items:
317
+ outputs.extend(
318
+ self.reconcile_template_collection(
319
+ c,
320
+ gql_no_validation,
321
+ p,
322
+ ruamel_instance,
323
+ input,
324
+ item,
325
+ )
326
+ )
327
+ if not dry_run and outputs:
328
+ p.write(outputs)
329
329
 
330
330
  @property
331
331
  def name(self) -> str: