Skip to content

Commit

Permalink
fix: check for labels in json dict when using them for hostnames
Browse files Browse the repository at this point in the history
  • Loading branch information
SirGitsalot authored Aug 31, 2023
2 parents 84503b7 + 3714be2 commit 85603ae
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 85603ae

Please sign in to comment.