Skip to content

Commit

Permalink
Updated The LKENodePool(...).nodes attribute to only be populated wit…
Browse files Browse the repository at this point in the history
…h LKENodePoolNode objects
  • Loading branch information
ezilber-akamai committed Jul 29, 2024
1 parent 0c0e649 commit 642e3cb
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions linode_api4/objects/lke.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,22 @@ def _populate(self, json):
Parse Nodes into more useful LKENodePoolNode objects
"""
if json is not None and json != {}:
new_nodes = [
(
LKENodePoolNode(self._client, c)
if not isinstance(c, dict)
else c
)
for c in json["nodes"]
]
new_nodes = []
for c in json["nodes"]:
if isinstance(c, LKENodePoolNode):
new_nodes.append(c)
elif isinstance(c, dict):
node_id = c.get("id")
if node_id is not None:
new_nodes.append(LKENodePoolNode(self._client, c))
else:
raise ValueError(
"Node dictionary does not contain 'id' key"
)
elif isinstance(c, str):
new_nodes.append(LKENodePoolNode(self._client, c))
else:
raise TypeError("Unsupported node type: {}".format(type(c)))
json["nodes"] = new_nodes

super()._populate(json)
Expand Down

0 comments on commit 642e3cb

Please sign in to comment.