Skip to content

Commit

Permalink
relax require_one
Browse files Browse the repository at this point in the history
the require_one method would always raise a SilentConfigurationError on
an empty list even if strict==False. Returning None in that case is
more appropriate
  • Loading branch information
PhilTaken committed Sep 6, 2024
1 parent 3ddc26c commit 2667f1b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/batou/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,9 @@ def require_one(
key, host
)
)
elif len(resources) == 0:
elif len(resources) == 0 and strict:
raise SilentConfigurationError()
return resources[0]
return resources[0] if resources else None

def assert_cmd(self, *args, **kw):
"""Assert that given command returns successfully, raise
Expand Down

0 comments on commit 2667f1b

Please sign in to comment.