Refactor container definitions
This commit is contained in:
41
apps/container/src/containers/db/config.rs
Normal file
41
apps/container/src/containers/db/config.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
#[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()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user