From 79456c262539dbf3db4fced1fc2ff33d23e6164c Mon Sep 17 00:00:00 2001 From: Yannik_Sc Date: Thu, 25 Apr 2024 16:50:59 +0200 Subject: [PATCH] Add parameter for debian release --- rust/Cargo.lock | 366 ++++-------------- rust/Cargo.toml | 7 +- ...pare_bookworm.rs => prepare_os_upgrade.rs} | 49 ++- rust/src/api.rs | 4 +- rust/src/cli.rs | 78 ++-- rust/src/lib.rs | 2 +- rust/src/query.rs | 1 - 7 files changed, 153 insertions(+), 354 deletions(-) rename rust/examples/{prepare_bookworm.rs => prepare_os_upgrade.rs} (51%) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 9d0bbf0a..43fb24ca 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -146,12 +146,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" - [[package]] name = "block-buffer" version = "0.10.4" @@ -240,22 +234,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -406,15 +384,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - [[package]] name = "env_filter" version = "0.1.0" @@ -438,28 +407,6 @@ dependencies = [ "log", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "fastrand" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" - [[package]] name = "ff" version = "0.13.0" @@ -482,21 +429,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.1" @@ -634,31 +566,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "h2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - [[package]] name = "hermit-abi" version = "0.3.9" @@ -729,7 +636,6 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2", "http", "http-body", "httparse", @@ -741,18 +647,19 @@ dependencies = [ ] [[package]] -name = "hyper-tls" -version = "0.6.0" +name = "hyper-rustls" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ - "bytes", - "http-body-util", + "futures-util", + "http", "hyper", "hyper-util", - "native-tls", + "rustls", + "rustls-pki-types", "tokio", - "tokio-native-tls", + "tokio-rustls", "tower-service", ] @@ -786,16 +693,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "inout" version = "0.1.3" @@ -832,7 +729,7 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" dependencies = [ - "spin", + "spin 0.5.2", ] [[package]] @@ -847,12 +744,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "linux-raw-sys" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" - [[package]] name = "lock_api" version = "0.4.11" @@ -901,24 +792,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "num-bigint-dig" version = "0.8.4" @@ -991,50 +864,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "openssl" -version = "0.10.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" -dependencies = [ - "bitflags 2.5.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "p256" version = "0.13.2" @@ -1164,12 +993,6 @@ dependencies = [ "spki", ] -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - [[package]] name = "platforms" version = "3.4.0" @@ -1244,7 +1067,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -1284,37 +1107,36 @@ checksum = "3e6cc1e89e689536eb5aeede61520e874df5a4707df811cd5da4aa5fbb2aae19" dependencies = [ "base64", "bytes", - "encoding_rs", "futures-core", "futures-util", - "h2", "http", "http-body", "http-body-util", "hyper", - "hyper-tls", + "hyper-rustls", "hyper-util", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "rustls", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", - "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots", "winreg", ] @@ -1328,6 +1150,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rsa" version = "0.9.6" @@ -1365,16 +1202,17 @@ dependencies = [ ] [[package]] -name = "rustix" -version = "0.38.32" +name = "rustls" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" dependencies = [ - "bitflags 2.5.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", + "log", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", ] [[package]] @@ -1394,19 +1232,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" [[package]] -name = "ryu" -version = "1.0.17" +name = "rustls-webpki" +version = "0.102.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] [[package]] -name = "schannel" -version = "0.1.23" +name = "ryu" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" -dependencies = [ - "windows-sys 0.52.0", -] +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "scopeguard" @@ -1428,29 +1268,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "security-framework" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "1.0.22" @@ -1572,6 +1389,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "spki" version = "0.7.3" @@ -1670,39 +1493,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "tempfile" -version = "3.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys 0.52.0", -] - [[package]] name = "thiserror" version = "1.0.58" @@ -1769,27 +1559,14 @@ dependencies = [ ] [[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.10" +name = "tokio-rustls" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", + "rustls", + "rustls-pki-types", "tokio", - "tracing", ] [[package]] @@ -1873,6 +1650,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.0" @@ -1890,12 +1673,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" @@ -1993,6 +1770,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 871323f5..455ce008 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/innogames/serveradmin/" anyhow = "1.0" hmac = "0.12" log = "0.4" -reqwest = { version = "0.12", features = ["json"] } +reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" sha1 = "0.10" @@ -26,3 +26,8 @@ env_logger = "0.11" tokio = { version = "1.37", features = ["full"] } clap = "4.5" futures = "0.3" + +[profile.release] +lto = true +opt-level = "z" +strip = true diff --git a/rust/examples/prepare_bookworm.rs b/rust/examples/prepare_os_upgrade.rs similarity index 51% rename from rust/examples/prepare_bookworm.rs rename to rust/examples/prepare_os_upgrade.rs index 7e9a6aa6..aff5ec30 100644 --- a/rust/examples/prepare_bookworm.rs +++ b/rust/examples/prepare_os_upgrade.rs @@ -4,13 +4,44 @@ use adminapi::query::Query; #[tokio::main] pub async fn main() -> anyhow::Result<()> { - let clap = clap::Command::new("prepare_bookworm") - .arg(clap::arg!([QUERY]).action(clap::ArgAction::Append).help("Query for the preparation").value_parser(clap::value_parser!(String)).num_args(1..).required(true)) - .arg(clap::arg!(--"puppet-environment" "Sets an optional puppet environment").value_parser(clap::value_parser!(String)).required(false)) - .arg(clap::arg!(--"maintenance" "Sets the servers to maintenance").action(clap::ArgAction::SetTrue).required(false)); + let clap = clap::Command::new("prepare_os_upgrade") + .author("Yannik, yannik.schwieger@innogames.com") + .arg(clap::arg!([OS_RELEASE] "Sets the OS release name").required(true)) + .arg( + clap::arg!([QUERY]) + .action(clap::ArgAction::Append) + .help("Query for the preparation") + .value_parser(clap::value_parser!(String)) + .num_args(1..) + .required(true), + ) + .arg( + clap::arg!(--"puppet-environment" "Sets an optional puppet environment") + .value_parser(clap::value_parser!(String)) + .required(false), + ) + .arg( + clap::arg!(--"maintenance" "Sets the servers to maintenance") + .action(clap::ArgAction::SetTrue) + .required(false), + ); let matches = clap.get_matches(); - let query = matches.get_many::("QUERY").unwrap().cloned().collect::>(); + let os_release = matches + .get_one::("OS_RELEASE") + .expect("OS_RELEASE is required!"); + let query = matches + .get_many::("QUERY") + .unwrap() + .cloned() + .collect::>(); + + if !["buster", "bookworm", "trixie"].contains(&os_release.as_str()) { + return Err(anyhow::anyhow!( + "Error: {os_release} is not a valid Debian release!" + )); + } + let filters = parse_filter_args(query.into_iter())?; let query = Query::builder() @@ -25,7 +56,6 @@ pub async fn main() -> anyhow::Result<()> { return Err(anyhow::anyhow!("Unexpected value for os")); }; - server.set("os", "bookworm")?; let AttributeValue::Array(repos) = server.get("repositories") else { return Err(anyhow::anyhow!("Unexpected value for repositories")); }; @@ -39,8 +69,9 @@ pub async fn main() -> anyhow::Result<()> { continue; } - server.add("repositories", repo.replace(&base_os, "bookworm"))?; + server.add("repositories", repo.replace(&base_os, os_release))?; server.remove("repositories", repo)?; + server.set("os", os_release.to_string())?; if matches.get_flag("maintenance") { server.set("state", "maintenance")?; @@ -48,7 +79,9 @@ pub async fn main() -> anyhow::Result<()> { if let Some(environment) = matches.get_one::("puppet-environment") { if !server.get("puppet_environment").is_null() { - return Err(anyhow::anyhow!("Puppet environment is already set. Aborting!")); + return Err(anyhow::anyhow!( + "Puppet environment is already set. Aborting!" + )); } server.set("puppet_environment", environment.clone())?; diff --git a/rust/src/api.rs b/rust/src/api.rs index 08ea72df..6a68b5a4 100644 --- a/rust/src/api.rs +++ b/rust/src/api.rs @@ -3,7 +3,9 @@ use std::fmt::Display; use signature::Signer; use ssh_encoding::Encode; -use crate::commit::{AttributeChange, AttributeValue, Changeset, Commit, Dataset, IntoAttributeValue}; +use crate::commit::{ + AttributeChange, AttributeValue, Changeset, Commit, Dataset, IntoAttributeValue, +}; use crate::config::Config; use crate::query::Query; diff --git a/rust/src/cli.rs b/rust/src/cli.rs index 6d8d2fd1..ab6e7c0f 100644 --- a/rust/src/cli.rs +++ b/rust/src/cli.rs @@ -1,9 +1,11 @@ use std::str::Chars; -use crate::filter::{AttributeFilter, FilterValue, IntoFilterValue}; use crate::filter; +use crate::filter::{AttributeFilter, FilterValue, IntoFilterValue}; -pub fn parse_filter_args(args: impl Iterator + 'static) -> anyhow::Result { +pub fn parse_filter_args( + args: impl Iterator + 'static, +) -> anyhow::Result { let mut filter = AttributeFilter::default(); for arg in args { @@ -46,7 +48,6 @@ pub fn lookup_function(chars: &mut Chars) -> FilterValue { fn_name.extend(buffer.drain(0..)); } - if char == '(' && depth == 1 { continue; } @@ -74,11 +75,14 @@ pub fn lookup_function(chars: &mut Chars) -> FilterValue { } let filter_fn = get_filter_function(&fn_name.to_lowercase()); - let mut inner_filters = inner.into_iter().map(|filter| { - let mut chars = filter.chars(); + let mut inner_filters = inner + .into_iter() + .map(|filter| { + let mut chars = filter.chars(); - lookup_function(&mut chars) - }).collect::>(); + lookup_function(&mut chars) + }) + .collect::>(); if inner_filters.len() == 1 { filter_fn(inner_filters.pop().unwrap()) @@ -89,50 +93,20 @@ pub fn lookup_function(chars: &mut Chars) -> FilterValue { fn get_filter_function(name: &str) -> Box FilterValue> { match name { - "all" => { - Box::new(filter::all) - } - "any" => { - Box::new(filter::any) - } - "containedby" => { - Box::new(filter::contained_by) - } - "containedonlyby" => { - Box::new(filter::contained_only_by) - } - "contains" => { - Box::new(filter::contains) - } - "empty" => { - Box::new(|_| filter::empty()) - } - "greaterthan" => { - Box::new(filter::greater_than) - } - "greaterthanorequals" => { - Box::new(filter::greater_than_or_equals) - } - "lessthan" => { - Box::new(filter::less_than) - } - "lessthanorequals" => { - Box::new(filter::less_than_or_equals) - } - "not" => { - Box::new(filter::not) - } - "overlaps" => { - Box::new(filter::overlaps) - } - "regexp" => { - Box::new(filter::regexp) - } - "startswith" => { - Box::new(filter::starts_with) - } - _name => { - Box::new(IntoFilterValue::into_filter_value) - } + "all" => Box::new(filter::all), + "any" => Box::new(filter::any), + "containedby" => Box::new(filter::contained_by), + "containedonlyby" => Box::new(filter::contained_only_by), + "contains" => Box::new(filter::contains), + "empty" => Box::new(|_| filter::empty()), + "greaterthan" => Box::new(filter::greater_than), + "greaterthanorequals" => Box::new(filter::greater_than_or_equals), + "lessthan" => Box::new(filter::less_than), + "lessthanorequals" => Box::new(filter::less_than_or_equals), + "not" => Box::new(filter::not), + "overlaps" => Box::new(filter::overlaps), + "regexp" => Box::new(filter::regexp), + "startswith" => Box::new(filter::starts_with), + _name => Box::new(IntoFilterValue::into_filter_value), } } diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 90ba1076..78fdcd8a 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,9 +1,9 @@ pub const API_VERSION: &str = "4.9.0"; pub mod api; +pub mod cli; pub mod commit; pub mod config; pub mod filter; pub mod new_object; pub mod query; -pub mod cli; diff --git a/rust/src/query.rs b/rust/src/query.rs index 242a2583..673701d0 100644 --- a/rust/src/query.rs +++ b/rust/src/query.rs @@ -46,7 +46,6 @@ impl QueryBuilder { self } - pub fn filter( mut self, attribute: impl ToString,