From 5c4df42844a571efe0b13e9008fc0099af5d498e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Sat, 1 Jun 2024 13:26:46 +0200 Subject: [PATCH] [fix] role:tlscert_acme_inwx --- roles/tlscert_acme_inwx/files/inwx | 102 +++++++++++++++-------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/roles/tlscert_acme_inwx/files/inwx b/roles/tlscert_acme_inwx/files/inwx index dcd0140..c61dd2a 100755 --- a/roles/tlscert_acme_inwx/files/inwx +++ b/roles/tlscert_acme_inwx/files/inwx @@ -142,58 +142,60 @@ def conf_load( path : str ): global _conf_data - if (not _os.path.exists(path)): - pass - else: - conf_data_raw = _json.loads(file_read(path)) - for pair in conf_data_raw.get("url", {}).items(): - if ("host" in pair[1]): - pass - else: - raise ValueError("flawed conf: missing mandatory value 'host' for url entry '%s'" % pair[0]) - _conf_data = { - "url": convey( - ( - { - "test": { - "scheme": "https", - "host": "api.ote.domrobot.com", - "port": 443, - "path": "jsonrpc/" - }, - "production": { - "scheme": "https", - "host": "api.domrobot.com", - "port": 443, - "path": "jsonrpc/" - } + conf_data_raw = ( + _json.loads(file_read(path)) + if _os.path.exists(path) else + {} + ) + for pair in conf_data_raw.get("url", {}).items(): + if ("host" in pair[1]): + pass + else: + raise ValueError("flawed conf: missing mandatory value 'host' for url entry '%s'" % pair[0]) + _conf_data = { + "url": convey( + ( + { + "test": { + "scheme": "https", + "host": "api.ote.domrobot.com", + "port": 443, + "path": "jsonrpc/" + }, + "production": { + "scheme": "https", + "host": "api.domrobot.com", + "port": 443, + "path": "jsonrpc/" } - | - conf_data_raw.get("url", {}) - ), - [ - lambda x: x.items(), - lambda pairs: map( - lambda pair: ( - pair[0], - { - "scheme": pair[1].get("scheme", "https"), - "host": pair[1]["host"], - "port": pair[1].get("port", 443), - "path": pair[1].get("path", "jsonrpc/"), - } - ), - pairs - ), - dict, - ] + } + | + conf_data_raw.get("url", {}) ), - "environment": conf_data_raw.get("environment", "production"), - "account": { - "username": conf_data_raw.get("account", {}).get("username", None), - "password": conf_data_raw.get("account", {}).get("password", None), - } + [ + lambda x: x.items(), + lambda pairs: map( + lambda pair: ( + pair[0], + { + "scheme": pair[1].get("scheme", "https"), + "host": pair[1]["host"], + "port": pair[1].get("port", 443), + "path": pair[1].get("path", "jsonrpc/"), + } + ), + pairs + ), + dict, + ] + ), + "environment": conf_data_raw.get("environment", "production"), + "account": { + "username": conf_data_raw.get("account", {}).get("username", None), + "password": conf_data_raw.get("account", {}).get("password", None), } + } + print(_json.dumps(_conf_data, indent = "\t")) def conf_get( @@ -620,7 +622,7 @@ def main( conf_load(args.conf) ## vars - environment = (args.environment or conf_get("environment") or "production") + environment = (args.environment or conf_get("environment")) account_username = (args.username or conf_get("account.username")) account_password = (args.password or conf_get("account.password")) domain_parts = (None if (args.domain is None) else args.domain.split("."))