Skip to content

Commit

Permalink
chore(inventory): Change labels functionality to include anything mat…
Browse files Browse the repository at this point in the history
…ching
  • Loading branch information
Antti Myyrä committed Sep 25, 2023
1 parent 145d6b0 commit 922044e
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions plugins/inventory/upcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
elements: str
required: false
labels:
description: Populate inventory with instances having all these labels
description: Populate inventory with instances with any of these labels, either just key or value ("foo" or "bar") or as a whole tag ("foo=bar")
default: []
type: list
elements: str
Expand Down Expand Up @@ -215,19 +215,12 @@ def _filter_servers(self):
display.vv("Choosing servers by labels")
tmp = []
for server in self.servers:
disqualified = False
for wanted_label in self.get_option("labels"):
server_labels = _parse_server_labels(server.labels['label'])
if len(server_labels) == 0:
disqualified = True

for server_label in server_labels:
display.vvvv(f"Comparing {wanted_label} against {server_label}")
if wanted_label not in server_label:
disqualified = True

if not disqualified:
tmp.append(server)
if wanted_label in server_label:
tmp.append(server)

self.servers = tmp

Expand Down

0 comments on commit 922044e

Please sign in to comment.