Skip to content

Commit

Permalink
Move file arg evaluation to VMBroker's init
Browse files Browse the repository at this point in the history
This improves parity between CLI and library use.
Suppressed warnings on inventory load
fixes #134
  • Loading branch information
JacobCallahan committed Nov 3, 2021
1 parent e14f399 commit 63f2bed
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
python-version: [3.8, 3.9, 3.10]

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
venv/
venv*/
build/
develop-eggs/
dist/
Expand Down
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
History
=======

0.1.28 (2021-11-03)
------------------

+ Suppress warnings on inventory load
+ Move file arg evaluation to VMBroker's init

0.1.27 (2021-10-29)
------------------

Expand Down
2 changes: 0 additions & 2 deletions broker/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def checkout(ctx, background, nick, count, args_file, **kwargs):
for key, val in zip(ctx.args[::2], ctx.args[1::2])
}
)
broker_args = helpers.resolve_file_args(broker_args)
if background:
helpers.fork_broker()
broker_inst = VMBroker(**broker_args)
Expand Down Expand Up @@ -375,7 +374,6 @@ def execute(ctx, background, nick, output_format, artifacts, args_file, **kwargs
for key, val in zip(ctx.args[::2], ctx.args[1::2])
}
)
broker_args = helpers.resolve_file_args(broker_args)
if background:
helpers.fork_broker()
broker_inst = VMBroker(**broker_args)
Expand Down
7 changes: 4 additions & 3 deletions broker/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ def resolve_nick(nick):
return settings.settings.NICKS[nick].to_dict()


def load_file(file):
def load_file(file, warn=True):
"""Verifies existence and loads data from json and yaml files"""
file = Path(file)
if not file.exists() or file.suffix not in (".json", ".yaml", ".yml"):
logger.warning(f"File {file.absolute()} is invalid or does not exist.")
if warn:
logger.warning(f"File {file.absolute()} is invalid or does not exist.")
return []
loader_args = {}
if file.suffix == ".json":
Expand Down Expand Up @@ -202,7 +203,7 @@ def load_inventory(filter=None):
inventory_file = settings.BROKER_DIRECTORY.joinpath(
settings.settings.INVENTORY_FILE
)
inv_data = load_file(inventory_file)
inv_data = load_file(inventory_file, warn=False)
return inv_data if not filter else inventory_filter(inv_data, filter)


Expand Down

0 comments on commit 63f2bed

Please sign in to comment.