Add --stack-path CLI option for custom stack path
Allows overriding the default botserver-stack location via: - --stack-path /path/to/stack CLI argument - BOTSERVER_STACK_PATH environment variable Useful for testing botserver bootstrap in isolated temp directories.
This commit is contained in:
parent
67c971557e
commit
41f5847f56
2 changed files with 30 additions and 0 deletions
|
|
@ -20,6 +20,8 @@ impl PackageManager {
|
||||||
let os_type = detect_os();
|
let os_type = detect_os();
|
||||||
let base_path = if mode == InstallMode::Container {
|
let base_path = if mode == InstallMode::Container {
|
||||||
PathBuf::from("/opt/gbo")
|
PathBuf::from("/opt/gbo")
|
||||||
|
} else if let Ok(custom_path) = std::env::var("BOTSERVER_STACK_PATH") {
|
||||||
|
PathBuf::from(custom_path)
|
||||||
} else {
|
} else {
|
||||||
std::env::current_dir()?.join("botserver-stack")
|
std::env::current_dir()?.join("botserver-stack")
|
||||||
};
|
};
|
||||||
|
|
@ -36,6 +38,26 @@ impl PackageManager {
|
||||||
Ok(pm)
|
Ok(pm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a PackageManager with a custom base path (for testing)
|
||||||
|
pub fn with_base_path(
|
||||||
|
mode: InstallMode,
|
||||||
|
tenant: Option<String>,
|
||||||
|
base_path: PathBuf,
|
||||||
|
) -> Result<Self> {
|
||||||
|
let os_type = detect_os();
|
||||||
|
let tenant = tenant.unwrap_or_else(|| "default".to_string());
|
||||||
|
|
||||||
|
let mut pm = PackageManager {
|
||||||
|
mode,
|
||||||
|
os_type,
|
||||||
|
base_path,
|
||||||
|
tenant,
|
||||||
|
components: HashMap::new(),
|
||||||
|
};
|
||||||
|
pm.register_components();
|
||||||
|
Ok(pm)
|
||||||
|
}
|
||||||
|
|
||||||
fn register_components(&mut self) {
|
fn register_components(&mut self) {
|
||||||
self.register_tables();
|
self.register_tables();
|
||||||
self.register_cache();
|
self.register_cache();
|
||||||
|
|
|
||||||
|
|
@ -386,6 +386,14 @@ async fn main() -> std::io::Result<()> {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set custom stack path if provided (for testing)
|
||||||
|
if let Some(idx) = args.iter().position(|a| a == "--stack-path") {
|
||||||
|
if let Some(path) = args.get(idx + 1) {
|
||||||
|
std::env::set_var("BOTSERVER_STACK_PATH", path);
|
||||||
|
info!("Using custom stack path: {}", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bootstrap
|
// Bootstrap
|
||||||
trace!("Starting bootstrap process...");
|
trace!("Starting bootstrap process...");
|
||||||
let progress_tx_clone = progress_tx.clone();
|
let progress_tx_clone = progress_tx.clone();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue