Skip to content

Commit 3275f66

Browse files
committed
chore: Rust dependency bumps
1 parent 58dc598 commit 3275f66

12 files changed

Lines changed: 764 additions & 1142 deletions

File tree

Cargo.lock

Lines changed: 710 additions & 1080 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ directories = "6.0"
3333
dotenvy = "0.15"
3434
either = "1.15.0"
3535
futures = "0.3"
36+
hex = "0.4"
3637
indexmap = { version = "2.2", features = ["serde"] }
3738
indicatif = "0.18"
3839
lazy_static = "1.5"
3940
libc = "0.2"
4041
once_cell = "1.19"
41-
phf = "0.13"
42-
phf_codegen = "0.13"
42+
phf = "0.14"
43+
phf_codegen = "0.14"
4344
rand = "0.10"
4445
regex = "1.10"
4546
reqwest = { version = "0.13", default-features = false, features = ["json", "rustls"] }
@@ -49,14 +50,14 @@ semver = { version = "1.0", features = ["serde"] }
4950
serde = { version = "1.0", features = ["derive"] }
5051
serde_json = "1.0"
5152
serde_yaml = "0.9"
52-
sha2 = "0.10"
53+
sha2 = "0.11"
5354
snafu = { version = "0.9", features = ["futures"] }
54-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.109.0", default-features = false, features = ["crds", "kube-ws"] }
55-
tera = "1.20"
55+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.113.4", default-features = false, features = ["crds", "kube-ws"] }
56+
tera = "2.0"
5657
termion = "4.0"
5758
tokio = { version = "1.38", features = ["rt-multi-thread", "macros", "fs", "process", "io-std"] }
5859
toml = { version = "1.0", features = ["serde"] }
59-
tower-http = { version = "0.6", features = ["validate-request"] }
60+
tower-http = { version = "0.7", features = ["validate-request"] }
6061
tracing = "0.1"
6162
tracing-indicatif = "0.3.9"
6263
tracing-subscriber = "0.3"

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.93.0"
2+
channel = "1.95.0"
33
profile = "default"

rust/stackable-cockpit/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ helm-sys = { path = "../helm-sys" }
1818
bcrypt.workspace = true
1919
clap.workspace = true
2020
either.workspace = true
21+
hex.workspace = true
2122
indexmap.workspace = true
2223
rand.workspace = true
2324
reqwest.workspace = true

rust/stackable-cockpit/src/platform/namespace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub async fn create_if_needed(client: &Client, name: String) -> Result<(), Error
2222
.create_namespace_if_needed(name)
2323
.await
2424
.map_err(|err| match err {
25-
k8s::Error::KubeClientCreate { source } => match source {
25+
k8s::Error::KubeClientCreate { source } => match &*source {
2626
kube::Error::Api(err) if err.code == 401 => Error::PermissionDenied,
2727
_ => Error::KubeClientCreate {
2828
source: Box::new(k8s::Error::KubeClientCreate { source }),

rust/stackable-cockpit/src/platform/service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ pub async fn get_endpoints(
5858
.await;
5959
let listeners = match listeners {
6060
Ok(ok) => Ok(ok.items),
61-
Err(k8s::Error::KubeClientFetch {
62-
source: kube::Error::Api(err),
63-
}) if err.code == 404 => {
61+
Err(k8s::Error::KubeClientFetch { source })
62+
if matches!(&*source, kube::Error::Api(err) if err.code == 404) =>
63+
{
6464
// In case the listener-operator is not installed, this will return a 404. We should not fail, as this causes
6565
// stackablectl to fail with ApiError 404 on clusters without listener-operator.
6666
Ok(Vec::new())

rust/stackable-cockpit/src/utils/k8s/client.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,27 @@ pub type Result<T, E = Error> = std::result::Result<T, E>;
3737
#[derive(Debug, Snafu)]
3838
pub enum Error {
3939
#[snafu(display("failed to create Kubernetes client"))]
40-
KubeClientCreate { source: kube::error::Error },
40+
KubeClientCreate {
41+
#[snafu(source(from(kube::error::Error, Box::new)))]
42+
source: Box<kube::error::Error>,
43+
},
4144

4245
#[snafu(display("failed to fetch data from Kubernetes API"))]
43-
KubeClientFetch { source: kube::error::Error },
46+
KubeClientFetch {
47+
#[snafu(source(from(kube::error::Error, Box::new)))]
48+
source: Box<kube::error::Error>,
49+
},
4450

4551
#[snafu(display("failed to patch/create Kubernetes object"))]
46-
KubeClientPatch { source: kube::error::Error },
52+
KubeClientPatch {
53+
#[snafu(source(from(kube::error::Error, Box::new)))]
54+
source: Box<kube::error::Error>,
55+
},
4756

4857
#[snafu(display("failed to replace Kubernetes object"))]
4958
KubeClientReplace {
50-
source: kube::error::Error,
59+
#[snafu(source(from(kube::error::Error, Box::new)))]
60+
source: Box<kube::error::Error>,
5161
gvk: GroupVersionKind,
5262
},
5363

@@ -60,7 +70,10 @@ pub enum Error {
6070
DeserializeYaml { source: serde_yaml::Error },
6171

6272
#[snafu(display("failed to run GVK discovery"))]
63-
GVKDiscoveryRun { source: kube::error::Error },
73+
GVKDiscoveryRun {
74+
#[snafu(source(from(kube::error::Error, Box::new)))]
75+
source: Box<kube::error::Error>,
76+
},
6477

6578
#[snafu(display("failed to deploy manifest because type of object {object:?} is not set"))]
6679
ObjectType { object: Box<DynamicObject> },

rust/stackable-cockpit/src/utils/templating.rs

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use std::collections::HashMap;
22

33
use bcrypt::DEFAULT_COST;
44
use rand::distr::{Alphanumeric, SampleString};
5-
use serde::de::DeserializeOwned;
6-
use tera::{Context, Function, Tera, Value};
5+
use tera::{Context, Kwargs, State, Tera, TeraResult};
76

87
use crate::constants::PASSWORD_LENGTH;
98

@@ -14,47 +13,25 @@ use crate::constants::PASSWORD_LENGTH;
1413
/// - `random_password`: Returns a random password with a relatively secure RNG.
1514
/// See [`rand::rng`] for more information.
1615
/// - `bcrypt`: Returns the bcyrpt hash of the provided `password` parameter.
17-
pub fn render(content: &str, parameters: &HashMap<String, String>) -> Result<String, tera::Error> {
16+
pub fn render(content: &str, parameters: &HashMap<String, String>) -> TeraResult<String> {
1817
// Create templating context
1918
let context = Context::from_serialize(parameters)?;
2019

2120
// Create render engine
22-
let mut tera = Tera::default();
23-
tera.register_function("random_password", random_password());
24-
tera.register_function("bcrypt", bcrypt());
21+
let mut tera = Tera::new();
22+
tera.register_function("random_password", random_password);
23+
tera.register_function("bcrypt", bcrypt);
2524

2625
// Render template
27-
tera.render_str(content, &context)
26+
tera.render(content, &context)
2827
}
2928

30-
/// Internal helper function to retrieve value of type `T` from the `map` by
31-
/// `key`. If the `key` is not present in the `map`, it returns an error.
32-
fn get_from_map<T>(map: &HashMap<String, Value>, key: &str) -> tera::Result<T>
33-
where
34-
T: DeserializeOwned,
35-
{
36-
match map.get(key) {
37-
Some(value) => match tera::from_value(value.to_owned()) {
38-
Ok(extracted) => Ok(extracted),
39-
Err(_) => Err(format!("Unable to retrieve value of argument {key:?}").into()),
40-
},
41-
None => Err(format!("Failed to retrieve missing parameter {key:?}").into()),
42-
}
29+
pub fn random_password(_: Kwargs, _: &State) -> TeraResult<String> {
30+
Ok(Alphanumeric.sample_string(&mut rand::rng(), PASSWORD_LENGTH))
4331
}
4432

45-
fn random_password() -> impl Function {
46-
|_args: &HashMap<String, Value>| -> tera::Result<Value> {
47-
let password = Alphanumeric.sample_string(&mut rand::rng(), PASSWORD_LENGTH);
48-
Ok(password.into())
49-
}
50-
}
51-
52-
fn bcrypt() -> impl Function {
53-
|args: &HashMap<String, Value>| -> tera::Result<Value> {
54-
let password: String = get_from_map(args, "password")?;
55-
let hash = bcrypt::hash(password, DEFAULT_COST)
56-
.map_err(|err| format!("Failed to create bcrypt hash: {err}"))?;
57-
58-
Ok(hash.into())
59-
}
33+
pub fn bcrypt(kwargs: Kwargs, _: &State) -> TeraResult<String> {
34+
let password = kwargs.must_get::<String>("password")?;
35+
bcrypt::hash(password, DEFAULT_COST)
36+
.map_err(|err| tera::Error::message(format!("Failed to create bcrypt hash: {err}")))
6037
}

rust/stackable-cockpit/src/xfer/cache.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,12 @@ impl Cache {
222222
}
223223

224224
fn file_path(base_path: &Path, file_url: &Url) -> PathBuf {
225-
let mut hasher = Sha256::new();
226-
227225
let sanitized_file_name = file_url
228226
.as_str()
229227
.replace(|c: char| !c.is_alphanumeric(), "-");
228+
let file_url_hash = hex::encode(Sha256::digest(file_url.as_str().as_bytes()));
230229

231-
hasher.update(file_url.as_str().as_bytes());
232-
let file_url_hash = hasher.finalize();
233-
234-
base_path.join(format!("{sanitized_file_name}-{file_url_hash:x}"))
230+
base_path.join(format!("{sanitized_file_name}-{file_url_hash}"))
235231
}
236232
}
237233

rust/stackablectl/src/cli/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ pub enum Error {
5454
Cache { source: cache::CmdError },
5555

5656
#[snafu(display("failed to execute debug (sub)command"))]
57-
Debug { source: debug::CmdError },
57+
Debug {
58+
#[snafu(source(from(debug::CmdError, Box::new)))]
59+
source: Box<debug::CmdError>,
60+
},
5861

5962
#[snafu(display("failed to execute version (sub)command"))]
6063
Version { source: version::CmdError },
@@ -194,7 +197,6 @@ impl Cli {
194197
}
195198
}
196199

197-
#[allow(clippy::result_large_err)]
198200
fn xdg_directories() -> Result<ProjectDirs, Error> {
199201
ProjectDirs::from(
200202
USER_DIR_QUALIFIER,

0 commit comments

Comments
 (0)