Skip to content

Commit

Permalink
ANS-5: improve readibility
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienDucourthial committed Feb 11, 2025
1 parent 99591e8 commit 3499d76
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/action/horizon_renew.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def run(self, tmp=None, task_vars=None):
content = self._get_content()

if "mode" in content:
should_generate_csr = content["mode"] == "decentralized" and content['csr'] is None and content["private_key"] is not None
is_decentralized = content["mode"] == "decentralized"
has_no_csr = content.get("csr") is None
has_private_key = content.get("private_key") is not None

should_generate_csr = is_decentralized and has_no_csr and has_private_key

if content["mode"] == "centralized" and content["csr"] is not None:
raise AnsibleError("Parameter csr cannot be used in centralized mode.")
Expand Down Expand Up @@ -59,7 +63,7 @@ def run(self, tmp=None, task_vars=None):
result["p12_password"] = response["password"]["value"]
result["key"] = HorizonCrypto.get_key_from_p12(response["pkcs12"]["value"],
response["password"]["value"])

except HorizonError as e:
raise AnsibleError(e.full_message)

Expand Down

0 comments on commit 3499d76

Please sign in to comment.