From cd2a3c6b9c30a54a0a4a53a5829d779c731855a3 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Wed, 8 Feb 2023 20:29:40 -0600 Subject: [PATCH] Fix Runtime Errors --- docs/docker-environment.md | 2 +- helm/easyhaproxy/Chart.yaml | 2 +- src/functions/__init__.py | 11 ++++++----- src/main.py | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/docker-environment.md b/docs/docker-environment.md index a8f8393..0b9ec11 100644 --- a/docs/docker-environment.md +++ b/docs/docker-environment.md @@ -5,7 +5,7 @@ | EASYHAPROXY_DISCOVER | How the services will be discovered to create `haproxy.cfg`: `static`, `docker`, `swarm` or `kubernetes` | **required** | | EASYHAPROXY_LABEL_PREFIX | (Optional) The key will search for matching resources. | `easyhaproxy` | | EASYHAPROXY_LETSENCRYPT_EMAIL | (Optional) The email will be used to request the certificate to Letsencrypt | *empty* | -| EASYHAPROXY_LETSENCRYPT_SERVER | (Optional) Can be true or 'schema://domain.tld'. If set, will try to connect to the Letsencrypt test server | false | +| EASYHAPROXY_LETSENCRYPT_SERVER | (Optional) Can be `staging` or 'schema://domain.tld'. If set, will try to connect to the Letsencrypt test server | *empty* | | EASYHAPROXY_SSL_MODE | (Optional) `strict` supports only the most recent TLS version; `default` good SSL integration with recent browsers; `loose` supports all old SSL protocols for old browsers (not recommended). | `default`| | EASYHAPROXY_REFRESH_CONF | (Optional) Check configuration every N seconds. | 10 | | EASYHAPROXY_LOG_LEVEL | (Optional) The log level for EasyHAproxy messages. Available: TRACE,DEBUG,INFO,WARN,ERROR,FATAL | DEBUG | diff --git a/helm/easyhaproxy/Chart.yaml b/helm/easyhaproxy/Chart.yaml index 724ec79..3bcc5b0 100644 --- a/helm/easyhaproxy/Chart.yaml +++ b/helm/easyhaproxy/Chart.yaml @@ -21,4 +21,4 @@ version: 0.1.4 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "4.3.0" +appVersion: "4.2.0" diff --git a/src/functions/__init__.py b/src/functions/__init__.py index 387a870..d174dcf 100644 --- a/src/functions/__init__.py +++ b/src/functions/__init__.py @@ -180,13 +180,12 @@ class Certbot: 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"]: + if test_server.lower() == "staging": return "--staging" - else: + elif test_server.lower().startswith("http"): return "--server " + test_server + else: + return "" def check_certificates(self, hosts): if self.email == "" or len(hosts) == 0: @@ -247,6 +246,8 @@ class Certbot: def find_live_certificates(self): letsencrypt_certs = "/etc/letsencrypt/live/" + if not os.path.exists(letsencrypt_certs): + return for item in os.listdir(letsencrypt_certs): path = os.path.join(letsencrypt_certs, item) if os.path.isdir(path): diff --git a/src/main.py b/src/main.py index 0631ef6..34e29d8 100644 --- a/src/main.py +++ b/src/main.py @@ -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_SERVER", "false").lower()) + certbot = Certbot(Consts.certs_letsencrypt, os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL"), os.getenv("EASYHAPROXY_LETSENCRYPT_SERVER", "").lower()) while True: if old_haproxy is not None: @@ -70,4 +70,4 @@ def main(): start() if __name__ == '__main__': - main() \ No newline at end of file + main()