I think a command errors (Non-zero return code) instead of empty list if none are present
All checks were successful
Build and deploy Bridgeman Accessible Hashicorp Vault Implementation / deploy (push) Successful in 14s

This commit is contained in:
Alan Bridgeman 2025-12-28 16:47:41 -06:00
parent 79c2e7efbf
commit 2fff91c5b2

View file

@ -106,7 +106,7 @@ def check_app_role_exists(role_name: str) -> bool:
"""
# To use `vault list`, we need to specify the "path" (which is a slash separated string dictating the hierarchy to the thing we want to list)
role_list_path = '/'.join(['auth', 'approle', 'role'])
role_list_path = '/' + '/'.join(['auth', 'approle', 'role'])
# List the roles
role_return_code, role_output, role_err = CommandRunner.run_command(f'vault list --format=json {role_list_path}')
@ -116,7 +116,7 @@ def check_app_role_exists(role_name: str) -> bool:
logging.error('Failed to list AppRole roles')
logging.error('Role Output: ' + role_output)
logging.error('Role Error: ' + role_err)
raise RuntimeError('Failed to list AppRole roles')
#raise RuntimeError('Failed to list AppRole roles')
# Parse the output
roles = json.loads(role_output)