Skip to content

Commit

Permalink
Don't show index if using a filter on inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCallahan committed Aug 7, 2023
1 parent 6f1bdee commit 773942f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions broker/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,13 @@ def inventory(details, sync, filter):
emit_data.append(host)
if (display_name := host.get("hostname")) is None:
display_name = host.get("name")
# if we're filtering, then don't show an index.
# Otherwise, a user might perform an action on the incorrect (unfiltered) index.
index = f"{num}: " if filter is None else ""
if details:
logger.info(f"{num}: {display_name}:\n{helpers.yaml_format(host)}")
logger.info(f"{index}{display_name}:\n{helpers.yaml_format(host)}")
else:
logger.info(f"{num}: {display_name}")
logger.info(f"{index}{display_name}")
helpers.emit({"inventory": emit_data})


Expand Down

0 comments on commit 773942f

Please sign in to comment.