Skip to content

Commit 3f53e03

Browse files
committed
Fix freeze() with YAML anchors usage
YAML parser creates object references when using YAML anchors. When one object in the tree is frozen, it affects all references to it, so when the traversal encounters a reference to already frozen object, it must not attempt to freeze it again. This commit enhances the type checks and skips freezing of already frozen objects.
1 parent 6744cf0 commit 3f53e03

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/cdn_definitions/_impl/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def freeze(node):
3434
"""
3535
Converts dict to frozendict and list to frozenlist.
3636
"""
37+
if isinstance(node, (frozenlist, frozendict)):
38+
# YAML parser creates object references when using YAML anchors.
39+
# When one object in the tree is frozen, it affects all references to it,
40+
# so when the traversal encounters a reference to already frozen object,
41+
# it must not attempt to freeze it again.
42+
return node
3743
if isinstance(node, list):
3844
# Iterating using index instead of enumeration
3945
# so we can replace the list items in place

src/cdn_definitions/data.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ rhel_open_dist:
225225
# repo_content_sync configures selective content synchronization from RHEL repos to other products.
226226
# It is used e.g. by UBI to sync content to Public CDN.
227227
repo_content_sync:
228-
stage:
228+
stage: &repo_content_sync_yaml_anchor
229229
# Source git repo contains the configuration for tooling that facilitates
230230
# the repo content sync (currently ubipop).
231231
# The configuration includes content set labels and lists with allowed and blocked packages.
@@ -237,11 +237,7 @@ repo_content_sync:
237237
populate_dot_repos: False
238238
- source: https://example.com/client-tools/data
239239
populate_dot_repos: True
240-
prod:
241-
- source: https://example.com/ubi/data
242-
populate_dot_repos: False
243-
- source: https://example.com/client-tools/data
244-
populate_dot_repos: True
240+
prod: *repo_content_sync_yaml_anchor
245241

246242
# repo_overrides can be used to define mappings between certain criteria matching CDN repos
247243
# and configuration which should be set on those repos. The intended usage is to allow

0 commit comments

Comments
 (0)