validation rules for api token

This commit is contained in:
Bruno MATEU 2023-06-17 11:16:02 +02:00 committed by GitHub
parent 16df5aadc6
commit f0345cf7a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -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}")