qontract-reconcile 0.10.1rc876__py3-none-any.whl → 0.10.1rc877__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.
- {qontract_reconcile-0.10.1rc876.dist-info → qontract_reconcile-0.10.1rc877.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.1rc876.dist-info → qontract_reconcile-0.10.1rc877.dist-info}/RECORD +7 -7
- reconcile/gql_definitions/templating/template_collection.py +8 -0
- reconcile/templating/renderer.py +55 -23
- {qontract_reconcile-0.10.1rc876.dist-info → qontract_reconcile-0.10.1rc877.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.1rc876.dist-info → qontract_reconcile-0.10.1rc877.dist-info}/entry_points.txt +0 -0
- {qontract_reconcile-0.10.1rc876.dist-info → qontract_reconcile-0.10.1rc877.dist-info}/top_level.txt +0 -0
{qontract_reconcile-0.10.1rc876.dist-info → qontract_reconcile-0.10.1rc877.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: qontract-reconcile
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.1rc877
|
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
|
{qontract_reconcile-0.10.1rc876.dist-info → qontract_reconcile-0.10.1rc877.dist-info}/RECORD
RENAMED
@@ -364,7 +364,7 @@ reconcile/gql_definitions/status_board/status_board.py,sha256=vHEzncabujkqbjJ-ib
|
|
364
364
|
reconcile/gql_definitions/statuspage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
365
365
|
reconcile/gql_definitions/statuspage/statuspages.py,sha256=CTRzjiR9k41LqlkgyoNHwC2JERsoD_Run_aK7jw_Ono,5299
|
366
366
|
reconcile/gql_definitions/templating/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
367
|
-
reconcile/gql_definitions/templating/template_collection.py,sha256=
|
367
|
+
reconcile/gql_definitions/templating/template_collection.py,sha256=Y1xA4ODphlsSMjGkAH-nm-dF5FzaQlpfs8hVMBczH5o,3542
|
368
368
|
reconcile/gql_definitions/templating/templates.py,sha256=ejAvQ13zfNMQTz3FWtRUic6dSvio3aAgBKEqt600hbk,2821
|
369
369
|
reconcile/gql_definitions/terraform_cloudflare_dns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
370
370
|
reconcile/gql_definitions/terraform_cloudflare_dns/app_interface_cloudflare_dns_settings.py,sha256=eyGX9HcTF6MZbOYZ6Kl6Mg3k6nJTUtwqs9gDxBP_8Dk,1920
|
@@ -461,7 +461,7 @@ reconcile/templates/jira-checkpoint-missinginfo.j2,sha256=c_Vvg-lEENsB3tgxm9B6Y9
|
|
461
461
|
reconcile/templates/rosa-classic-cluster-creation.sh.j2,sha256=0UHfYtXRVJqP07VJQx456cRI6EbZNBgamtP_8nb4WPY,2353
|
462
462
|
reconcile/templates/rosa-hcp-cluster-creation.sh.j2,sha256=O7Bf3WQIJhsZoEqaYA0wRktUO4yXXCb4BQkuvvp-C80,2385
|
463
463
|
reconcile/templating/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
464
|
-
reconcile/templating/renderer.py,sha256=
|
464
|
+
reconcile/templating/renderer.py,sha256=cRgoT5aMTbo3UYR9RkHIajd5lQ4wjN1Bge-DTrhY6Ac,11831
|
465
465
|
reconcile/templating/validator.py,sha256=pvDEc6veznEZzjypkoRJUGMMFLWosU-zd7i3j7JeNjE,4670
|
466
466
|
reconcile/templating/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
467
467
|
reconcile/templating/lib/merge_request_manager.py,sha256=JUkfF3smaQ8onzKF5F7UpmA7MWaQpftANy6dDo1FCug,5464
|
@@ -837,8 +837,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
|
|
837
837
|
tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jrss,4941
|
838
838
|
tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
|
839
839
|
tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
|
840
|
-
qontract_reconcile-0.10.
|
841
|
-
qontract_reconcile-0.10.
|
842
|
-
qontract_reconcile-0.10.
|
843
|
-
qontract_reconcile-0.10.
|
844
|
-
qontract_reconcile-0.10.
|
840
|
+
qontract_reconcile-0.10.1rc877.dist-info/METADATA,sha256=eGK-obD-y6Kqjiz2fI4n5OefUFpshM_OXDvIMLxVkxw,2273
|
841
|
+
qontract_reconcile-0.10.1rc877.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
842
|
+
qontract_reconcile-0.10.1rc877.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
|
843
|
+
qontract_reconcile-0.10.1rc877.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
|
844
|
+
qontract_reconcile-0.10.1rc877.dist-info/RECORD,,
|
@@ -25,6 +25,9 @@ query TemplateCollection_v1 {
|
|
25
25
|
additionalMrLabels
|
26
26
|
description
|
27
27
|
enableAutoApproval
|
28
|
+
forEach {
|
29
|
+
items
|
30
|
+
}
|
28
31
|
variables {
|
29
32
|
static
|
30
33
|
dynamic {
|
@@ -54,6 +57,10 @@ class ConfiguredBaseModel(BaseModel):
|
|
54
57
|
extra=Extra.forbid
|
55
58
|
|
56
59
|
|
60
|
+
class TemplateCollectionForEachV1(ConfiguredBaseModel):
|
61
|
+
items: Optional[list[Json]] = Field(..., alias="items")
|
62
|
+
|
63
|
+
|
57
64
|
class TemplateCollectionVariablesQueriesV1(ConfiguredBaseModel):
|
58
65
|
name: str = Field(..., alias="name")
|
59
66
|
query: str = Field(..., alias="query")
|
@@ -83,6 +90,7 @@ class TemplateCollectionV1(ConfiguredBaseModel):
|
|
83
90
|
additional_mr_labels: Optional[list[str]] = Field(..., alias="additionalMrLabels")
|
84
91
|
description: str = Field(..., alias="description")
|
85
92
|
enable_auto_approval: Optional[bool] = Field(..., alias="enableAutoApproval")
|
93
|
+
for_each: Optional[TemplateCollectionForEachV1] = Field(..., alias="forEach")
|
86
94
|
variables: Optional[TemplateCollectionVariablesV1] = Field(..., alias="variables")
|
87
95
|
templates: list[TemplateV1] = Field(..., alias="templates")
|
88
96
|
|
reconcile/templating/renderer.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import json
|
1
2
|
import logging
|
2
3
|
import os
|
3
4
|
import tempfile
|
@@ -30,7 +31,7 @@ from reconcile.typed_queries.github_orgs import get_github_orgs
|
|
30
31
|
from reconcile.typed_queries.gitlab_instances import get_gitlab_instances
|
31
32
|
from reconcile.utils import gql
|
32
33
|
from reconcile.utils.git import clone
|
33
|
-
from reconcile.utils.gql import init_from_config
|
34
|
+
from reconcile.utils.gql import GqlApi, init_from_config
|
34
35
|
from reconcile.utils.jinja2.utils import process_jinja2_template
|
35
36
|
from reconcile.utils.ruamel import create_ruamel_instance
|
36
37
|
from reconcile.utils.runtime.integration import (
|
@@ -158,18 +159,25 @@ class ClonedRepoGitlabPersistence(FilePersistence):
|
|
158
159
|
|
159
160
|
def unpack_static_variables(
|
160
161
|
collection_variables: TemplateCollectionVariablesV1,
|
162
|
+
each: dict[str, Any],
|
161
163
|
) -> dict:
|
162
|
-
return
|
164
|
+
return {
|
165
|
+
k: json.loads(process_jinja2_template(body=json.dumps(v), vars={"each": each}))
|
166
|
+
for k, v in (collection_variables.static or {}).items()
|
167
|
+
}
|
163
168
|
|
164
169
|
|
165
170
|
def unpack_dynamic_variables(
|
166
|
-
collection_variables: TemplateCollectionVariablesV1,
|
171
|
+
collection_variables: TemplateCollectionVariablesV1,
|
172
|
+
each: dict[str, Any],
|
173
|
+
gql: gql.GqlApi,
|
167
174
|
) -> dict[str, dict[str, Any]]:
|
168
175
|
static = collection_variables.static or {}
|
169
176
|
dynamic: dict[str, dict[str, Any]] = {}
|
170
177
|
for dv in collection_variables.dynamic or []:
|
171
178
|
query = process_jinja2_template(
|
172
|
-
body=dv.query,
|
179
|
+
body=dv.query,
|
180
|
+
vars={"static": static, "dynamic": dynamic, "each": each},
|
173
181
|
)
|
174
182
|
dynamic[dv.name] = gql.query(query) or {}
|
175
183
|
return dynamic
|
@@ -238,6 +246,38 @@ class TemplateRendererIntegration(QontractReconcileIntegration):
|
|
238
246
|
)
|
239
247
|
return None
|
240
248
|
|
249
|
+
def reconcile_template_collection(
|
250
|
+
self,
|
251
|
+
collection: TemplateCollectionV1,
|
252
|
+
gql_api: GqlApi,
|
253
|
+
dry_run: bool,
|
254
|
+
persistence: FilePersistence,
|
255
|
+
ruamel_instance: yaml.YAML,
|
256
|
+
each: dict[str, Any],
|
257
|
+
) -> None:
|
258
|
+
variables = {}
|
259
|
+
if collection.variables:
|
260
|
+
variables = {
|
261
|
+
"dynamic": unpack_dynamic_variables(
|
262
|
+
collection.variables, each, gql_api
|
263
|
+
),
|
264
|
+
"static": unpack_static_variables(collection.variables, each),
|
265
|
+
}
|
266
|
+
|
267
|
+
with PersistenceTransaction(persistence, dry_run) as p:
|
268
|
+
input = TemplateInput(
|
269
|
+
collection=collection.name,
|
270
|
+
collection_hash=calc_template_hash(collection, variables),
|
271
|
+
enable_auto_approval=collection.enable_auto_approval or False,
|
272
|
+
labels=collection.additional_mr_labels or [],
|
273
|
+
)
|
274
|
+
for template in collection.templates:
|
275
|
+
output = self.process_template(
|
276
|
+
template, variables, p, ruamel_instance, input
|
277
|
+
)
|
278
|
+
if not dry_run and output:
|
279
|
+
p.write([output])
|
280
|
+
|
241
281
|
def reconcile(
|
242
282
|
self,
|
243
283
|
dry_run: bool,
|
@@ -247,26 +287,18 @@ class TemplateRendererIntegration(QontractReconcileIntegration):
|
|
247
287
|
gql_no_validation = init_from_config(validate_schemas=False)
|
248
288
|
|
249
289
|
for c in get_template_collections():
|
250
|
-
|
251
|
-
if c.
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
enable_auto_approval=c.enable_auto_approval or False,
|
262
|
-
labels=c.additional_mr_labels or [],
|
290
|
+
for_each_items: list[dict[str, Any]] = [{}]
|
291
|
+
if c.for_each and c.for_each.items:
|
292
|
+
for_each_items = c.for_each.items
|
293
|
+
for item in for_each_items:
|
294
|
+
self.reconcile_template_collection(
|
295
|
+
c,
|
296
|
+
gql_no_validation,
|
297
|
+
dry_run,
|
298
|
+
persistence,
|
299
|
+
ruamel_instance,
|
300
|
+
item,
|
263
301
|
)
|
264
|
-
for template in c.templates:
|
265
|
-
output = self.process_template(
|
266
|
-
template, variables, p, ruamel_instance, input
|
267
|
-
)
|
268
|
-
if not dry_run and output:
|
269
|
-
p.write([output])
|
270
302
|
|
271
303
|
@property
|
272
304
|
def name(self) -> str:
|
File without changes
|
File without changes
|
{qontract_reconcile-0.10.1rc876.dist-info → qontract_reconcile-0.10.1rc877.dist-info}/top_level.txt
RENAMED
File without changes
|