Skip to content

Commit

Permalink
fix up acl_app to capture stderr output from acl:list
Browse files Browse the repository at this point in the history
  • Loading branch information
dvessey-fes authored and ltalirz committed Dec 19, 2022
1 parent 2159005 commit e7eaeee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library/dokku_acl_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def dokku_acl_app_set(data):

# get users for app
command = "dokku acl:list {0}".format(data["app"])
output, error = subprocess_check_output(command)
output, error = subprocess_check_output(command, redirect_stderr=True)

if error is not None:
meta["error"] = error
Expand Down
5 changes: 3 additions & 2 deletions library/dokku_acl_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ def dokku_acl_service_set(data):
has_changed = False

# get users for service
command = "dokku --quiet acl:list-service {0} {1}".format(data["type"], data["service"])
command = "dokku --quiet acl:list-service {0} {1}".format(
data["type"], data["service"]
)
output, error = subprocess_check_output(command, redirect_stderr=True)

if error is not None:
meta["error"] = error
return (is_error, has_changed, meta)


users = set(output)

if data["state"] == "absent":
Expand Down
5 changes: 4 additions & 1 deletion module_utils/dokku_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ def force_list(var):
return var
return list(var)


# Add an option to redirect stderr to stdout, because some dokku commands output to stderr
def subprocess_check_output(command, split="\n", redirect_stderr=False):
error = None
output = []
try:
if redirect_stderr:
output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
output = subprocess.check_output(
command, shell=True, stderr=subprocess.STDOUT
)
else:
output = subprocess.check_output(command, shell=True)
if isinstance(output, bytes):
Expand Down

0 comments on commit e7eaeee

Please sign in to comment.