From 5e68905e1eb5629a9811011538a00d1516263a8b Mon Sep 17 00:00:00 2001 From: Benjamin Hanzelmann Date: Tue, 11 Aug 2015 11:08:16 +0200 Subject: [PATCH] verify that url: is actually in the configuration --- zmon_cli/main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/zmon_cli/main.py b/zmon_cli/main.py index 6d66fda..57e684d 100644 --- a/zmon_cli/main.py +++ b/zmon_cli/main.py @@ -139,9 +139,17 @@ def get_config_data(): if os.path.exists(fn): with open(fn) as fd: data = yaml.safe_load(fd) + else: + raise Exception("Config file not found: ~/.zmon-cli.yaml") + + return validate_config(data) + +def validate_config(data): if "user" not in data or "password" not in data: - raise Exception("Config file not found/properly configured: ~/.zmon-cli.yaml with user: and password:") + raise Exception("Config file not properly configured: keys 'user' and 'password' are missing") + if "url" not in data: + raise Exception("Config file not properly configured: key 'url' is missing") return data