Skip to content

Commit 1572f2f

Browse files
committed
refactor unnamed interpolations
1 parent 96df198 commit 1572f2f

File tree

20 files changed

+128
-97
lines changed

20 files changed

+128
-97
lines changed

rust/stackable-cockpit/src/helm.rs

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ impl Display for InstallReleaseStatus {
122122
} => {
123123
write!(
124124
f,
125-
"The release {} ({}) is already installed (requested {}), skipping.",
126-
release_name, current_version, requested_version
125+
"The release {release_name} ({current_version}) is already installed (requested {requested_version}), skipping."
127126
)
128127
}
129128
InstallReleaseStatus::ReleaseAlreadyInstalledUnspecified {
@@ -132,16 +131,11 @@ impl Display for InstallReleaseStatus {
132131
} => {
133132
write!(
134133
f,
135-
"The release {} ({}) is already installed and no specific version was requested, skipping.",
136-
release_name, current_version
134+
"The release {release_name} ({current_version}) is already installed and no specific version was requested, skipping."
137135
)
138136
}
139137
InstallReleaseStatus::Installed(release_name) => {
140-
write!(
141-
f,
142-
"The release {} was successfully installed.",
143-
release_name
144-
)
138+
write!(f, "The release {release_name} was successfully installed.")
145139
}
146140
}
147141
}
@@ -157,17 +151,12 @@ impl Display for UninstallReleaseStatus {
157151
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
158152
match self {
159153
UninstallReleaseStatus::NotInstalled(release_name) => {
160-
write!(
161-
f,
162-
"The release {} is not installed, skipping.",
163-
release_name
164-
)
154+
write!(f, "The release {release_name} is not installed, skipping.")
165155
}
166156
UninstallReleaseStatus::Uninstalled(release_name) => {
167157
write!(
168158
f,
169-
"The release {} was successfully uninstalled.",
170-
release_name
159+
"The release {release_name} was successfully uninstalled."
171160
)
172161
}
173162
}
@@ -282,10 +271,7 @@ fn install_release(
282271
);
283272

284273
if let Some(error) = helm_sys::to_helm_error(&result) {
285-
error!(
286-
"Go wrapper function go_install_helm_release encountered an error: {}",
287-
error
288-
);
274+
error!("Go wrapper function go_install_helm_release encountered an error: {error}");
289275

290276
return Err(Error::InstallRelease {
291277
source: InstallReleaseError::HelmWrapper { error },
@@ -312,10 +298,7 @@ pub fn uninstall_release(
312298
let result = helm_sys::uninstall_helm_release(release_name, namespace, suppress_output);
313299

314300
if let Some(err) = helm_sys::to_helm_error(&result) {
315-
error!(
316-
"Go wrapper function go_uninstall_helm_release encountered an error: {}",
317-
err
318-
);
301+
error!("Go wrapper function go_uninstall_helm_release encountered an error: {err}");
319302

320303
return Err(Error::UninstallRelease { error: err });
321304
}
@@ -325,10 +308,7 @@ pub fn uninstall_release(
325308
));
326309
}
327310

328-
info!(
329-
"The Helm release {} is not installed, skipping.",
330-
release_name
331-
);
311+
info!("The Helm release {release_name} is not installed, skipping.");
332312

333313
Ok(UninstallReleaseStatus::NotInstalled(
334314
release_name.to_string(),
@@ -352,10 +332,7 @@ pub fn list_releases(namespace: &str) -> Result<Vec<Release>, Error> {
352332
let result = helm_sys::list_helm_releases(namespace);
353333

354334
if let Some(err) = helm_sys::to_helm_error(&result) {
355-
error!(
356-
"Go wrapper function go_helm_list_releases encountered an error: {}",
357-
err
358-
);
335+
error!("Go wrapper function go_helm_list_releases encountered an error: {err}");
359336

360337
return Err(Error::ListReleases { error: err });
361338
}
@@ -381,10 +358,7 @@ pub fn add_repo(repository_name: &str, repository_url: &str) -> Result<(), Error
381358
let result = helm_sys::add_helm_repository(repository_name, repository_url);
382359

383360
if let Some(err) = helm_sys::to_helm_error(&result) {
384-
error!(
385-
"Go wrapper function go_add_helm_repo encountered an error: {}",
386-
err
387-
);
361+
error!("Go wrapper function go_add_helm_repo encountered an error: {err}");
388362

389363
return Err(Error::AddRepo { error: err });
390364
}
@@ -403,7 +377,7 @@ where
403377
let url = Url::parse(repo_url.as_ref()).context(UrlParseSnafu)?;
404378
let url = url.join(HELM_REPO_INDEX_FILE).context(UrlParseSnafu)?;
405379

406-
debug!("Using {} to retrieve Helm index file", url);
380+
debug!("Using {url} to retrieve Helm index file");
407381

408382
// TODO (Techassi): Use the FileTransferClient for that
409383
let index_file_content = reqwest::get(url)

rust/stackable-cockpit/src/platform/cluster/resource_request.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ impl Display for ResourceRequests {
3232
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3333
write!(
3434
f,
35-
"CPU: {}, Memory: {}, PVC space: {}",
36-
self.cpu.0, self.memory.0, self.pvc.0
35+
"CPU: {cpu}, Memory: {memory}, PVC space: {pvc}",
36+
cpu = self.cpu.0,
37+
memory = self.memory.0,
38+
pvc = self.pvc.0
3739
)
3840
}
3941
}
@@ -67,8 +69,8 @@ pub enum ResourceRequestsError {
6769
#[derive(Debug, Snafu)]
6870
pub enum ResourceRequestsValidationError {
6971
#[snafu(display(
70-
"The {object_name} requires {} CPU core(s), but there are only {} CPU core(s) available in the cluster",
71-
required.as_cpu_count(), available.as_cpu_count()
72+
"The {object_name} requires {required_cpu} CPU core(s), but there are only {available_cpu} CPU core(s) available in the cluster",
73+
required_cpu = required.as_cpu_count(), available_cpu = available.as_cpu_count()
7274
))]
7375
InsufficientCpu {
7476
available: CpuQuantity,

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ pub struct Credentials {
2525

2626
impl Display for Credentials {
2727
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28-
write!(f, "{}:{}", self.username, self.password)
28+
write!(
29+
f,
30+
"{username}:{password}",
31+
username = self.username,
32+
password = self.password
33+
)
2934
}
3035
}
3136

rust/stackable-cockpit/src/platform/demo/spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub enum Error {
3535
#[snafu(display("demo resource requests error"), context(false))]
3636
DemoResourceRequests { source: ResourceRequestsError },
3737

38-
#[snafu(display("cannot install demo in namespace {requested:?}, only '{}' supported", supported.join(", ")))]
38+
#[snafu(display("cannot install demo in namespace {requested:?}, only {supported:?} supported", supported = supported.join(", ")))]
3939
UnsupportedNamespace {
4040
requested: String,
4141
supported: Vec<String>,

rust/stackable-cockpit/src/platform/stack/spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub enum Error {
4949

5050
/// This error indicates that the stack doesn't support being installed in
5151
/// the provided namespace.
52-
#[snafu(display("unable install stack in namespace {requested:?}, only '{}' supported", supported.join(", ")))]
52+
#[snafu(display("unable install stack in namespace {requested:?}, only {supported:?} supported", supported = supported.join(", ")))]
5353
UnsupportedNamespace {
5454
requested: String,
5555
supported: Vec<String>,

rust/stackable-cockpit/src/platform/stacklet/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ fn gvk_from_product_name(product_name: &str) -> GroupVersionKind {
197197
GroupVersionKind {
198198
group: format!("{product_name}.stackable.tech"),
199199
version: "v1alpha1".into(),
200-
kind: format!("{}Cluster", product_name.capitalize()),
200+
kind: format!(
201+
"{product_name}Cluster",
202+
product_name = product_name.capitalize()
203+
),
201204
}
202205
}

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ impl ConditionsExt for Vec<Condition> {
4343
self.iter()
4444
.map(|c| {
4545
DisplayCondition::new(
46-
format!("{}: {}", c.type_, c.status),
46+
format!(
47+
"{condition_type}: {status}",
48+
condition_type = c.type_,
49+
status = c.status
50+
),
4751
Some(c.message.clone()),
4852
c.is_good(),
4953
)
@@ -57,7 +61,11 @@ impl ConditionsExt for Vec<DeploymentCondition> {
5761
self.iter()
5862
.map(|c| {
5963
DisplayCondition::new(
60-
format!("{}: {}", c.type_, c.status),
64+
format!(
65+
"{condition_type}: {status}",
66+
condition_type = c.type_,
67+
status = c.status
68+
),
6169
c.message.clone(),
6270
c.is_good(),
6371
)
@@ -79,7 +87,11 @@ impl ConditionsExt for Vec<StatefulSetCondition> {
7987
self.iter()
8088
.map(|c| {
8189
DisplayCondition::new(
82-
format!("{}: {}", c.type_, c.status),
90+
format!(
91+
"{condition_type}: {status}",
92+
condition_type = c.type_,
93+
status = c.status
94+
),
8395
c.message.clone(),
8496
c.is_good(),
8597
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub trait ListParamsExt {
3737
impl ListParamsExt for ListParams {
3838
fn add_label(&mut self, label: impl Into<String>) {
3939
match self.label_selector.as_mut() {
40-
Some(labels) => labels.push_str(format!(",{}", label.into()).as_str()),
40+
Some(labels) => labels.push_str(format!(",{label}", label = label.into()).as_str()),
4141
None => self.label_selector = Some(label.into()),
4242
}
4343
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ pub mod templating;
88

99
/// Returns the name of the operator used in the Helm repository.
1010
pub fn operator_chart_name(name: &str) -> String {
11-
format!("{}-operator", name)
11+
format!("{name}-operator")
1212
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub enum RawParameterParseError {
106106

107107
impl Display for RawParameter {
108108
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
109-
write!(f, "{}={}", self.name, self.value)
109+
write!(f, "{name}={value}", name = self.name, value = self.value)
110110
}
111111
}
112112

0 commit comments

Comments
 (0)