qontract-reconcile 0.10.1rc398__py3-none-any.whl → 0.10.1rc399__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.1rc398
3
+ Version: 0.10.1rc399
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
@@ -321,7 +321,7 @@ reconcile/saas_auto_promotions_manager/subscriber.py,sha256=cLhPlkT71J2LIice3SLm
321
321
  reconcile/saas_auto_promotions_manager/merge_request_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
322
322
  reconcile/saas_auto_promotions_manager/merge_request_manager/merge_request.py,sha256=PNu7sE-tDUY61E03z5w0b93fdowZ8auCl0S4_vhYOKQ,1333
323
323
  reconcile/saas_auto_promotions_manager/merge_request_manager/merge_request_manager.py,sha256=SNJ9WLlaFnf_tblwC0xDBfrXi4SVadeFgV3llhTqbGM,10959
324
- reconcile/saas_auto_promotions_manager/merge_request_manager/renderer.py,sha256=cQYT0qCQQdsG4H16zpXBnHvnF_aZy4T87SxruyxRgNc,8565
324
+ reconcile/saas_auto_promotions_manager/merge_request_manager/renderer.py,sha256=t4Zi1BSDBEhrEl0hFIC7bPA41IGwh3kTWlo7qCtDTLE,7176
325
325
  reconcile/saas_auto_promotions_manager/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
326
326
  reconcile/saas_auto_promotions_manager/utils/saas_files_inventory.py,sha256=mihuWynroB1Cea1Lsvf6V8Nb8PGiBdcLC0uhCX_52Y0,6966
327
327
  reconcile/saas_auto_promotions_manager/utils/vcs.py,sha256=WXzr6I0Q9NzTU8s2Dk_wdWxKN8zUwPFiXbx31CnuY0w,5237
@@ -613,8 +613,8 @@ tools/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
613
613
  tools/test/test_qontract_cli.py,sha256=awwTHEc2DWlykuqGIYM0WOBoSL0KRnOraCLk3C7izis,1401
614
614
  tools/test/test_sd_app_sre_alert_report.py,sha256=JeLhgzpKCPgLvptwg_4ZvJHLVWKNG1T5845HXTkMBxA,1826
615
615
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
616
- qontract_reconcile-0.10.1rc398.dist-info/METADATA,sha256=40hOlhFAF0_KDt5bD1YtZDrIG_MHZi-tFwgioF-OQa4,2347
617
- qontract_reconcile-0.10.1rc398.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
618
- qontract_reconcile-0.10.1rc398.dist-info/entry_points.txt,sha256=ErVY2Jp-0Rtuq5KOtMlW5yvna4nIEuc_1YbEdEdcy9o,301
619
- qontract_reconcile-0.10.1rc398.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
620
- qontract_reconcile-0.10.1rc398.dist-info/RECORD,,
616
+ qontract_reconcile-0.10.1rc399.dist-info/METADATA,sha256=8Rhg2IJPlLsVXNXBbLK1INKk5ke86eV9Z67fDjHGShA,2347
617
+ qontract_reconcile-0.10.1rc399.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
618
+ qontract_reconcile-0.10.1rc399.dist-info/entry_points.txt,sha256=ErVY2Jp-0Rtuq5KOtMlW5yvna4nIEuc_1YbEdEdcy9o,301
619
+ qontract_reconcile-0.10.1rc399.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
620
+ qontract_reconcile-0.10.1rc399.dist-info/RECORD,,
@@ -56,14 +56,9 @@ class Renderer:
56
56
  **namespace_selector
57
57
  )
58
58
  # Check if the target namespace is addressed by the selector
59
- return (
60
- len(
61
- get_namespaces_by_selector(
62
- namespaces=[subscriber.target_namespace],
63
- namespace_selector=selector,
64
- )
65
- )
66
- == 1
59
+ return is_namespace_addressed_by_selector(
60
+ namespace=subscriber.target_namespace,
61
+ namespace_selector=selector,
67
62
  )
68
63
  return target["namespace"]["$ref"] == subscriber.target_namespace.path
69
64
 
@@ -158,56 +153,33 @@ class Renderer:
158
153
  return f"[auto-promotion] event for channel(s) {channels}"
159
154
 
160
155
 
161
- def get_namespaces_by_selector(
162
- namespaces: list[SaasTargetNamespace],
163
- namespace_selector: SaasResourceTemplateTargetNamespaceSelectorV1,
164
- ) -> list[SaasTargetNamespace]:
165
- """
166
- # TODO: for whatever reason tox fails to import this from saas_files.
167
- Interestingly it works outside of tox, but to get going we simply
168
- copy the function here - very bad style but works for now
156
+ def _parse_expression(expression: str) -> Any:
157
+ try:
158
+ return parser.parse(expression)
159
+ except JsonPathParserError as e:
160
+ raise RuntimeError(
161
+ f"Invalid jsonpath expression in namespaceSelector '{expression}' :{e}"
162
+ )
169
163
 
170
- Copy of reconcile.typed_queries.saas_files.get_namespaces_by_selector
171
- """
172
164
 
173
- # json representation of all the namespaces to filter on
165
+ def is_namespace_addressed_by_selector(
166
+ namespace: SaasTargetNamespace,
167
+ namespace_selector: SaasResourceTemplateTargetNamespaceSelectorV1,
168
+ ) -> bool:
169
+ # json representation of namespace to filter on
174
170
  # remove all the None values to simplify the jsonpath expressions
175
- namespaces_as_dict = {
176
- "namespace": [ns.dict(by_alias=True, exclude_none=True) for ns in namespaces]
171
+ namespace_as_dict = {
172
+ "namespace": [namespace.dict(by_alias=True, exclude_none=True)]
177
173
  }
178
174
 
179
- def _get_namespace_by_cluster_and_name(
180
- cluster_name: str, name: str
181
- ) -> SaasTargetNamespace:
182
- for ns in namespaces:
183
- if ns.cluster.name == cluster_name and ns.name == name:
184
- return ns
185
- # this should never ever happen - just make mypy happy
186
- raise RuntimeError(f"namespace '{name}' not found in cluster '{cluster_name}'")
175
+ do_include = any(
176
+ _parse_expression(include).find(namespace_as_dict)
177
+ for include in namespace_selector.json_path_selectors.include or []
178
+ )
187
179
 
188
- filtered_namespaces: dict[str, Any] = {}
180
+ do_exclude = any(
181
+ _parse_expression(exclude).find(namespace_as_dict)
182
+ for exclude in namespace_selector.json_path_selectors.exclude or []
183
+ )
189
184
 
190
- try:
191
- for include in namespace_selector.json_path_selectors.include:
192
- for match in parser.parse(include).find(namespaces_as_dict):
193
- cluster_name = match.value["cluster"]["name"]
194
- ns_name = match.value["name"]
195
- filtered_namespaces[
196
- f"{cluster_name}-{ns_name}"
197
- ] = _get_namespace_by_cluster_and_name(cluster_name, ns_name)
198
- except JsonPathParserError as e:
199
- raise RuntimeError(
200
- f"Invalid jsonpath expression in namespaceSelector '{include}' :{e}"
201
- )
202
-
203
- try:
204
- for exclude in namespace_selector.json_path_selectors.exclude or []:
205
- for match in parser.parse(exclude).find(namespaces_as_dict):
206
- cluster_name = match.value["cluster"]["name"]
207
- ns_name = match.value["name"]
208
- filtered_namespaces.pop(f"{cluster_name}-{ns_name}", None)
209
- except JsonPathParserError as e:
210
- raise RuntimeError(
211
- f"Invalid jsonpath expression in namespaceSelector '{exclude}' :{e}"
212
- )
213
- return list(filtered_namespaces.values())
185
+ return do_include and not do_exclude