refactor: split module
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -7,41 +7,9 @@ pub mod rust_lib;
|
||||
pub mod rust_service;
|
||||
|
||||
pub mod cuddle_file;
|
||||
pub mod rust_workspace {
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
pub struct Workspace {
|
||||
pub members: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
pub struct File {
|
||||
pub workspace: Option<Workspace>,
|
||||
}
|
||||
|
||||
impl File {
|
||||
pub async fn read_file() -> eyre::Result<Option<Self>> {
|
||||
let file = match tokio::fs::read_to_string("Cargo.toml").await {
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
tracing::warn!("Cargo.toml was not found: {}", e);
|
||||
return Ok(None);
|
||||
}
|
||||
};
|
||||
|
||||
let workspace_file: File = toml::from_str(&file)?;
|
||||
|
||||
Ok(Some(workspace_file))
|
||||
}
|
||||
|
||||
pub fn get_workspace_members(&self) -> Option<Vec<String>> {
|
||||
self.workspace.as_ref().map(|w| w.members.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
pub mod cuddle_please;
|
||||
pub mod cuddle_releaser;
|
||||
pub mod cuddle_x;
|
||||
pub mod dagger_middleware;
|
||||
pub mod drone_templater;
|
||||
pub mod rust_workspace;
|
||||
|
31
crates/cuddle-ci/src/rust_workspace.rs
Normal file
31
crates/cuddle-ci/src/rust_workspace.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
pub struct Workspace {
|
||||
pub members: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
pub struct File {
|
||||
pub workspace: Option<Workspace>,
|
||||
}
|
||||
|
||||
impl File {
|
||||
pub async fn read_file() -> eyre::Result<Option<Self>> {
|
||||
let file = match tokio::fs::read_to_string("Cargo.toml").await {
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
tracing::warn!("Cargo.toml was not found: {}", e);
|
||||
return Ok(None);
|
||||
}
|
||||
};
|
||||
|
||||
let workspace_file: File = toml::from_str(&file)?;
|
||||
|
||||
Ok(Some(workspace_file))
|
||||
}
|
||||
|
||||
pub fn get_workspace_members(&self) -> Option<Vec<String>> {
|
||||
self.workspace.as_ref().map(|w| w.members.clone())
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user