Skip to content

Commit

Permalink
avoid recursion in case of non dict yaml element (#582)
Browse files Browse the repository at this point in the history
Signed-off-by: haim-kermany <[email protected]>
  • Loading branch information
haim-kermany authored Aug 14, 2023
1 parent 1190864 commit 14d0dbe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 4 additions & 6 deletions nca/NetworkConfig/TopologyObjectsFinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ def add_eps_from_yaml(self, yaml_obj, kind_override=None):
:param kind_override: if set, ignoring the object kind and using this param instead
:return: None
"""
if isinstance(yaml_obj, list):
for ep_sub_list in yaml_obj: # e.g. when we have a list of lists - call recursively for each list
self.add_eps_from_yaml(ep_sub_list)
return
if not isinstance(yaml_obj, dict):
try:
for ep_sub_list in yaml_obj: # e.g. when we have a list of lists - call recursively for each list
self.add_eps_from_yaml(ep_sub_list)
except TypeError:
pass
return

kind = yaml_obj.get('kind') if not kind_override else kind_override
if kind in ['List', 'PodList', 'WorkloadEndpointList', 'HostEndpointList', 'NetworkSetList',
'GlobalNetworkSetList']:
Expand Down
5 changes: 5 additions & 0 deletions tests/bad_yamls/list_of_strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
"esnext.global-this",
"esnext.promise.all-settled",
"esnext.string.match-all"
]

0 comments on commit 14d0dbe

Please sign in to comment.