Remove tables install from bootstrap

The tables component is now installed by default. The install command no
longer installs it as part of the bootstrap process.
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-10-20 07:34:06 -03:00
parent f8d4e8925f
commit ed93f70f94
4 changed files with 71 additions and 28 deletions

View file

@ -1,2 +1,2 @@
clear && \ clear && \
RUST_LOG=trace cargo run install tables RUST_LOG=trace cargo run

View file

@ -1,7 +1,7 @@
use crate::config::AppConfig; use crate::config::AppConfig;
use crate::package_manager::{InstallMode, PackageManager}; use crate::package_manager::{InstallMode, PackageManager};
use anyhow::Result; use anyhow::Result;
use log::{debug, trace, warn}; use log::{trace, warn};
use rand::distr::Alphanumeric; use rand::distr::Alphanumeric;
use rand::rngs::ThreadRng; use rand::rngs::ThreadRng;
use rand::Rng; use rand::Rng;
@ -14,7 +14,11 @@ pub struct BootstrapManager {
impl BootstrapManager { impl BootstrapManager {
pub fn new(install_mode: InstallMode, tenant: Option<String>) -> Self { pub fn new(install_mode: InstallMode, tenant: Option<String>) -> Self {
trace!("Initializing BootstrapManager with mode {:?} and tenant {:?}", install_mode, tenant); trace!(
"Initializing BootstrapManager with mode {:?} and tenant {:?}",
install_mode,
tenant
);
Self { Self {
install_mode, install_mode,
tenant, tenant,
@ -24,9 +28,26 @@ impl BootstrapManager {
pub fn start_all(&mut self) -> Result<()> { pub fn start_all(&mut self) -> Result<()> {
let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?; let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?;
let components = vec![ let components = vec![
"tables", "cache", "drive", "llm", "email", "proxy", "directory", "tables",
"alm", "alm_ci", "dns", "webmail", "meeting", "table_editor", "cache",
"doc_editor", "desktop", "devtools", "bot", "system", "vector_db", "host" "drive",
"llm",
"email",
"proxy",
"directory",
"alm",
"alm_ci",
"dns",
"webmail",
"meeting",
"table_editor",
"doc_editor",
"desktop",
"devtools",
"bot",
"system",
"vector_db",
"host",
]; ];
for component in components { for component in components {
@ -42,7 +63,7 @@ impl BootstrapManager {
pub fn bootstrap(&mut self) -> Result<AppConfig> { pub fn bootstrap(&mut self) -> Result<AppConfig> {
let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?; let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?;
let required_components = vec!["tables", "cache", "drive", "llm"]; let required_components = vec!["tables"]; // , "cache", "drive", "llm"];
for component in required_components { for component in required_components {
if !pm.is_installed(component) { if !pm.is_installed(component) {
@ -55,7 +76,9 @@ impl BootstrapManager {
} }
} }
let config = match diesel::Connection::establish("postgres://botserver:botserver@localhost:5432/botserver") { let config = match diesel::Connection::establish(
"postgres://botserver:botserver@localhost:5432/botserver",
) {
Ok(mut conn) => { Ok(mut conn) => {
self.setup_secure_credentials(&mut conn)?; self.setup_secure_credentials(&mut conn)?;
AppConfig::from_database(&mut conn) AppConfig::from_database(&mut conn)
@ -74,7 +97,8 @@ impl BootstrapManager {
use diesel::prelude::*; use diesel::prelude::*;
use uuid::Uuid; use uuid::Uuid;
let farm_password = std::env::var("FARM_PASSWORD").unwrap_or_else(|_| self.generate_secure_password(32)); let farm_password =
std::env::var("FARM_PASSWORD").unwrap_or_else(|_| self.generate_secure_password(32));
let db_password = self.generate_secure_password(16); let db_password = self.generate_secure_password(16);
let encrypted_db_password = self.encrypt_password(&db_password, &farm_password); let encrypted_db_password = self.encrypt_password(&db_password, &farm_password);
@ -99,7 +123,7 @@ impl BootstrapManager {
} }
fn generate_secure_password(&self, length: usize) -> String { fn generate_secure_password(&self, length: usize) -> String {
let mut rng: ThreadRng = rand::thread_rng(); let rng: ThreadRng = rand::rng();
rng.sample_iter(&Alphanumeric) rng.sample_iter(&Alphanumeric)
.take(length) .take(length)
.map(char::from) .map(char::from)

View file

@ -648,6 +648,7 @@ impl PackageManager {
); );
Ok(std::process::Command::new("sh") Ok(std::process::Command::new("sh")
.current_dir(&bin_path)
.arg("-c") .arg("-c")
.arg(&rendered_cmd) .arg(&rendered_cmd)
.spawn()?) .spawn()?)
@ -657,7 +658,7 @@ impl PackageManager {
} }
fn generate_secure_password(&self, length: usize) -> String { fn generate_secure_password(&self, length: usize) -> String {
let mut rng: ThreadRng = rand::thread_rng(); let rng: ThreadRng = rand::rng();
rng.sample_iter(&Alphanumeric) rng.sample_iter(&Alphanumeric)
.take(length) .take(length)
.map(char::from) .map(char::from)

View file

@ -1,4 +1,8 @@
use log::{debug, trace}; use crate::config::AIConfig;
use futures_util::StreamExt;
use indicatif::{ProgressBar, ProgressStyle};
use log::trace;
use reqwest::Client;
use rhai::{Array, Dynamic}; use rhai::{Array, Dynamic};
use serde_json::Value; use serde_json::Value;
use smartstring::SmartString; use smartstring::SmartString;
@ -7,14 +11,13 @@ use std::fs::File;
use std::io::BufReader; use std::io::BufReader;
use std::path::Path; use std::path::Path;
use tokio::fs::File as TokioFile; use tokio::fs::File as TokioFile;
use zip::ZipArchive;
use crate::config::AIConfig;
use reqwest::Client;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use indicatif::{ProgressBar, ProgressStyle}; use zip::ZipArchive;
use futures_util::StreamExt;
pub fn extract_zip_recursive(zip_path: &Path, destination_path: &Path) -> Result<(), Box<dyn std::error::Error>> { pub fn extract_zip_recursive(
zip_path: &Path,
destination_path: &Path,
) -> Result<(), Box<dyn std::error::Error>> {
let file = File::open(zip_path)?; let file = File::open(zip_path)?;
let buf_reader = BufReader::new(file); let buf_reader = BufReader::new(file);
let mut archive = ZipArchive::new(buf_reader)?; let mut archive = ZipArchive::new(buf_reader)?;
@ -75,7 +78,10 @@ pub fn to_array(value: Dynamic) -> Array {
} }
} }
pub async fn download_file(url: &str, output_path: &str) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { pub async fn download_file(
url: &str,
output_path: &str,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let url = url.to_string(); let url = url.to_string();
let output_path = output_path.to_string(); let output_path = output_path.to_string();
@ -123,14 +129,20 @@ pub fn parse_filter(filter_str: &str) -> Result<(String, Vec<String>), Box<dyn E
let column = parts[0].trim(); let column = parts[0].trim();
let value = parts[1].trim(); let value = parts[1].trim();
if !column.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') { if !column
.chars()
.all(|c| c.is_ascii_alphanumeric() || c == '_')
{
return Err("Invalid column name in filter".into()); return Err("Invalid column name in filter".into());
} }
Ok((format!("{} = $1", column), vec![value.to_string()])) Ok((format!("{} = $1", column), vec![value.to_string()]))
} }
pub fn parse_filter_with_offset(filter_str: &str, offset: usize) -> Result<(String, Vec<String>), Box<dyn Error>> { pub fn parse_filter_with_offset(
filter_str: &str,
offset: usize,
) -> Result<(String, Vec<String>), Box<dyn Error>> {
let mut clauses = Vec::new(); let mut clauses = Vec::new();
let mut params = Vec::new(); let mut params = Vec::new();
@ -143,7 +155,10 @@ pub fn parse_filter_with_offset(filter_str: &str, offset: usize) -> Result<(Stri
let column = parts[0].trim(); let column = parts[0].trim();
let value = parts[1].trim(); let value = parts[1].trim();
if !column.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') { if !column
.chars()
.all(|c| c.is_ascii_alphanumeric() || c == '_')
{
return Err("Invalid column name".into()); return Err("Invalid column name".into());
} }
@ -154,6 +169,9 @@ pub fn parse_filter_with_offset(filter_str: &str, offset: usize) -> Result<(Stri
Ok((clauses.join(" AND "), params)) Ok((clauses.join(" AND "), params))
} }
pub async fn call_llm(prompt: &str, _ai_config: &AIConfig) -> Result<String, Box<dyn std::error::Error + Send + Sync>> { pub async fn call_llm(
prompt: &str,
_ai_config: &AIConfig,
) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
Ok(format!("Generated response for: {}", prompt)) Ok(format!("Generated response for: {}", prompt))
} }