Skip to content

Commit

Permalink
refactor(module): add get_acme_bin function
Browse files Browse the repository at this point in the history
  • Loading branch information
genaumann committed Jan 10, 2024
1 parent b54956a commit 289dffa
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions _modules/acme_sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@

log = logging.getLogger(__name__)

def _get_acme_bin(
script_path,
home_dir
):

acme_bin = script_path if script_path else f"{home_dir}/.acme.sh/acme.sh"
if not salt.utils.path.which_bin([acme_bin]):
raise CommandNotFoundError("acme.sh script is not available. Specify the absolute script path in `script_path`")

return acme_bin

def install(
email,
user='root',
Expand Down Expand Up @@ -158,10 +169,7 @@ def cert(
__context__["retcode"] = 1
return "Install socat to use standalone mode first"

# check command exist
acme_bin = script_path if script_path else f"{home_dir}/.acme.sh/acme.sh"
if not salt.utils.path.which_bin([acme_bin]):
raise CommandNotFoundError("acme.sh script is not available. Specify the absolute script path in `script_path`")
acme_bin = _get_acme_bin(script_path, home_dir)

# check keysize
possible_keylength = ["ec-256", "ec-384", "ec-521", "2048", "3072", "4096"]
Expand Down

0 comments on commit 289dffa

Please sign in to comment.