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:
parent
823712e2bf
commit
c03f351d81
53
Cargo.lock
generated
53
Cargo.lock
generated
@ -362,6 +362,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"tokio",
|
||||
"toml",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
@ -1475,6 +1476,15 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.7.1"
|
||||
@ -1743,6 +1753,40 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-service"
|
||||
version = "0.3.2"
|
||||
@ -2180,6 +2224,15 @@ version = "0.52.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.50.0"
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user