Skip to content

Commit

Permalink
fix: check for labels in json dict
Browse files Browse the repository at this point in the history
  • Loading branch information
jarv committed Aug 30, 2023
1 parent 84503b7 commit 3714be2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/inventory/gcp_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def hostname(self):
for order in self.hostname_ordering:
name = None
if order.startswith("labels."):
name = self.json["labels"].get(order[7:])
if "labels" in self.json:
name = self.json["labels"].get(order[7:])
elif order == "public_ip":
name = self._get_publicip()
elif order == "private_ip":
Expand Down

0 comments on commit 3714be2

Please sign in to comment.