Refactor container definitions
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use clap::Parser;
|
||||
use container::agent::{AgentConfig, AgentContainerConfig, AgentContainerInfo, NginxConfig};
|
||||
use container::start_attached;
|
||||
use container::types::ConfigInfoType;
|
||||
use container::{Config, agent};
|
||||
|
||||
use container::db::DBInfo;
|
||||
use container::{
|
||||
Config,
|
||||
containers::{
|
||||
ConfigInfoType,
|
||||
agent::{AgentConfig, AgentContainerConfig, AgentContainerInfo, NginxConfig},
|
||||
db::DBInfo,
|
||||
},
|
||||
start_attached,
|
||||
};
|
||||
|
||||
/// Command line arguments
|
||||
#[derive(Parser, Debug)]
|
||||
@@ -65,7 +68,7 @@ async fn main() {
|
||||
println!("Starting container with database type: {}", args.db_type);
|
||||
let db_config = match args.db_type.to_lowercase().as_str() {
|
||||
"postgres" | "pg" | "pgsql" => {
|
||||
use container::db::postgresql::PostgreSQLContainer;
|
||||
use container::containers::db::postgresql::PostgreSQLContainer;
|
||||
println!("Using PostgreSQL database");
|
||||
PostgreSQLContainer::new(None)
|
||||
.await
|
||||
@@ -74,7 +77,7 @@ async fn main() {
|
||||
}
|
||||
"sqlite" | "sql" => {
|
||||
println!("Using SQLite database");
|
||||
use container::db::sqlite::SQLiteContainer;
|
||||
use container::containers::db::sqlite::SQLiteContainer;
|
||||
SQLiteContainer::new(None)
|
||||
.await
|
||||
.get_db_container_config_info()
|
||||
@@ -89,7 +92,7 @@ async fn main() {
|
||||
|
||||
let agent_container = if let Some(agent_config) = &args.agent_container_config {
|
||||
println!(
|
||||
"Agent container will be used with socket path: {} and nginx config dir: {}",
|
||||
"Agent container will be used with socket folder: {} and nginx config dir: {}",
|
||||
agent_config.agent_config.sock_folder, agent_config.agent_config.nginx_config_dir
|
||||
);
|
||||
Some(agent_config.get_unstarted_container().await)
|
||||
@@ -168,6 +171,7 @@ async fn parse_args() -> ParsedArgs {
|
||||
ParsedArgs {
|
||||
db_type: args.db_type,
|
||||
agent_container_config: Some(AgentContainerConfig {
|
||||
// TODO: allow customization of these fields via CLI args
|
||||
image: "yanpm-agent".to_string(),
|
||||
tag: "latest".to_string(),
|
||||
container_name: format!("yanpm-agent-container-{}", time),
|
||||
|
||||
Reference in New Issue
Block a user