Skip to content

Commit 14d0dbe

Browse files
authored
avoid recursion in case of non dict yaml element (#582)
Signed-off-by: haim-kermany <[email protected]>
1 parent 1190864 commit 14d0dbe

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

nca/NetworkConfig/TopologyObjectsFinder.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ def add_eps_from_yaml(self, yaml_obj, kind_override=None):
4747
:param kind_override: if set, ignoring the object kind and using this param instead
4848
:return: None
4949
"""
50+
if isinstance(yaml_obj, list):
51+
for ep_sub_list in yaml_obj: # e.g. when we have a list of lists - call recursively for each list
52+
self.add_eps_from_yaml(ep_sub_list)
53+
return
5054
if not isinstance(yaml_obj, dict):
51-
try:
52-
for ep_sub_list in yaml_obj: # e.g. when we have a list of lists - call recursively for each list
53-
self.add_eps_from_yaml(ep_sub_list)
54-
except TypeError:
55-
pass
5655
return
57-
5856
kind = yaml_obj.get('kind') if not kind_override else kind_override
5957
if kind in ['List', 'PodList', 'WorkloadEndpointList', 'HostEndpointList', 'NetworkSetList',
6058
'GlobalNetworkSetList']:

tests/bad_yamls/list_of_strings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
"esnext.global-this",
3+
"esnext.promise.all-settled",
4+
"esnext.string.match-all"
5+
]

0 commit comments

Comments
 (0)