Skip to content

Commit 72a4610

Browse files
Updated The LKENodePool(...).nodes attribute to only be populated with LKENodePoolNode objects
1 parent 0c0e649 commit 72a4610

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

linode_api4/objects/lke.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,20 @@ def _populate(self, json):
146146
Parse Nodes into more useful LKENodePoolNode objects
147147
"""
148148
if json is not None and json != {}:
149-
new_nodes = [
150-
(
151-
LKENodePoolNode(self._client, c)
152-
if not isinstance(c, dict)
153-
else c
154-
)
155-
for c in json["nodes"]
156-
]
149+
new_nodes = []
150+
for c in json["nodes"]:
151+
if isinstance(c, dict):
152+
node_id = c.get("id")
153+
if node_id is not None:
154+
new_nodes.append(LKENodePoolNode(self._client, c))
155+
else:
156+
raise ValueError(
157+
"Node dictionary does not contain 'id' key"
158+
)
159+
elif isinstance(c, str):
160+
new_nodes.append(LKENodePoolNode(self._client, c))
161+
else:
162+
raise TypeError("Unsupported node type: {}".format(type(c)))
157163
json["nodes"] = new_nodes
158164

159165
super()._populate(json)

0 commit comments

Comments
 (0)