From dc60bd1654cea286b740ce08e625b8f7c7673e9f Mon Sep 17 00:00:00 2001 From: Thomas Draebing Date: Wed, 29 Apr 2020 17:33:51 +0200 Subject: [PATCH] Fix installation if TLS verification is skipped The installation failed, if TLS verification was disabled and no CA certificate was given in the configuration. This happened because the installation script always expected the CA certificate. The installation now only expects the certificate, if TLS verification is enabled. Change-Id: I5429fc1ee0d230c74cc0689607cf2736d6520030 --- subcommands/install.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/subcommands/install.py b/subcommands/install.py index 4dc46ac..9803bce 100644 --- a/subcommands/install.py +++ b/subcommands/install.py @@ -96,8 +96,14 @@ def _create_promtail_configs(config, output_dir): os.remove(os.path.join(output_dir, "promtail.yaml")) - with open(os.path.join(output_dir, "promtail", "promtail.ca.crt"), "w") as f: - f.write(config["tls"]["caCert"]) + if not config["tls"]["skipVerify"]: + try: + with open( + os.path.join(output_dir, "promtail", "promtail.ca.crt"), "w" + ) as f: + f.write(config["tls"]["caCert"]) + except TypeError: + print("CA certificate for TLS verification has to be given.") def _download_promtail(output_dir):