42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
#[derive(Default)]
|
|
pub struct OptionalContainerConfig {
|
|
pub image: Option<String>,
|
|
pub tag: Option<String>,
|
|
pub container_name: Option<String>,
|
|
pub database_name: Option<String>,
|
|
pub user: Option<String>,
|
|
pub password: Option<String>,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct DatabaseContainerConfig {
|
|
pub image: String,
|
|
pub tag: String,
|
|
pub container_name: String,
|
|
pub database_name: String,
|
|
pub user: String,
|
|
pub password: String,
|
|
}
|
|
|
|
impl OptionalContainerConfig {
|
|
pub fn fill_with(&self, other: &DatabaseContainerConfig) -> DatabaseContainerConfig {
|
|
DatabaseContainerConfig {
|
|
image: self.image.clone().unwrap_or_else(|| other.image.clone()),
|
|
tag: self.tag.clone().unwrap_or_else(|| other.tag.clone()),
|
|
container_name: self
|
|
.container_name
|
|
.clone()
|
|
.unwrap_or_else(|| other.container_name.clone()),
|
|
database_name: self
|
|
.database_name
|
|
.clone()
|
|
.unwrap_or_else(|| other.database_name.clone()),
|
|
user: self.user.clone().unwrap_or_else(|| other.user.clone()),
|
|
password: self
|
|
.password
|
|
.clone()
|
|
.unwrap_or_else(|| other.password.clone()),
|
|
}
|
|
}
|
|
}
|