1
0
Fork 0

Issue #32 renaming letsencrypt test server env var

This commit is contained in:
Joao Gilberto 2022-11-10 18:43:50 -03:00
parent 607470a122
commit f7969c2deb
6 changed files with 25 additions and 10 deletions

View file

@ -174,10 +174,19 @@ class DaemonizeHAProxy:
class Certbot:
def __init__(self, certs, email, staging):
def __init__(self, certs, email, test_server):
self.certs = certs
self.email = email
self.staging = staging
self.test_server = self.set_test_server(test_server)
def set_test_server(self, test_server):
if not test_server:
return ""
if test_server.lower() in ["true", "1", "yes"]:
return "--staging"
else:
return "--server " + test_server
def check_certificates(self, hosts):
if self.email == "" or len(hosts) == 0:
@ -202,7 +211,7 @@ class Certbot:
Functions.log(Functions.CERTBOT_LOG, Functions.DEBUG, "Renew certificate for %s" % (host))
renew_certs.append(host_arg)
certbot_certonly = ('/usr/bin/certbot certonly {staging}'
certbot_certonly = ('/usr/bin/certbot certonly {test_server}'
' --standalone'
' --preferred-challenges http'
' --http-01-port 2080'
@ -213,7 +222,7 @@ class Certbot:
' --max-log-backups=0'
' {certs} --email {email}'.format(certs = ' '.join(request_certs),
email = self.email,
staging = '--staging' if self.staging else '')
test_server = self.test_server)
)
ret_reload = False

View file

@ -22,7 +22,7 @@ def start():
haproxy.haproxy("start")
haproxy.sleep()
certbot = Certbot(Consts.certs_letsencrypt, os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL"), os.getenv("EASYHAPROXY_LETSENCRYPT_STAGING", "false").lower() in ["true", "1", "yes"])
certbot = Certbot(Consts.certs_letsencrypt, os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL"), os.getenv("EASYHAPROXY_LETSENCRYPT_SERVER", "false").lower())
while True:
if old_haproxy is not None:

View file

@ -29,7 +29,7 @@ class ContainerEnv:
if (os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL")):
env_vars["letsencrypt"] = {
"email": os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL"),
"staging": os.getenv("EASYHAPROXY_LETSENCRYPT_STAGING", "false").lower() in ["true", "1", "yes"]
"server": os.getenv("EASYHAPROXY_LETSENCRYPT_SERVER", "false").lower() in ["true", "1", "yes"]
}
return env_vars

View file

@ -95,7 +95,7 @@ def test_container_env_stats_password():
"lookup_label": "easyhaproxy",
"letsencrypt": {
"email": "acme@example.org",
"staging": False
"server": False
}
} == ContainerEnv.read()
finally:
@ -103,7 +103,7 @@ def test_container_env_stats_password():
def test_container_env_letsencrypt():
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = 'acme@example.org'
os.environ['EASYHAPROXY_LETSENCRYPT_STAGING'] = 'true'
os.environ['EASYHAPROXY_LETSENCRYPT_SERVER'] = 'true'
try:
assert {
"customerrors": False,
@ -111,7 +111,7 @@ def test_container_env_letsencrypt():
"lookup_label": "easyhaproxy",
"letsencrypt": {
"email": "acme@example.org",
"staging": True
"server": True
}
} == ContainerEnv.read()
finally: