From 48708436df6c8dcc2815ac4afa35d561bc8459b9 Mon Sep 17 00:00:00 2001 From: jaydee Date: Tue, 10 Feb 2026 21:33:11 +0100 Subject: [PATCH] build --- main.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/main.py b/main.py index e27e7a2..a28e332 100755 --- a/main.py +++ b/main.py @@ -26,23 +26,25 @@ from prompt_toolkit.shortcuts import checkboxlist_dialog from prompt_toolkit.shortcuts import radiolist_dialog -# VAULT_ADDR = os.environ.get("VAULT_ADDR", "http://192.168.77.101:8200") -VAULT_ADDR = os.environ.get("VAULT_ADDR", "https://vault.sectorq.eu") -try: - VAULT_TOKEN = os.environ.get("VAULT_TOKEN") - if VAULT_TOKEN is None: - raise KeyError -except KeyError: - VAULT_TOKEN = prompt("Valult root token : ", is_password=True) -os.environ["VAULT_TOKEN"] = VAULT_TOKEN +def setup_vault(): + # VAULT_ADDR = os.environ.get("VAULT_ADDR", "http://192.168.77.101:8200") + VAULT_ADDR = os.environ.get("VAULT_ADDR", "https://vault.sectorq.eu") + try: + VAULT_TOKEN = os.environ.get("VAULT_TOKEN") + if VAULT_TOKEN is None: + raise KeyError + except KeyError: + VAULT_TOKEN = prompt("Valult root token : ", is_password=True) + os.environ["VAULT_TOKEN"] = VAULT_TOKEN -client = hvac.Client(url=VAULT_ADDR, token=VAULT_TOKEN) -# Check if connected -if client.is_authenticated(): - print("Connected to Vault") -else: - raise Exception("Failed to authenticate with Vault") -# Specify the mount point of your KV engine + vclient = hvac.Client(url=VAULT_ADDR, token=VAULT_TOKEN) + # Check if connected + if vclient.is_authenticated(): + print("Connected to Vault") + else: + raise Exception("Failed to authenticate with Vault") + # Specify the mount point of your KV engine + return vclient VERSION = "0.1.55" @@ -158,7 +160,8 @@ parser.add_argument( args = parser.parse_args() print("Running version:", VERSION) print("Environment:", args.site) -args.client = client + +args.client = setup_vault() if args.site is not None: cur_config["PORTAINER_SITE"] = args.site if args.endpoint_id is not None: