qontract-reconcile 0.10.1rc919__py3-none-any.whl → 0.10.1rc921__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.1rc919.dist-info → qontract_reconcile-0.10.1rc921.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.1rc919.dist-info → qontract_reconcile-0.10.1rc921.dist-info}/RECORD +7 -7
- reconcile/utils/saasherder/models.py +81 -1
- reconcile/utils/saasherder/saasherder.py +3 -73
- {qontract_reconcile-0.10.1rc919.dist-info → qontract_reconcile-0.10.1rc921.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.1rc919.dist-info → qontract_reconcile-0.10.1rc921.dist-info}/entry_points.txt +0 -0
- {qontract_reconcile-0.10.1rc919.dist-info → qontract_reconcile-0.10.1rc921.dist-info}/top_level.txt +0 -0
{qontract_reconcile-0.10.1rc919.dist-info → qontract_reconcile-0.10.1rc921.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.1rc921
|
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.1rc919.dist-info → qontract_reconcile-0.10.1rc921.dist-info}/RECORD
RENAMED
@@ -792,8 +792,8 @@ reconcile/utils/runtime/runner.py,sha256=PBfE_M4hTZKtyubg29AkMWlLi2KKyA74yItREtT
|
|
792
792
|
reconcile/utils/runtime/sharding.py,sha256=r0ieUtNed7NvknSw6qQrCkKpVXE1shuHGnfFcnpA_k4,16142
|
793
793
|
reconcile/utils/saasherder/__init__.py,sha256=J3MBZBFa5YmhqYm08QsjBXz8mFcVOCiOCkyIcw41t7E,343
|
794
794
|
reconcile/utils/saasherder/interfaces.py,sha256=C2wrw34OXypshVocAsPrVZsSHptgw4g9u7Haa2wulZQ,9087
|
795
|
-
reconcile/utils/saasherder/models.py,sha256=
|
796
|
-
reconcile/utils/saasherder/saasherder.py,sha256=
|
795
|
+
reconcile/utils/saasherder/models.py,sha256=6MGie9SqsyP5ySjmk5bO5vPJ0-x53a0uzABxQO-WsB0,9746
|
796
|
+
reconcile/utils/saasherder/saasherder.py,sha256=H3pLQAD6EkjwrFpfQN73LKPg8mYRilssIcZ9M3duizU,84555
|
797
797
|
reconcile/utils/terraform/__init__.py,sha256=zNbiyTWo35AT1sFTElL2j_AA0jJ_yWE_bfFn-nD2xik,250
|
798
798
|
reconcile/utils/terraform/config.py,sha256=5UVrd563TMcvi4ooa5JvWVDW1I3bIWg484u79evfV_8,164
|
799
799
|
reconcile/utils/terraform/config_client.py,sha256=3gUIIIEv52Vx7-VgQ2FZYfCCrfqUv_5gw_TQ3mbLcTs,4666
|
@@ -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.
|
848
|
-
qontract_reconcile-0.10.
|
849
|
-
qontract_reconcile-0.10.
|
850
|
-
qontract_reconcile-0.10.
|
851
|
-
qontract_reconcile-0.10.
|
847
|
+
qontract_reconcile-0.10.1rc921.dist-info/METADATA,sha256=SpNBTIDWOYtsmjJ-o-tNFYFAzDMWgKbggJxyukAXWng,2273
|
848
|
+
qontract_reconcile-0.10.1rc921.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
849
|
+
qontract_reconcile-0.10.1rc921.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
|
850
|
+
qontract_reconcile-0.10.1rc921.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
|
851
|
+
qontract_reconcile-0.10.1rc921.dist-info/RECORD,,
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import base64
|
2
|
+
import json
|
3
|
+
import logging
|
2
4
|
from collections.abc import Iterable, Sequence
|
3
5
|
from dataclasses import dataclass
|
4
6
|
from enum import Enum
|
@@ -12,6 +14,8 @@ from pydantic import (
|
|
12
14
|
|
13
15
|
from reconcile.utils.oc_connection_parameters import Cluster
|
14
16
|
from reconcile.utils.saasherder.interfaces import (
|
17
|
+
HasParameters,
|
18
|
+
HasSecretParameters,
|
15
19
|
ManagedResourceName,
|
16
20
|
SaasApp,
|
17
21
|
SaasEnvironment,
|
@@ -20,6 +24,7 @@ from reconcile.utils.saasherder.interfaces import (
|
|
20
24
|
SaasResourceTemplate,
|
21
25
|
SaasResourceTemplateTarget,
|
22
26
|
)
|
27
|
+
from reconcile.utils.secret_reader import SecretReaderBase
|
23
28
|
|
24
29
|
|
25
30
|
class Providers(Enum):
|
@@ -215,9 +220,9 @@ class TargetSpec:
|
|
215
220
|
target: SaasResourceTemplateTarget
|
216
221
|
image_auth: ImageAuth
|
217
222
|
hash_length: int
|
218
|
-
parameters: dict[str, str]
|
219
223
|
github: Github
|
220
224
|
target_config_hash: str
|
225
|
+
secret_reader: SecretReaderBase
|
221
226
|
|
222
227
|
@property
|
223
228
|
def saas_file_name(self) -> str:
|
@@ -266,3 +271,78 @@ class TargetSpec:
|
|
266
271
|
@property
|
267
272
|
def delete(self) -> bool:
|
268
273
|
return bool(self.target.delete)
|
274
|
+
|
275
|
+
def parameters(self, adjust: bool = True) -> dict[str, str]:
|
276
|
+
environment_parameters = self._collect_parameters(
|
277
|
+
self.target.namespace.environment, adjust=adjust
|
278
|
+
)
|
279
|
+
saas_file_parameters = self._collect_parameters(self.saas_file, adjust=adjust)
|
280
|
+
resource_template_parameters = self._collect_parameters(
|
281
|
+
self.resource_template, adjust=adjust
|
282
|
+
)
|
283
|
+
target_parameters = self._collect_parameters(self.target, adjust=adjust)
|
284
|
+
|
285
|
+
try:
|
286
|
+
saas_file_secret_parameters = self._collect_secret_parameters(
|
287
|
+
self.saas_file
|
288
|
+
)
|
289
|
+
resource_template_secret_parameters = self._collect_secret_parameters(
|
290
|
+
self.resource_template
|
291
|
+
)
|
292
|
+
environment_secret_parameters = self._collect_secret_parameters(
|
293
|
+
self.target.namespace.environment
|
294
|
+
)
|
295
|
+
target_secret_parameters = self._collect_secret_parameters(self.target)
|
296
|
+
except Exception as e:
|
297
|
+
logging.error(f"Error collecting secrets: {e}")
|
298
|
+
raise
|
299
|
+
|
300
|
+
consolidated_parameters = {}
|
301
|
+
consolidated_parameters.update(environment_parameters)
|
302
|
+
consolidated_parameters.update(environment_secret_parameters)
|
303
|
+
consolidated_parameters.update(saas_file_parameters)
|
304
|
+
consolidated_parameters.update(saas_file_secret_parameters)
|
305
|
+
consolidated_parameters.update(resource_template_parameters)
|
306
|
+
consolidated_parameters.update(resource_template_secret_parameters)
|
307
|
+
consolidated_parameters.update(target_parameters)
|
308
|
+
consolidated_parameters.update(target_secret_parameters)
|
309
|
+
|
310
|
+
for replace_key, replace_value in consolidated_parameters.items():
|
311
|
+
if not isinstance(replace_value, str):
|
312
|
+
continue
|
313
|
+
replace_pattern = "${" + replace_key + "}"
|
314
|
+
for k, v in consolidated_parameters.items():
|
315
|
+
if not isinstance(v, str):
|
316
|
+
continue
|
317
|
+
if replace_pattern in v:
|
318
|
+
consolidated_parameters[k] = v.replace(
|
319
|
+
replace_pattern, replace_value
|
320
|
+
)
|
321
|
+
|
322
|
+
return consolidated_parameters
|
323
|
+
|
324
|
+
@staticmethod
|
325
|
+
def _collect_parameters(
|
326
|
+
container: HasParameters, adjust: bool = True
|
327
|
+
) -> dict[str, str]:
|
328
|
+
parameters = container.parameters or {}
|
329
|
+
if isinstance(parameters, str):
|
330
|
+
parameters = json.loads(parameters)
|
331
|
+
if adjust:
|
332
|
+
# adjust Python's True/False
|
333
|
+
for k, v in parameters.items():
|
334
|
+
if v is True:
|
335
|
+
parameters[k] = "true"
|
336
|
+
elif v is False:
|
337
|
+
parameters[k] = "false"
|
338
|
+
elif any(isinstance(v, t) for t in [dict, list, tuple]):
|
339
|
+
parameters[k] = json.dumps(v)
|
340
|
+
return parameters
|
341
|
+
|
342
|
+
def _collect_secret_parameters(
|
343
|
+
self, container: HasSecretParameters
|
344
|
+
) -> dict[str, str]:
|
345
|
+
return {
|
346
|
+
sp.name: self.secret_reader.read_secret(sp.secret)
|
347
|
+
for sp in container.secret_parameters or []
|
348
|
+
}
|
@@ -59,8 +59,6 @@ from reconcile.utils.promotion_state import (
|
|
59
59
|
PromotionState,
|
60
60
|
)
|
61
61
|
from reconcile.utils.saasherder.interfaces import (
|
62
|
-
HasParameters,
|
63
|
-
HasSecretParameters,
|
64
62
|
SaasFile,
|
65
63
|
SaasParentSaasPromotion,
|
66
64
|
SaasResourceTemplate,
|
@@ -706,29 +704,6 @@ class SaasHerder: # pylint: disable=too-many-public-methods
|
|
706
704
|
for rt in saas_file.resource_templates
|
707
705
|
)
|
708
706
|
|
709
|
-
@staticmethod
|
710
|
-
def _collect_parameters(container: HasParameters) -> dict[str, str]:
|
711
|
-
parameters = container.parameters or {}
|
712
|
-
if isinstance(parameters, str):
|
713
|
-
parameters = json.loads(parameters)
|
714
|
-
# adjust Python's True/False
|
715
|
-
for k, v in parameters.items():
|
716
|
-
if v is True:
|
717
|
-
parameters[k] = "true"
|
718
|
-
elif v is False:
|
719
|
-
parameters[k] = "false"
|
720
|
-
elif any(isinstance(v, t) for t in [dict, list, tuple]):
|
721
|
-
parameters[k] = json.dumps(v)
|
722
|
-
return parameters
|
723
|
-
|
724
|
-
def _collect_secret_parameters(
|
725
|
-
self, container: HasSecretParameters
|
726
|
-
) -> dict[str, str]:
|
727
|
-
return {
|
728
|
-
sp.name: self.secret_reader.read_secret(sp.secret)
|
729
|
-
for sp in container.secret_parameters or []
|
730
|
-
}
|
731
|
-
|
732
707
|
@staticmethod
|
733
708
|
def _get_file_contents_github(repo: Repository, path: str, commit_sha: str) -> str:
|
734
709
|
f = repo.get_contents(path, commit_sha)
|
@@ -899,44 +874,11 @@ class SaasHerder: # pylint: disable=too-many-public-methods
|
|
899
874
|
provider = spec.provider
|
900
875
|
hash_length = spec.hash_length
|
901
876
|
target = spec.target
|
902
|
-
parameters = spec.parameters
|
903
877
|
github = spec.github
|
904
878
|
target_config_hash = spec.target_config_hash
|
905
879
|
|
906
880
|
if provider == "openshift-template":
|
907
|
-
|
908
|
-
target.namespace.environment
|
909
|
-
)
|
910
|
-
target_parameters = self._collect_parameters(target)
|
911
|
-
|
912
|
-
try:
|
913
|
-
environment_secret_parameters = self._collect_secret_parameters(
|
914
|
-
target.namespace.environment
|
915
|
-
)
|
916
|
-
target_secret_parameters = self._collect_secret_parameters(target)
|
917
|
-
except Exception as e:
|
918
|
-
logging.error(f"Error collecting secrets: {e}")
|
919
|
-
raise
|
920
|
-
|
921
|
-
consolidated_parameters = {}
|
922
|
-
consolidated_parameters.update(environment_parameters)
|
923
|
-
consolidated_parameters.update(environment_secret_parameters)
|
924
|
-
consolidated_parameters.update(parameters)
|
925
|
-
consolidated_parameters.update(target_parameters)
|
926
|
-
consolidated_parameters.update(target_secret_parameters)
|
927
|
-
|
928
|
-
for replace_key, replace_value in consolidated_parameters.items():
|
929
|
-
if not isinstance(replace_value, str):
|
930
|
-
continue
|
931
|
-
replace_pattern = "${" + replace_key + "}"
|
932
|
-
for k, v in consolidated_parameters.items():
|
933
|
-
if not isinstance(v, str):
|
934
|
-
continue
|
935
|
-
if replace_pattern in v:
|
936
|
-
consolidated_parameters[k] = v.replace(
|
937
|
-
replace_pattern, replace_value
|
938
|
-
)
|
939
|
-
|
881
|
+
consolidated_parameters = spec.parameters()
|
940
882
|
try:
|
941
883
|
template, html_url, commit_sha = self._get_file_contents(
|
942
884
|
url=url, path=path, ref=target.ref, github=github
|
@@ -1046,7 +988,7 @@ class SaasHerder: # pylint: disable=too-many-public-methods
|
|
1046
988
|
url=url,
|
1047
989
|
path=path,
|
1048
990
|
name=resource_template_name,
|
1049
|
-
values=
|
991
|
+
values=spec.parameters(adjust=False),
|
1050
992
|
ssl_verify=ssl_verify,
|
1051
993
|
)
|
1052
994
|
|
@@ -1304,22 +1246,10 @@ class SaasHerder: # pylint: disable=too-many-public-methods
|
|
1304
1246
|
specs = []
|
1305
1247
|
github = self._initiate_github(saas_file)
|
1306
1248
|
image_auth = self._initiate_image_auth(saas_file)
|
1307
|
-
saas_file_parameters = self._collect_parameters(saas_file)
|
1308
|
-
saas_file_secret_parameters = self._collect_secret_parameters(saas_file)
|
1309
|
-
|
1310
1249
|
all_trigger_specs = self.get_saas_targets_config_trigger_specs(saas_file)
|
1311
1250
|
# iterate over resource templates (multiple per saas_file)
|
1312
1251
|
for rt in saas_file.resource_templates:
|
1313
1252
|
hash_length = rt.hash_length or self.hash_length
|
1314
|
-
resource_template_parameters = self._collect_parameters(rt)
|
1315
|
-
resource_template_secret_parameters = self._collect_secret_parameters(rt)
|
1316
|
-
|
1317
|
-
consolidated_parameters = {}
|
1318
|
-
consolidated_parameters.update(saas_file_parameters)
|
1319
|
-
consolidated_parameters.update(saas_file_secret_parameters)
|
1320
|
-
consolidated_parameters.update(resource_template_parameters)
|
1321
|
-
consolidated_parameters.update(resource_template_secret_parameters)
|
1322
|
-
|
1323
1253
|
# Iterate over targets (each target is a namespace).
|
1324
1254
|
for target in rt.targets:
|
1325
1255
|
if target.disable:
|
@@ -1349,9 +1279,9 @@ class SaasHerder: # pylint: disable=too-many-public-methods
|
|
1349
1279
|
# process_template options
|
1350
1280
|
image_auth=image_auth,
|
1351
1281
|
hash_length=hash_length,
|
1352
|
-
parameters=consolidated_parameters,
|
1353
1282
|
github=github,
|
1354
1283
|
target_config_hash=digest,
|
1284
|
+
secret_reader=self.secret_reader,
|
1355
1285
|
)
|
1356
1286
|
)
|
1357
1287
|
|
File without changes
|
File without changes
|
{qontract_reconcile-0.10.1rc919.dist-info → qontract_reconcile-0.10.1rc921.dist-info}/top_level.txt
RENAMED
File without changes
|