allow list of domains instead of dict

5-trigger-hooks-after-certificate-renewal
HgO 2020-12-25 20:32:30 +01:00
parent bfcd643dac
commit 58496cdb40
1 changed files with 14 additions and 1 deletions

View File

@ -345,6 +345,19 @@ def main():
logging.error(f"Unable to load config file: {e}") logging.error(f"Unable to load config file: {e}")
return 1 return 1
if isinstance(config["domains"], list):
domains = {domain.name: domain for domain in config["domains"]}
if len(domains) != len(config["domains"]):
domain_uniques = set()
domain_duplicates = set()
for domain in config["domains"]:
if domain.name not in domain_uniques:
domain_uniques.add(domain.name)
else:
domain_duplicates.add(domain.name)
logging.error(f"Duplicate domain name(s) found: {domain_uniques}")
return 2
try: try:
domains_to_renew = [] domains_to_renew = []
for domain_name, domain_details in config["domains"].items(): for domain_name, domain_details in config["domains"].items():
@ -385,7 +398,7 @@ def main():
domain.renew_cert(challenge, force=args.force) domain.renew_cert(challenge, force=args.force)
except Exception as e: except Exception as e:
logging.exception(e) logging.exception(e)
return 2 return 3
if __name__ == '__main__': if __name__ == '__main__':