Skip to content

Commit

Permalink
validate_config() will check all keys
Browse files Browse the repository at this point in the history
partly addressing #55
  • Loading branch information
JM-Lemmi committed Dec 28, 2021
1 parent 8b0094b commit db5b42f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions files/zimbra_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def main():
if ans == "n":
return
else:
logging.info("Invalid or outdated config, overwriting with default.")
create_config()
return

Expand All @@ -64,9 +65,10 @@ def validate_config() -> bool:
if not host:
logging.warning("Malformed zimbra_host. You need to include the protocol (http(s)://)!")

if not "email_domain" in config:
logging.warning("Missing email_domain parameter")
return False
for default_key, default_value in DEFAULT_CONIFG.items():
if not default_key in config:
logging.warning(f"Missing parameter: {default_key}")
return False

email_domain = re.match(r"(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]", config["email_domain"])
if not email_domain:
Expand Down

0 comments on commit db5b42f

Please sign in to comment.