Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,974 changes: 1,153 additions & 821 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ rust_2018_idioms = { level = "deny", priority = -1 }

[workspace.dependencies]
clap = { version = "4.5.47", features = ["cargo", "derive", "wrap_help"] }
facet = "0.33.0"
futures = "0.3.30"
indicatif = { version = "0.18.2", features = ["tokio"] }
itertools = "0.14.0"
lloggs = "1.3.0"
miette = "7.6.0"
reqwest = { version = "0.12.25", features = ["rustls-tls-native-roots", "json"], default-features = false }
rand = "0.10.0"
reqwest = { version = "0.13.2", features = ["json"] }
sysinfo = "0.38.4"
thiserror = "2.0.16"
tokio = "1.47.1"
tokio-util = "0.7.16"
Expand Down
5 changes: 2 additions & 3 deletions crates/alertd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ bytes = "1.9.0"
chrono = "0.4.38"
clap = { workspace = true, optional = true, features = ["env", "wrap_help"] }
clap-markdown = { version = "0.1.5", optional = true }
facet = { workspace = true }
futures = { workspace = true }
glob = "0.3.3"
jiff = "0.2.15"
Expand All @@ -32,13 +31,13 @@ miette = { workspace = true }
notify = "8.2.0"
prometheus = "0.14.0"
pulldown-cmark = "0.13.0"
rand = "0.9.2"
rand.workspace = true
reqwest = { workspace = true }
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.145"
serde_path_to_error = "0.1.17"
serde_yaml = "0.9.34"
sysinfo = "0.37.2"
sysinfo.workspace = true
tempfile = "3.21.0"
tera = "1.20.0"
thiserror = { workspace = true }
Expand Down
6 changes: 2 additions & 4 deletions crates/alertd/src/alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ fn default_interval() -> String {
"1 minute".to_string()
}

#[derive(serde::Deserialize, facet::Facet, Debug, Clone)]
#[facet(rename_all = "kebab-case")]
#[derive(serde::Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct NumericalThreshold {
pub field: String,
Expand All @@ -45,8 +44,7 @@ impl Default for WhenChanged {
}
}

#[derive(serde::Deserialize, facet::Facet, Debug, Clone)]
#[facet(rename_all = "kebab-case")]
#[derive(serde::Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct WhenChangedConfig {
#[serde(default)]
Expand Down
2 changes: 1 addition & 1 deletion crates/alertd/src/commands/loaded_alerts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::try_connect_daemon;
use serde::Deserialize;

#[derive(Debug, Deserialize, facet::Facet)]
#[derive(Debug, Deserialize)]
struct AlertStateInfo {
path: String,
enabled: bool,
Expand Down
8 changes: 4 additions & 4 deletions crates/alertd/src/commands/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub async fn validate_alert(
.into_diagnostic()
.wrap_err("failed to get daemon status")?;

#[derive(serde::Deserialize, facet::Facet)]
#[derive(serde::Deserialize)]
struct StatusResponse {
version: String,
}
Expand Down Expand Up @@ -61,21 +61,21 @@ pub async fn validate_alert(
}

// Parse response
#[derive(serde::Deserialize, facet::Facet)]
#[derive(serde::Deserialize)]
struct ValidationResponse {
valid: bool,
error: Option<String>,
error_location: Option<ErrorLocation>,
info: Option<ValidationInfo>,
}

#[derive(serde::Deserialize, facet::Facet)]
#[derive(serde::Deserialize)]
struct ErrorLocation {
line: usize,
column: usize,
}

#[derive(serde::Deserialize, facet::Facet)]
#[derive(serde::Deserialize)]
struct ValidationInfo {
enabled: bool,
interval: String,
Expand Down
14 changes: 7 additions & 7 deletions crates/alertd/src/http_server/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, facet::Facet)]
#[derive(Serialize, Deserialize)]
pub struct StatusResponse {
pub name: String,
pub version: String,
Expand All @@ -17,13 +17,13 @@ pub struct AlertRequest {
pub custom: serde_json::Value,
}

#[derive(Deserialize, facet::Facet)]
#[derive(Deserialize)]
pub struct PauseAlertRequest {
pub alert: String,
pub until: String,
}

#[derive(Serialize, Deserialize, facet::Facet)]
#[derive(Serialize, Deserialize)]
pub struct ValidationResponse {
pub valid: bool,
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -34,28 +34,28 @@ pub struct ValidationResponse {
pub info: Option<ValidationInfo>,
}

#[derive(Serialize, Deserialize, facet::Facet)]
#[derive(Serialize, Deserialize)]
pub struct ErrorLocation {
pub line: usize,
pub column: usize,
pub path: String,
}

#[derive(Serialize, Deserialize, facet::Facet)]
#[derive(Serialize, Deserialize)]
pub struct ValidationInfo {
pub enabled: bool,
pub interval: String,
pub source_type: String,
pub targets: usize,
}

#[derive(Debug, Deserialize, facet::Facet)]
#[derive(Debug, Deserialize)]
pub struct AlertsQuery {
#[serde(default)]
pub detail: bool,
}

#[derive(Debug, Serialize, Deserialize, facet::Facet)]
#[derive(Debug, Serialize, Deserialize)]
pub struct AlertStateInfo {
pub path: String,
pub enabled: bool,
Expand Down
5 changes: 2 additions & 3 deletions crates/alertd/src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ impl ResolvedTarget {
}
}

#[derive(serde::Deserialize, facet::Facet, Debug)]
#[derive(serde::Deserialize, Debug)]
pub struct AlertTargets {
pub targets: Vec<ExternalTarget>,
}

#[derive(serde::Deserialize, serde::Serialize, facet::Facet, Clone, Debug)]
#[facet(rename_all = "snake_case")]
#[derive(serde::Deserialize, serde::Serialize, Clone, Debug)]
#[serde(rename_all = "snake_case")]
pub struct ExternalTarget {
pub id: String,
Expand Down
3 changes: 1 addition & 2 deletions crates/alertd/src/targets/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use tracing::debug;

use crate::{EmailConfig, alert::AlertDefinition};

#[derive(serde::Deserialize, serde::Serialize, facet::Facet, Clone, Debug)]
#[facet(rename_all = "snake_case")]
#[derive(serde::Deserialize, serde::Serialize, Clone, Debug)]
#[serde(rename_all = "snake_case")]
pub struct TargetEmail {
pub addresses: Vec<String>,
Expand Down
2 changes: 1 addition & 1 deletion crates/algae-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ itertools = { workspace = true }
jiff = "0.2.15"
miette = { workspace = true, features = ["fancy"] }
pinentry = "0.8.0"
rand = "0.9.2"
rand.workspace = true
tokio = { workspace = true, features = ["fs", "io-util", "macros", "rt-multi-thread"] }
tokio-util = { workspace = true, features = ["compat"] }
tracing = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/algae-cli/src/cli/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub async fn run(
use rand::prelude::*;
let rng = &mut rand::rng();
let words: [_; 6] = diceware_wordlists::MINILOCK_WORDLIST
.choose_multiple_array(rng)
.sample_array(rng)
.unwrap();

let phrase: String = Itertools::intersperse(words.into_iter(), "-").collect();
Expand Down
16 changes: 6 additions & 10 deletions crates/bestool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ workspace = true
algae-cli = { version = "1.0.14", path = "../algae-cli", optional = true }
bestool-alertd = { version = "1.0.9", path = "../alertd", default-features = false, optional = true }
bestool-psql = { version = "1.4.0", path = "../psql", default-features = false, optional = true }
binstalk-downloader = { version = "0.13.29", optional = true, features = ["hickory-dns"] }
binstalk-downloader = { version = "0.13.36", optional = true, features = ["hickory-dns"] }
blake3 = { version = "1.8.2", optional = true }
boxcar = "0.2.14"
bytes = "1.10.0"
chrono = "0.4.41"
clap = { workspace = true, features = ["env", "unicode", "string"] }
clap_complete = { version = "4.5.57", optional = true }
facet = { workspace = true }
clap_complete_nushell = { version = "4.5.8", optional = true }
clap-markdown = "0.1.5"
comfy-table = { version = "7.2.0", optional = true }
Expand All @@ -48,7 +47,7 @@ json5 = { version = "1.3.0", optional = true }
leon = { version = "3.0.1", optional = true }
leon-macros = { version = "1.0.2", optional = true }
lloggs = "1.1.0"
mailgun-rs = { version = "2.0.1", optional = true }
mailgun-rs = { version = "2.0.2", optional = true }
merkle_hash = { version = "3.8.0", optional = true }
miette = { workspace = true, features = ["fancy"] }
mimalloc = "0.1.48"
Expand All @@ -65,8 +64,8 @@ serde_json = "1.0.143"
serde_path_to_error = { version = "0.1.17", optional = true }
serde_yaml = { version = "0.9.33", optional = true }
ssh-key = { version = "0.6.6", optional = true }
sysinfo = { version = "0.37.2", optional = true }
target-tuples = { version = "0.5.13", optional = true }
sysinfo = { workspace = true, optional = true }
target-tuples = { version = "0.16.0", optional = true }
tempfile = "3.21.0"
tera = { version = "1.19.1", optional = true }
thiserror = { workspace = true }
Expand All @@ -77,16 +76,13 @@ tracing = { workspace = true }
upgrade = { version = "2.0.1", optional = true }
uuid = "1.19.0"
walkdir = { version = "2.5.0", optional = true }
zip = { version = "7.0.0", optional = true, default-features = false, features = ["time"] }
zip = { version = "8.2.0", optional = true, default-features = false, features = ["time"] }
zmq = { version = "0.10.0", optional = true }

[target.'cfg(windows)'.dependencies]
windows-acl = { version = "0.3.0", optional = true }
windows-env = { version = "0.2.0", optional = true }

[target.'cfg(target_env = "musl")'.dependencies]
openssl-sys = { version = "0.9.109", features = ["vendored"] }

[build-dependencies]
windows_exe_info = { version = "0.5.2", features = ["manifest"] }

Expand Down Expand Up @@ -169,7 +165,7 @@ tamanu-upgrade = []
walg = []

[dev-dependencies]
trycmd = "0.15.10"
trycmd = "1.1.1"

[package.metadata.binstall]
pkg-url = "https://tools.ops.tamanu.io/bestool/{ version }/{ target }/{ name }{ binary-ext }"
Expand Down
2 changes: 1 addition & 1 deletion crates/bestool/src/actions/file/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl ChunkSize {
}
}

#[derive(Debug, serde::Serialize, serde::Deserialize, facet::Facet)]
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub(super) struct ChunkedMetadata {
pub full_size: u64,
pub full_sum: String,
Expand Down
2 changes: 1 addition & 1 deletion crates/bestool/src/actions/iti/lcd/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Drawable for Screen {
}
}

#[derive(Clone, Debug, Default, Deserialize, Serialize, facet::Facet)]
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct Item {
pub x: i32,
pub y: i32,
Expand Down
3 changes: 1 addition & 2 deletions crates/bestool/src/actions/tamanu/alerts/targets/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use tracing::debug;

use crate::actions::tamanu::{alerts::definition::AlertDefinition, config::TamanuConfig};

#[derive(serde::Deserialize, facet::Facet, Clone, Debug)]
#[facet(rename_all = "snake_case")]
#[derive(serde::Deserialize, Clone, Debug)]
#[serde(rename_all = "snake_case")]
pub struct TargetEmail {
pub addresses: Vec<String>,
Expand Down
4 changes: 2 additions & 2 deletions crates/bestool/src/actions/tamanu/alerts/targets/zendesk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub enum ZendeskMethod {
Anonymous { requester: String },
}

#[derive(serde::Deserialize, facet::Facet, Clone, Debug)]
#[derive(serde::Deserialize, Clone, Debug)]
pub struct ZendeskCredentials {
pub email: String,
pub password: String,
}

#[derive(serde::Deserialize, serde::Serialize, facet::Facet, Clone, Debug)]
#[derive(serde::Deserialize, serde::Serialize, Clone, Debug)]
pub struct ZendeskCustomField {
pub id: u64,
pub value: String,
Expand Down
33 changes: 19 additions & 14 deletions crates/bestool/src/actions/tamanu/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use miette::{IntoDiagnostic, Result};
use reqwest::{Client, Url};
use serde::Deserialize;
use std::str::FromStr;
use target_tuples::{OS, Target};
use target_tuples::{
CanonicalTarget, TargetRef,
pieces::{Architecture, OS},
};

use crate::actions::Context;

Expand Down Expand Up @@ -79,8 +82,12 @@ pub async fn get_artifacts(version: &str, for_platform: &Platform) -> Result<Vec
let host_targets = detect_targets()
.await
.into_iter()
.filter_map(|target| Target::from_str(&target).ok())
.collect::<Vec<Target>>();
.filter_map(|target| {
TargetRef::try_parse(&target)
.map(|target| target.canonical())
.ok()
})
.collect::<Vec<CanonicalTarget>>();

artifacts.retain(|artifact| match &for_platform {
Platform::All => true,
Expand All @@ -90,25 +97,23 @@ pub async fn get_artifacts(version: &str, for_platform: &Platform) -> Result<Vec
}

let os = if artifact.platform.contains("linux") {
host_targets
.iter()
.any(|t| t.operating_system() == Some(OS::Linux))
host_targets.iter().any(|t| t.sys.os() == Some(OS::Linux))
} else if artifact.platform.contains("windows") {
host_targets
.iter()
.any(|t| t.operating_system() == Some(OS::Win32))
host_targets.iter().any(|t| t.sys.os() == Some(OS::Win32))
} else if artifact.platform.contains("macos") {
host_targets
.iter()
.any(|t| t.operating_system() == Some(OS::Darwin))
host_targets.iter().any(|t| t.sys.os() == Some(OS::Darwin))
} else {
false
};

let arch = if artifact.platform.contains("amd64") {
host_targets.iter().any(|t| t.arch_name() == "x86_64")
host_targets
.iter()
.any(|t| matches!(t.arch, Architecture::X86_64 { .. }))
} else if artifact.platform.contains("arm64") {
host_targets.iter().any(|t| t.arch_name() == "aarch64")
host_targets
.iter()
.any(|t| matches!(t.arch, Architecture::Aarch64))
} else {
!artifact.platform.contains("-")
};
Expand Down
Loading
Loading