Skip to content

Commit ac7384e

Browse files
committed
Fix clippy lints
1 parent f4e8663 commit ac7384e

File tree

11 files changed

+74
-46
lines changed

11 files changed

+74
-46
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ where
128128
{
129129
#[snafu(display("failed to retrieve secret \"{secret_ref}\""))]
130130
GetSecret {
131-
source: kube::Error,
131+
#[snafu(source(from(kube::Error, Box::new)))]
132+
source: Box<kube::Error>,
132133
secret_ref: SecretReference,
133134
},
134135

@@ -146,15 +147,19 @@ where
146147

147148
#[snafu(display("failed to read PEM-encoded certificate chain from secret {secret:?}"))]
148149
ReadChain {
149-
source: x509_cert::der::Error,
150+
#[snafu(source(from(x509_cert::der::Error, Box::new)))]
151+
source: Box<x509_cert::der::Error>,
150152
secret: ObjectRef<Secret>,
151153
},
152154

153155
#[snafu(display("failed to parse UTF-8 encoded byte string"))]
154156
DecodeUtf8String { source: std::str::Utf8Error },
155157

156158
#[snafu(display("failed to deserialize private key from PEM"))]
157-
DeserializeKeyFromPem { source: E },
159+
DeserializeKeyFromPem {
160+
#[snafu(source(from(E, Box::new)))]
161+
source: Box<E>,
162+
},
158163
}
159164

160165
/// A certificate authority (CA) which is used to generate and sign

crates/stackable-operator/src/cluster_resources.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ pub enum Error {
5353
MissingObjectKey { key: &'static str },
5454

5555
#[snafu(display("failed to list cluster resources with label selector"))]
56-
ListClusterResources { source: crate::client::Error },
56+
ListClusterResources {
57+
#[snafu(source(from(crate::client::Error, Box::new)))]
58+
source: Box<crate::client::Error>,
59+
},
5760

5861
#[snafu(display("label {label:?} is missing"))]
5962
MissingLabel { label: &'static str },
@@ -68,13 +71,22 @@ pub enum Error {
6871
},
6972

7073
#[snafu(display("failed to get resource"))]
71-
GetResource { source: crate::client::Error },
74+
GetResource {
75+
#[snafu(source(from(crate::client::Error, Box::new)))]
76+
source: Box<crate::client::Error>,
77+
},
7278

7379
#[snafu(display("failed to apply patch"))]
74-
ApplyPatch { source: crate::client::Error },
80+
ApplyPatch {
81+
#[snafu(source(from(crate::client::Error, Box::new)))]
82+
source: Box<crate::client::Error>,
83+
},
7584

7685
#[snafu(display("failed to delete orphaned resource"))]
77-
DeleteOrphanedResource { source: crate::client::Error },
86+
DeleteOrphanedResource {
87+
#[snafu(source(from(crate::client::Error, Box::new)))]
88+
source: Box<crate::client::Error>,
89+
},
7890
}
7991

8092
/// A cluster resource handled by [`ClusterResources`].

crates/stackable-operator/src/crd/s3/connection/v1alpha1_impl.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ use crate::{
1717
pub enum ConnectionError {
1818
#[snafu(display("failed to retrieve S3 connection '{s3_connection}'"))]
1919
RetrieveS3Connection {
20-
source: crate::client::Error,
20+
#[snafu(source(from(crate::client::Error, Box::new)))]
21+
source: Box<crate::client::Error>,
2122
s3_connection: String,
2223
},
2324

@@ -37,11 +38,15 @@ pub enum ConnectionError {
3738
AddS3TlsClientDetailsVolumes { source: TlsClientDetailsError },
3839

3940
#[snafu(display("failed to add required volumes"))]
40-
AddVolumes { source: crate::builder::pod::Error },
41+
AddVolumes {
42+
#[snafu(source(from(crate::builder::pod::Error, Box::new)))]
43+
source: Box<crate::builder::pod::Error>,
44+
},
4145

4246
#[snafu(display("failed to add required volumeMounts"))]
4347
AddVolumeMounts {
44-
source: crate::builder::pod::container::Error,
48+
#[snafu(source(from(crate::builder::pod::container::Error, Box::new)))]
49+
source: Box<crate::builder::pod::container::Error>,
4550
},
4651
}
4752

crates/stackable-operator/src/product_config_utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ pub fn config_for_role_and_group<'a>(
160160
Ok(result)
161161
}
162162

163+
#[allow(clippy::doc_overindented_list_items)]
163164
/// Given the configuration parameters of all `roles` partition them by `PropertyNameKind` and
164165
/// merge them with the role groups configuration parameters.
165166
///
@@ -197,6 +198,7 @@ where
197198
Ok(result)
198199
}
199200

201+
#[allow(clippy::doc_overindented_list_items)]
200202
/// Validates a product configuration for all roles and role_groups. Requires a valid product config
201203
/// and [`RoleConfigByPropertyKind`] which can be obtained via `transform_all_roles_to_config`.
202204
///
@@ -239,6 +241,7 @@ pub fn validate_all_roles_and_groups_config(
239241
Ok(result)
240242
}
241243

244+
#[allow(clippy::doc_overindented_list_items)]
242245
/// Calculates and validates a product configuration for a role and group. Requires a valid
243246
/// product config and existing [`RoleConfigByPropertyKind`] that can be obtained via
244247
/// `transform_all_roles_to_config`.
@@ -283,6 +286,7 @@ fn validate_role_and_group_config(
283286
Ok(result)
284287
}
285288

289+
#[allow(clippy::doc_overindented_list_items)]
286290
/// This transforms the [`product_config::PropertyValidationResult`] back into a pure BTreeMap which can be used
287291
/// to set properties for config files, cli or environmental variables.
288292
/// Default values are ignored, Recommended and Valid values are used as is. For Warning and

crates/stackable-operator/src/product_logging/framework.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ pub fn capture_shell_output(
228228
///
229229
/// * `log_dir` - Directory where the log files are stored
230230
/// * `log_file` - Name of the active log file; When the file is rolled over then a number is
231-
/// appended.
231+
/// appended.
232232
/// * `max_size_in_mib` - Maximum size of all log files in MiB; This value can be slightly
233-
/// exceeded. The value is set to 2 if the given value is lower (1 MiB for the active log
234-
/// file and 1 MiB for the archived one).
233+
/// exceeded. The value is set to 2 if the given value is lower (1 MiB for the active log
234+
/// file and 1 MiB for the archived one).
235235
/// * `console_conversion_pattern` - Logback conversion pattern for the console appender
236236
/// * `config` - The logging configuration for the container
237237
///
@@ -349,10 +349,10 @@ log4j.appender.FILE.layout=org.apache.log4j.xml.XMLLayout
349349
///
350350
/// * `log_dir` - Directory where the log files are stored
351351
/// * `log_file` - Name of the active log file; When the file is rolled over then a number is
352-
/// appended.
352+
/// appended.
353353
/// * `max_size_in_mib` - Maximum size of all log files in MiB; This value can be slightly
354-
/// exceeded. The value is set to 2 if the given value is lower (1 MiB for the active log
355-
/// file and 1 MiB for the archived one).
354+
/// exceeded. The value is set to 2 if the given value is lower (1 MiB for the active log
355+
/// file and 1 MiB for the archived one).
356356
/// * `console_conversion_pattern` - Log4j2 conversion pattern for the console appender
357357
/// * `config` - The logging configuration for the container
358358
///
@@ -493,15 +493,15 @@ rootLogger.appenderRef.FILE.ref = FILE"#,
493493
///
494494
/// * `log_dir` - Directory where the log files are stored
495495
/// * `log_file` - Name of the active log file; When the file is rolled over then a number is
496-
/// appended.
496+
/// appended.
497497
/// * `max_size_in_mib` - Maximum size of all log files in MiB; This value can be slightly
498-
/// exceeded. The value is set to 2 if the given value is lower (1 MiB for the active log
499-
/// file and 1 MiB for the archived one).
498+
/// exceeded. The value is set to 2 if the given value is lower (1 MiB for the active log
499+
/// file and 1 MiB for the archived one).
500500
/// * `console_conversion_pattern` - Logback conversion pattern for the console appender
501501
/// * `config` - The logging configuration for the container
502502
/// * `additional_config` - Optional unstructured parameter to add special cases that are not
503-
/// covered in the logging configuration. Must adhere to the inner logback XML schema as
504-
/// shown in the example below. It is not parsed or checked and added as is to the `logback.xml`.
503+
/// covered in the logging configuration. Must adhere to the inner logback XML schema as
504+
/// shown in the example below. It is not parsed or checked and added as is to the `logback.xml`.
505505
///
506506
/// # Example
507507
///

crates/stackable-operator/src/status/condition/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ pub trait ConditionBuilder {
2626
/// # Arguments
2727
///
2828
/// * `resource` - A cluster resource or status implementing [`HasStatusCondition`] in order to
29-
/// retrieve the "current" conditions set in the cluster. This is required to compute
30-
/// condition change and set proper update / transition times.
29+
/// retrieve the "current" conditions set in the cluster. This is required to compute
30+
/// condition change and set proper update / transition times.
3131
/// * `condition_builders` - A slice of structs implementing [`ConditionBuilder`]. This can be a
32-
/// one of the predefined ConditionBuilders like `DaemonSetConditionBuilder` or a custom
33-
/// implementation for special resources or different behavior.
32+
/// one of the predefined ConditionBuilders like `DaemonSetConditionBuilder` or a custom
33+
/// implementation for special resources or different behavior.
3434
///
3535
/// # Examples
3636
/// ```

crates/stackable-operator/src/utils/option.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ mod tests {
5151

5252
#[test]
5353
fn as_ref_or_else() {
54-
let maybe: Option<String> = None;
55-
let defaulted: Cow<String> = maybe.as_ref_or_else(|| "foo".to_string());
56-
assert_eq!(defaulted, Cow::<String>::Owned("foo".to_string()));
54+
let maybe: Option<&str> = None;
55+
let defaulted: Cow<&str> = maybe.as_ref_or_else(|| "foo");
56+
assert_eq!(defaulted, Cow::<&str>::Owned("foo"));
5757

58-
let maybe: Option<String> = Some("foo".to_string());
59-
let defaulted: Cow<String> = maybe.as_ref_or_else(|| panic!());
60-
assert_eq!(defaulted, Cow::<String>::Borrowed(&"foo".to_string()));
58+
let maybe: Option<&str> = Some("foo");
59+
let defaulted: Cow<&str> = maybe.as_ref_or_else(|| panic!());
60+
assert_eq!(defaulted, Cow::<&str>::Borrowed(&"foo"));
6161
}
6262

6363
#[test]

crates/stackable-versioned-macros/src/attrs/container/k8s.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ use crate::attrs::common::Override;
1515
/// - `group`: Set the group of the CR object, usually the domain of the company.
1616
/// This argument is Required.
1717
/// - `kind`: Override the kind field of the CR object. This defaults to the struct
18-
/// name (without the 'Spec' suffix).
18+
/// name (without the 'Spec' suffix).
1919
/// - `singular`: Set the singular name of the CR object.
2020
/// - `plural`: Set the plural name of the CR object.
2121
/// - `namespaced`: Indicate that this is a namespaced scoped resource rather than a
22-
/// cluster scoped resource.
22+
/// cluster scoped resource.
2323
/// - `crates`: Override specific crates.
2424
/// - `status`: Set the specified struct as the status subresource.
2525
/// - `shortname`: Set a shortname for the CR object. This can be specified multiple

crates/stackable-versioned-macros/src/attrs/item/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ impl CommonItemAttributes {
336336
downgrade_with: change.downgrade_with.as_deref().cloned(),
337337
upgrade_with: change.upgrade_with.as_deref().cloned(),
338338
from_ident: from_ident.clone(),
339-
from_type: from_ty.clone(),
339+
from_type: Box::new(from_ty.clone()),
340340
to_ident: ident,
341-
to_type: ty,
341+
to_type: Box::new(ty),
342342
},
343343
);
344344

@@ -354,7 +354,7 @@ impl CommonItemAttributes {
354354
ItemStatus::Addition {
355355
default_fn: added.default_fn.deref().clone(),
356356
ident,
357-
ty,
357+
ty: Box::new(ty),
358358
},
359359
);
360360
}
@@ -387,9 +387,9 @@ impl CommonItemAttributes {
387387
downgrade_with: change.downgrade_with.as_deref().cloned(),
388388
upgrade_with: change.upgrade_with.as_deref().cloned(),
389389
from_ident: from_ident.clone(),
390-
from_type: from_ty.clone(),
390+
from_type: Box::new(from_ty.clone()),
391391
to_ident: ident,
392-
to_type: ty,
392+
to_type: Box::new(ty),
393393
},
394394
);
395395

@@ -405,7 +405,7 @@ impl CommonItemAttributes {
405405
ItemStatus::Addition {
406406
default_fn: added.default_fn.deref().clone(),
407407
ident,
408-
ty,
408+
ty: Box::new(ty),
409409
},
410410
);
411411
}
@@ -420,7 +420,7 @@ impl CommonItemAttributes {
420420
ItemStatus::Addition {
421421
default_fn: added.default_fn.deref().clone(),
422422
ident: ident.deref().clone(),
423-
ty,
423+
ty: Box::new(ty),
424424
},
425425
);
426426

crates/stackable-versioned-macros/src/codegen/changes.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl ChangesetExt for BTreeMap<Version, ItemStatus> {
128128
ItemStatus::NoChange {
129129
previously_deprecated: false,
130130
ident: previous_ident.clone(),
131-
ty: ty.clone(),
131+
ty: Box::new(ty.clone()),
132132
},
133133
),
134134
ItemStatus::NoChange {
@@ -151,7 +151,9 @@ impl ChangesetExt for BTreeMap<Version, ItemStatus> {
151151
ItemStatus::Change {
152152
to_ident, to_type, ..
153153
} => (to_ident, to_type, false),
154-
ItemStatus::Deprecation { ident, .. } => (ident, ty, true),
154+
ItemStatus::Deprecation { ident, .. } => {
155+
(ident, &Box::new(ty.clone()), true)
156+
}
155157
ItemStatus::NoChange {
156158
previously_deprecated,
157159
ident,

0 commit comments

Comments
 (0)