Skip to content

Commit 67a01f7

Browse files
committed
chore: Apply Rust 2024 formatting
1 parent cce4ee7 commit 67a01f7

File tree

66 files changed

+591
-694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+591
-694
lines changed

crates/k8s-version/src/group.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{fmt, ops::Deref, str::FromStr, sync::LazyLock};
22

33
use regex::Regex;
4-
use snafu::{ensure, Snafu};
4+
use snafu::{Snafu, ensure};
55

66
const MAX_GROUP_LENGTH: usize = 253;
77

crates/k8s-version/src/version.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ static VERSION_REGEX: LazyLock<Regex> = LazyLock::new(|| {
1616
/// unparsed input.
1717
#[derive(Debug, PartialEq, Snafu)]
1818
pub enum ParseVersionError {
19-
#[snafu(display("invalid version format. Input is empty, contains non-ASCII characters or contains more than 63 characters"))]
19+
#[snafu(display(
20+
"invalid version format. Input is empty, contains non-ASCII characters or contains more than 63 characters"
21+
))]
2022
InvalidFormat,
2123

2224
#[snafu(display("failed to parse major version"))]

crates/stackable-certs/src/ca/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use stackable_operator::{client::Client, commons::secret::SecretReference, time:
1010
use tracing::{debug, instrument};
1111
use x509_cert::{
1212
builder::{Builder, CertificateBuilder, Profile},
13-
der::{pem::LineEnding, referenced::OwnedToRef, DecodePem},
13+
der::{DecodePem, pem::LineEnding, referenced::OwnedToRef},
1414
ext::pkix::{AuthorityKeyIdentifier, ExtendedKeyUsage},
1515
name::Name,
1616
serial_number::SerialNumber,
@@ -19,8 +19,8 @@ use x509_cert::{
1919
};
2020

2121
use crate::{
22-
keys::{ecdsa, rsa, CertificateKeypair},
2322
CertificatePair,
23+
keys::{CertificateKeypair, ecdsa, rsa},
2424
};
2525

2626
mod consts;

crates/stackable-certs/src/keys/ecdsa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Abstraction layer around the [`ecdsa`] crate. This module provides types
22
//! which abstract away the generation of ECDSA keys used for signing of CAs
33
//! and other certificates.
4-
use p256::{pkcs8::DecodePrivateKey, NistP256};
4+
use p256::{NistP256, pkcs8::DecodePrivateKey};
55
use rand_core::{CryptoRngCore, OsRng};
66
use snafu::{ResultExt, Snafu};
77
use tracing::instrument;

crates/stackable-certs/src/keys/rsa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! which abstract away the generation of RSA keys used for signing of CAs
33
//! and other certificates.
44
use rand_core::{CryptoRngCore, OsRng};
5-
use rsa::{pkcs8::DecodePrivateKey, RsaPrivateKey};
5+
use rsa::{RsaPrivateKey, pkcs8::DecodePrivateKey};
66
use signature::Keypair;
77
use snafu::{ResultExt, Snafu};
88
use tracing::instrument;

crates/stackable-certs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use std::ops::Deref;
2323

2424
use snafu::Snafu;
25-
use x509_cert::{spki::EncodePublicKey, Certificate};
25+
use x509_cert::{Certificate, spki::EncodePublicKey};
2626
#[cfg(feature = "rustls")]
2727
use {
2828
p256::pkcs8::EncodePrivateKey,

crates/stackable-operator-derive/src/fragment.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use darling::{ast::Data, FromDeriveInput, FromField, FromMeta, FromVariant};
1+
use darling::{FromDeriveInput, FromField, FromMeta, FromVariant, ast::Data};
22
use proc_macro2::{Ident, TokenStream, TokenTree};
3-
use quote::{format_ident, quote, ToTokens};
3+
use quote::{ToTokens, format_ident, quote};
44
use syn::{
5-
parse_quote, Attribute, DeriveInput, Generics, Meta, MetaList, Path, Type, Visibility,
6-
WherePredicate,
5+
Attribute, DeriveInput, Generics, Meta, MetaList, Path, Type, Visibility, WherePredicate,
6+
parse_quote,
77
};
88

99
#[derive(FromMeta)]
@@ -125,7 +125,7 @@ pub fn derive(input: DeriveInput) -> TokenStream {
125125
Data::Enum(_) => {
126126
return quote! {
127127
compile_error!("`#[derive(Fragment)]` does not currently support enums");
128-
}
128+
};
129129
}
130130
Data::Struct(fields) => fields.fields,
131131
};

crates/stackable-operator-derive/src/merge.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use darling::{
2-
ast::{Data, Fields},
32
FromDeriveInput, FromField, FromMeta, FromVariant,
3+
ast::{Data, Fields},
44
};
55
use proc_macro2::{Ident, Span, TokenStream};
66
use quote::{format_ident, quote};
7-
use syn::{parse_quote, DeriveInput, Generics, Index, Path, WherePredicate};
7+
use syn::{DeriveInput, Generics, Index, Path, WherePredicate, parse_quote};
88

99
#[derive(FromMeta)]
1010
struct PathOverrides {
@@ -67,13 +67,10 @@ pub fn derive(input: DeriveInput) -> TokenStream {
6767

6868
let (ty, variants) = match data {
6969
// Structs are almost single-variant enums, so we can reuse most of the same matching code for both cases
70-
Data::Struct(fields) => (
71-
InputType::Struct,
72-
vec![MergeVariant {
73-
ident: Ident::new("__placeholder", Span::call_site()),
74-
fields,
75-
}],
76-
),
70+
Data::Struct(fields) => (InputType::Struct, vec![MergeVariant {
71+
ident: Ident::new("__placeholder", Span::call_site()),
72+
fields,
73+
}]),
7774
Data::Enum(variants) => (InputType::Enum, variants),
7875
};
7976
let merge_variants = variants

crates/stackable-operator/src/builder/pdb.rs

Lines changed: 52 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ mod tests {
205205
api::policy::v1::{PodDisruptionBudget, PodDisruptionBudgetSpec},
206206
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
207207
};
208-
use kube::{core::ObjectMeta, CustomResource};
208+
use kube::{CustomResource, core::ObjectMeta};
209209
use schemars::JsonSchema;
210210
use serde::{Deserialize, Serialize};
211211

@@ -229,28 +229,22 @@ mod tests {
229229
.with_min_available(42)
230230
.build();
231231

232-
assert_eq!(
233-
pdb,
234-
PodDisruptionBudget {
235-
metadata: ObjectMeta {
236-
name: Some("trino".to_string()),
237-
namespace: Some("default".to_string()),
238-
..Default::default()
239-
},
240-
spec: Some(PodDisruptionBudgetSpec {
241-
min_available: Some(IntOrString::Int(42)),
242-
selector: Some(LabelSelector {
243-
match_expressions: None,
244-
match_labels: Some(BTreeMap::from([(
245-
"foo".to_string(),
246-
"bar".to_string()
247-
)])),
248-
}),
249-
..Default::default()
232+
assert_eq!(pdb, PodDisruptionBudget {
233+
metadata: ObjectMeta {
234+
name: Some("trino".to_string()),
235+
namespace: Some("default".to_string()),
236+
..Default::default()
237+
},
238+
spec: Some(PodDisruptionBudgetSpec {
239+
min_available: Some(IntOrString::Int(42)),
240+
selector: Some(LabelSelector {
241+
match_expressions: None,
242+
match_labels: Some(BTreeMap::from([("foo".to_string(), "bar".to_string())])),
250243
}),
251244
..Default::default()
252-
}
253-
)
245+
}),
246+
..Default::default()
247+
})
254248
}
255249

256250
#[test]
@@ -289,55 +283,54 @@ mod tests {
289283
.with_max_unavailable(2)
290284
.build();
291285

292-
assert_eq!(
293-
pdb,
294-
PodDisruptionBudget {
295-
metadata: ObjectMeta {
296-
name: Some("simple-trino-worker".to_string()),
297-
namespace: Some("default".to_string()),
298-
labels: Some(BTreeMap::from([
286+
assert_eq!(pdb, PodDisruptionBudget {
287+
metadata: ObjectMeta {
288+
name: Some("simple-trino-worker".to_string()),
289+
namespace: Some("default".to_string()),
290+
labels: Some(BTreeMap::from([
291+
("app.kubernetes.io/name".to_string(), "trino".to_string()),
292+
(
293+
"app.kubernetes.io/instance".to_string(),
294+
"simple-trino".to_string()
295+
),
296+
(
297+
"app.kubernetes.io/managed-by".to_string(),
298+
"trino.stackable.tech_trino-operator-trino-controller".to_string()
299+
),
300+
(
301+
"app.kubernetes.io/component".to_string(),
302+
"worker".to_string()
303+
)
304+
])),
305+
owner_references: Some(vec![
306+
OwnerReferenceBuilder::new()
307+
.initialize_from_resource(&trino)
308+
.block_owner_deletion_opt(None)
309+
.controller_opt(Some(true))
310+
.build()
311+
.unwrap()
312+
]),
313+
..Default::default()
314+
},
315+
spec: Some(PodDisruptionBudgetSpec {
316+
max_unavailable: Some(IntOrString::Int(2)),
317+
selector: Some(LabelSelector {
318+
match_expressions: None,
319+
match_labels: Some(BTreeMap::from([
299320
("app.kubernetes.io/name".to_string(), "trino".to_string()),
300321
(
301322
"app.kubernetes.io/instance".to_string(),
302323
"simple-trino".to_string()
303324
),
304-
(
305-
"app.kubernetes.io/managed-by".to_string(),
306-
"trino.stackable.tech_trino-operator-trino-controller".to_string()
307-
),
308325
(
309326
"app.kubernetes.io/component".to_string(),
310327
"worker".to_string()
311328
)
312329
])),
313-
owner_references: Some(vec![OwnerReferenceBuilder::new()
314-
.initialize_from_resource(&trino)
315-
.block_owner_deletion_opt(None)
316-
.controller_opt(Some(true))
317-
.build()
318-
.unwrap()]),
319-
..Default::default()
320-
},
321-
spec: Some(PodDisruptionBudgetSpec {
322-
max_unavailable: Some(IntOrString::Int(2)),
323-
selector: Some(LabelSelector {
324-
match_expressions: None,
325-
match_labels: Some(BTreeMap::from([
326-
("app.kubernetes.io/name".to_string(), "trino".to_string()),
327-
(
328-
"app.kubernetes.io/instance".to_string(),
329-
"simple-trino".to_string()
330-
),
331-
(
332-
"app.kubernetes.io/component".to_string(),
333-
"worker".to_string()
334-
)
335-
])),
336-
}),
337-
..Default::default()
338330
}),
339331
..Default::default()
340-
}
341-
)
332+
}),
333+
..Default::default()
334+
})
342335
}
343336
}

crates/stackable-operator/src/builder/pod/container.rs

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,13 @@ impl ContainerBuilder {
121121
name: impl Into<String>,
122122
field_path: FieldPathEnvVar,
123123
) -> &mut Self {
124-
self.add_env_var_from_source(
125-
name,
126-
EnvVarSource {
127-
field_ref: Some(ObjectFieldSelector {
128-
field_path: field_path.to_string(),
129-
..ObjectFieldSelector::default()
130-
}),
131-
..EnvVarSource::default()
132-
},
133-
);
124+
self.add_env_var_from_source(name, EnvVarSource {
125+
field_ref: Some(ObjectFieldSelector {
126+
field_path: field_path.to_string(),
127+
..ObjectFieldSelector::default()
128+
}),
129+
..EnvVarSource::default()
130+
});
134131
self
135132
}
136133

@@ -141,17 +138,14 @@ impl ContainerBuilder {
141138
secret_name: impl Into<String>,
142139
secret_key: impl Into<String>,
143140
) -> &mut Self {
144-
self.add_env_var_from_source(
145-
name,
146-
EnvVarSource {
147-
secret_key_ref: Some(SecretKeySelector {
148-
name: secret_name.into(),
149-
key: secret_key.into(),
150-
..Default::default()
151-
}),
141+
self.add_env_var_from_source(name, EnvVarSource {
142+
secret_key_ref: Some(SecretKeySelector {
143+
name: secret_name.into(),
144+
key: secret_key.into(),
152145
..Default::default()
153-
},
154-
);
146+
}),
147+
..Default::default()
148+
});
155149
self
156150
}
157151

@@ -162,17 +156,14 @@ impl ContainerBuilder {
162156
config_map_name: impl Into<String>,
163157
config_map_key: impl Into<String>,
164158
) -> &mut Self {
165-
self.add_env_var_from_source(
166-
name,
167-
EnvVarSource {
168-
config_map_key_ref: Some(ConfigMapKeySelector {
169-
name: config_map_name.into(),
170-
key: config_map_key.into(),
171-
..Default::default()
172-
}),
159+
self.add_env_var_from_source(name, EnvVarSource {
160+
config_map_key_ref: Some(ConfigMapKeySelector {
161+
name: config_map_name.into(),
162+
key: config_map_key.into(),
173163
..Default::default()
174-
},
175-
);
164+
}),
165+
..Default::default()
166+
});
176167
self
177168
}
178169

@@ -469,9 +460,11 @@ mod tests {
469460
.expect("add volume mount")
470461
.add_container_port(container_port_name, container_port)
471462
.resources(resources.clone())
472-
.add_container_ports(vec![ContainerPortBuilder::new(container_port_1)
473-
.name(container_port_name_1)
474-
.build()])
463+
.add_container_ports(vec![
464+
ContainerPortBuilder::new(container_port_1)
465+
.name(container_port_name_1)
466+
.build(),
467+
])
475468
.build();
476469

477470
assert_eq!(container.name, "testcontainer");

0 commit comments

Comments
 (0)