From 1ca7e9b6403cee130c96c502358e847264166165 Mon Sep 17 00:00:00 2001 From: Bruno MATEU Date: Sat, 17 Jun 2023 11:16:02 +0200 Subject: [PATCH] validation rules for api token --- prometheuspvesd/cli.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/prometheuspvesd/cli.py b/prometheuspvesd/cli.py index 1e0fb8d..71ab27b 100644 --- a/prometheuspvesd/cli.py +++ b/prometheuspvesd/cli.py @@ -119,6 +119,12 @@ class PrometheusSD: for name, value in required: if not value: self.log.sysexit_with_message(f"Option '{name}' is required but not set") + + if config.config["pve"]["token_name"] and not config.config["pve"]["token_value"]: + self.log.sysexit_with_message(f"Option 'pve.token_name' require 'pve.token_value' to be set") + + if not config.config["pve"]["token_name"] and not config.config["pve"]["token_value"] and not config.config["pve"]["password"]: + self.log.sysexit_with_message(f"Neither password nor API token have been set for pve authentication") self.logger.info(f"Using config file {config.config_file}")