Fix: initialize secrets manager when remote Vault detected, even without init.json
All checks were successful
BotServer CI/CD / build (push) Successful in 5m9s

- main.rs: Skip init.json check when VAULT_ADDR points to remote server
- This allows botserver to read database credentials from Vault in production
- Without this fix, database URL falls back to localhost and connection fails
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-03 08:22:06 -03:00
parent 65e7db5acd
commit eece6831b4

View file

@ -207,11 +207,16 @@ async fn main() -> std::io::Result<()> {
let env_path_early = std::path::Path::new("./.env");
let vault_init_path_early = std::path::Path::new("./botserver-stack/conf/vault/init.json");
let bootstrap_ready = env_path_early.exists() && vault_init_path_early.exists() && {
let vault_addr = std::env::var("VAULT_ADDR").unwrap_or_default();
let is_remote_vault = !vault_addr.is_empty()
&& !vault_addr.contains("localhost")
&& !vault_addr.contains("127.0.0.1");
let bootstrap_ready = is_remote_vault || (env_path_early.exists() && vault_init_path_early.exists() && {
std::fs::read_to_string(env_path_early)
.map(|content| content.contains("VAULT_TOKEN="))
.unwrap_or(false)
};
});
if bootstrap_ready {
if let Err(e) = crate::core::shared::utils::init_secrets_manager().await {