Skip to content

Commit ed760d5

Browse files
committed
chore: cargo fmt
```shell cargo +nightly-2025-01-15 fmt --all ```
1 parent 591d393 commit ed760d5

File tree

18 files changed

+149
-136
lines changed

18 files changed

+149
-136
lines changed

rust/stackable-cockpit/src/engine/kind/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,9 @@ impl Cluster {
141141
.await
142142
.context(CommandFailedToRunSnafu)?;
143143

144-
ensure!(
145-
output.status.success(),
146-
CommandErroredOutSnafu {
147-
error: String::from_utf8_lossy(&output.stderr)
148-
}
149-
);
144+
ensure!(output.status.success(), CommandErroredOutSnafu {
145+
error: String::from_utf8_lossy(&output.stderr)
146+
});
150147

151148
let output = String::from_utf8_lossy(&output.stdout);
152149
Ok(output.lines().any(|name| name == cluster_name))

rust/stackable-cockpit/src/oci.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,9 @@ pub async fn get_oci_index<'a>() -> Result<HashMap<&'a str, ChartSourceMetadata>
128128
HELM_REPO_NAME_TEST,
129129
HELM_REPO_NAME_DEV,
130130
] {
131-
source_index_files.insert(
132-
repo_name,
133-
ChartSourceMetadata {
134-
entries: HashMap::new(),
135-
},
136-
);
131+
source_index_files.insert(repo_name, ChartSourceMetadata {
132+
entries: HashMap::new(),
133+
});
137134
}
138135
let base_url = format!("https://{HELM_OCI_BASE}/api/v2.0");
139136

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ impl DemoSpec {
191191
transfer_client: &xfer::Client,
192192
) -> Result<(), Error> {
193193
info!("Installing demo manifests");
194-
Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("valid progress template"));
194+
Span::current().pb_set_style(
195+
&ProgressStyle::with_template("{spinner} Installing manifests")
196+
.expect("valid progress template"),
197+
);
195198

196199
let params = install_params
197200
.parameters

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::collections::HashMap;
33
use indicatif::ProgressStyle;
44
use snafu::{ResultExt, Snafu};
55
use stackable_operator::kvp::Labels;
6-
use tracing::{debug, info, info_span, instrument, Instrument as _, Span};
6+
use tracing::{Instrument as _, Span, debug, info, info_span, instrument};
77
use tracing_indicatif::span_ext::IndicatifSpanExt as _;
88

99
use crate::{
@@ -77,7 +77,8 @@ pub trait InstallManifestsExt {
7777
debug!("Installing manifests");
7878

7979
Span::current().pb_set_style(
80-
&ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("valid progress template")
80+
&ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}")
81+
.expect("valid progress template"),
8182
);
8283
Span::current().pb_set_length(manifests.len() as u64);
8384

@@ -97,18 +98,25 @@ pub trait InstallManifestsExt {
9798
debug!(helm_file, "Installing manifest from Helm chart");
9899

99100
// Read Helm chart YAML and apply templating
100-
let helm_file = helm_file.into_path_or_url().context(ParsePathOrUrlSnafu {
101-
path_or_url: helm_file.clone(),
102-
})?;
101+
let helm_file =
102+
helm_file.into_path_or_url().context(ParsePathOrUrlSnafu {
103+
path_or_url: helm_file.clone(),
104+
})?;
103105

104106
let helm_chart: helm::Chart = transfer_client
105107
.get(&helm_file, &Template::new(&parameters).then(Yaml::new()))
106108
.await
107109
.context(FileTransferSnafu)?;
108110

109111
info!(helm_chart.name, helm_chart.version, "Installing Helm chart",);
110-
Span::current().pb_set_message(format!("Installing {name} Helm chart", name = helm_chart.name).as_str());
111-
Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template"));
112+
Span::current().pb_set_message(
113+
format!("Installing {name} Helm chart", name = helm_chart.name)
114+
.as_str(),
115+
);
116+
Span::current().pb_set_style(
117+
&ProgressStyle::with_template("{spinner} {msg}")
118+
.expect("valid progress template"),
119+
);
112120

113121
// Assumption: that all manifest helm charts refer to repos not registries
114122
helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context(
@@ -139,7 +147,10 @@ pub trait InstallManifestsExt {
139147
}
140148
ManifestSpec::PlainYaml(manifest_file) => {
141149
debug!(manifest_file, "Installing YAML manifest");
142-
Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing YAML manifest").expect("valid progress template"));
150+
Span::current().pb_set_style(
151+
&ProgressStyle::with_template("{spinner} Installing YAML manifest")
152+
.expect("valid progress template"),
153+
);
143154

144155
// Read YAML manifest and apply templating
145156
let path_or_url =
@@ -162,8 +173,9 @@ pub trait InstallManifestsExt {
162173
}
163174

164175
Ok::<(), Error>(())
165-
166-
}.instrument(span).await?;
176+
}
177+
.instrument(span)
178+
.await?;
167179

168180
Span::current().pb_inc(1);
169181
}

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use indicatif::ProgressStyle;
44
use semver::Version;
55
use serde::Serialize;
66
use snafu::{ResultExt, Snafu, ensure};
7-
use tracing::{info, instrument, Span};
7+
use tracing::{Span, info, instrument};
88
use tracing_indicatif::{indicatif_println, span_ext::IndicatifSpanExt};
99

1010
use crate::{
@@ -93,10 +93,9 @@ impl FromStr for OperatorSpec {
9393
ensure!(len <= 2, InvalidEqualSignCountSnafu);
9494

9595
// Check if the provided operator name is in the list of valid operators
96-
ensure!(
97-
VALID_OPERATORS.contains(&parts[0]),
98-
InvalidNameSnafu { name: parts[0] }
99-
);
96+
ensure!(VALID_OPERATORS.contains(&parts[0]), InvalidNameSnafu {
97+
name: parts[0]
98+
});
10099

101100
// If there is only one part, the input didn't include
102101
// the optional version identifier
@@ -194,8 +193,11 @@ impl OperatorSpec {
194193
chart_source: &ChartSourceType,
195194
) -> Result<(), helm::Error> {
196195
info!(operator = %self, "Installing operator");
197-
Span::current().pb_set_message(format!("Installing {name}-operator", name = self.name).as_str());
198-
Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template"));
196+
Span::current()
197+
.pb_set_message(format!("Installing {name}-operator", name = self.name).as_str());
198+
Span::current().pb_set_style(
199+
&ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template"),
200+
);
199201

200202
let version = self.version.as_ref().map(|v| v.to_string());
201203
let helm_name = self.helm_name();

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use indicatif::ProgressStyle;
44
use serde::{Deserialize, Serialize};
55
use snafu::{ResultExt, Snafu};
66
use tokio::task::JoinError;
7-
use tracing::{info, instrument, Instrument, Span};
8-
use tracing_indicatif::{span_ext::IndicatifSpanExt as _};
7+
use tracing::{Instrument, Span, info, instrument};
8+
use tracing_indicatif::span_ext::IndicatifSpanExt as _;
99
#[cfg(feature = "openapi")]
1010
use utoipa::ToSchema;
1111

@@ -65,7 +65,8 @@ impl ReleaseSpec {
6565
) -> Result<()> {
6666
info!("Installing release");
6767
Span::current().pb_set_style(
68-
&ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("valid progress template")
68+
&ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}")
69+
.expect("valid progress template"),
6970
);
7071

7172
include_products.iter().for_each(|product| {
@@ -125,7 +126,8 @@ impl ReleaseSpec {
125126
info!("Uninstalling release");
126127

127128
Span::current().pb_set_style(
128-
&ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("valid progress template")
129+
&ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}")
130+
.expect("valid progress template"),
129131
);
130132
Span::current().pb_set_length(self.products.len() as u64);
131133

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ impl StackSpec {
205205
chart_source: &ChartSourceType,
206206
) -> Result<(), Error> {
207207
info!(self.release, "Trying to install release");
208-
Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing operators").expect("valid progress template"));
208+
Span::current().pb_set_style(
209+
&ProgressStyle::with_template("{spinner} Installing operators")
210+
.expect("valid progress template"),
211+
);
209212

210213
// Get the release by name
211214
let release = release_list
@@ -229,7 +232,10 @@ impl StackSpec {
229232
transfer_client: &xfer::Client,
230233
) -> Result<(), Error> {
231234
info!("Installing stack manifests");
232-
Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("valid progress template"));
235+
Span::current().pb_set_style(
236+
&ProgressStyle::with_template("{spinner} Installing manifests")
237+
.expect("valid progress template"),
238+
);
233239

234240
let parameters = install_params
235241
.parameters

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,11 @@ fn build_products_gvk_list<'a>(product_names: &[&'a str]) -> IndexMap<&'a str, G
170170
for product_name in product_names {
171171
// Why? Just why? Can we please make this consistent?
172172
if *product_name == "spark-history-server" {
173-
map.insert(
174-
*product_name,
175-
GroupVersionKind {
176-
group: "spark.stackable.tech".into(),
177-
version: "v1alpha1".into(),
178-
kind: "SparkHistoryServer".into(),
179-
},
180-
);
173+
map.insert(*product_name, GroupVersionKind {
174+
group: "spark.stackable.tech".into(),
175+
version: "v1alpha1".into(),
176+
kind: "SparkHistoryServer".into(),
177+
});
181178
continue;
182179
}
183180

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,16 +354,13 @@ impl Client {
354354
pub async fn create_namespace(&self, name: String) -> Result<()> {
355355
let namespace_api: Api<Namespace> = Api::all(self.client.clone());
356356
namespace_api
357-
.create(
358-
&PostParams::default(),
359-
&Namespace {
360-
metadata: ObjectMeta {
361-
name: Some(name),
362-
..Default::default()
363-
},
357+
.create(&PostParams::default(), &Namespace {
358+
metadata: ObjectMeta {
359+
name: Some(name),
364360
..Default::default()
365361
},
366-
)
362+
..Default::default()
363+
})
367364
.await
368365
.context(KubeClientPatchSnafu)?;
369366

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

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -281,23 +281,17 @@ mod test {
281281

282282
let p = iter.next();
283283
assert!(p.is_some());
284-
assert_eq!(
285-
p.unwrap(),
286-
&RawParameter {
287-
name: "param1".into(),
288-
value: "value1".into()
289-
}
290-
);
284+
assert_eq!(p.unwrap(), &RawParameter {
285+
name: "param1".into(),
286+
value: "value1".into()
287+
});
291288

292289
let p = iter.next();
293290
assert!(p.is_some());
294-
assert_eq!(
295-
p.unwrap(),
296-
&RawParameter {
297-
name: "param2".into(),
298-
value: "value2".into()
299-
}
300-
);
291+
assert_eq!(p.unwrap(), &RawParameter {
292+
name: "param2".into(),
293+
value: "value2".into()
294+
});
301295

302296
let p = iter.next();
303297
assert!(p.is_none());
@@ -315,23 +309,17 @@ mod test {
315309

316310
let p = iter.next();
317311
assert!(p.is_some());
318-
assert_eq!(
319-
p.unwrap(),
320-
&RawParameter {
321-
name: "param1".into(),
322-
value: "value1".into()
323-
}
324-
);
312+
assert_eq!(p.unwrap(), &RawParameter {
313+
name: "param1".into(),
314+
value: "value1".into()
315+
});
325316

326317
let p = iter.next();
327318
assert!(p.is_some());
328-
assert_eq!(
329-
p.unwrap(),
330-
&RawParameter {
331-
name: "param2".into(),
332-
value: "value2".into()
333-
}
334-
);
319+
assert_eq!(p.unwrap(), &RawParameter {
320+
name: "param2".into(),
321+
value: "value2".into()
322+
});
335323

336324
let p = iter.next();
337325
assert!(p.is_none());
@@ -379,13 +367,10 @@ mod test {
379367

380368
match input.into_params(valid_parameters) {
381369
Ok(validated) => panic!("SHOULD FAIL: {validated:?}"),
382-
Err(err) => assert_eq!(
383-
err,
384-
IntoParametersError::InvalidParameter {
385-
parameter: "param2".into(),
386-
expected: "param1".into()
387-
}
388-
),
370+
Err(err) => assert_eq!(err, IntoParametersError::InvalidParameter {
371+
parameter: "param2".into(),
372+
expected: "param1".into()
373+
}),
389374
}
390375
}
391376
}

0 commit comments

Comments
 (0)