Skip to content

Commit 0ddcd57

Browse files
chore: Fix clippy warnings
1 parent 6b0a860 commit 0ddcd57

File tree

15 files changed

+73
-45
lines changed

15 files changed

+73
-45
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub type Result<T, E = Error> = std::result::Result<T, E>;
1111
#[derive(Debug, Snafu)]
1212
pub enum Error {
1313
#[snafu(display("failed to fetch data from Kubernetes API"))]
14-
KubeClientFetch { source: k8s::Error },
14+
KubeClientFetch { source: Box<k8s::Error> },
1515

1616
#[snafu(display("no credentials secret found"))]
1717
NoSecret,
@@ -69,6 +69,7 @@ pub async fn get(
6969
"adminUser.password",
7070
)
7171
.await
72+
.map_err(Box::new)
7273
.context(KubeClientFetchSnafu)?
7374
}
7475
"nifi" => {
@@ -84,6 +85,7 @@ pub async fn get(
8485
"password",
8586
)
8687
.await
88+
.map_err(Box::new)
8789
.context(KubeClientFetchSnafu)?
8890
}
8991
_ => return Ok(None),

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::utils::k8s::{self, Client};
55
#[derive(Debug, Snafu)]
66
pub enum Error {
77
#[snafu(display("failed to create Kubernetes client"))]
8-
KubeClientCreate { source: k8s::Error },
8+
KubeClientCreate { source: Box<k8s::Error> },
99

1010
#[snafu(display(
1111
"permission denied - try to create the namespace manually or choose an already existing one to which you have access to"
@@ -24,9 +24,11 @@ pub async fn create_if_needed(client: &Client, name: String) -> Result<(), Error
2424
k8s::Error::KubeClientCreate { source } => match source {
2525
kube::Error::Api(err) if err.code == 401 => Error::PermissionDenied,
2626
_ => Error::KubeClientCreate {
27-
source: k8s::Error::KubeClientCreate { source },
27+
source: Box::new(k8s::Error::KubeClientCreate { source }),
2828
},
2929
},
30-
_ => Error::KubeClientCreate { source: err },
30+
_ => Error::KubeClientCreate {
31+
source: Box::new(err),
32+
},
3133
})
3234
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub enum Error {
4949
BackgroundTask { source: JoinError },
5050

5151
#[snafu(display("failed to deploy manifests using the kube client"))]
52-
DeployManifest { source: k8s::Error },
52+
DeployManifest { source: Box<k8s::Error> },
5353
}
5454

5555
#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -195,6 +195,7 @@ impl ReleaseSpec {
195195
k8s_client
196196
.replace_crds(&crd_manifests)
197197
.await
198+
.map_err(Box::new)
198199
.context(DeployManifestSnafu)?;
199200

200201
info!("Upgraded {product_name}-operator CRDs");

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::utils::k8s::{self, Client, ListParamsExt};
1818
#[derive(Debug, Snafu)]
1919
pub enum Error {
2020
#[snafu(display("failed to fetch data from Kubernetes API"))]
21-
KubeClientFetch { source: k8s::Error },
21+
KubeClientFetch { source: Box<k8s::Error> },
2222

2323
#[snafu(display("missing namespace for service {service:?}"))]
2424
MissingServiceNamespace { service: String },
@@ -62,6 +62,7 @@ pub async fn get_endpoints(
6262
}
6363
Err(err) => Err(err),
6464
}
65+
.map_err(Box::new)
6566
.context(KubeClientFetchSnafu)?;
6667

6768
let mut endpoints = IndexMap::new();
@@ -95,6 +96,7 @@ pub async fn get_endpoints(
9596
let services = client
9697
.list_services(Some(object_namespace), &list_params)
9798
.await
99+
.map_err(Box::new)
98100
.context(KubeClientFetchSnafu)?;
99101

100102
for service in services {
@@ -161,6 +163,7 @@ pub async fn get_endpoint_urls_for_nodeport(
161163
let endpoints = client
162164
.get_endpoints(service_namespace, service_name)
163165
.await
166+
.map_err(Box::new)
164167
.context(KubeClientFetchSnafu)?;
165168

166169
let node_name = match &endpoints.subsets {
@@ -288,7 +291,11 @@ async fn get_node_ip(client: &Client, node_name: &str) -> Result<String, Error>
288291
// TODO(sbernauer): Add caching. Not going to do so now, as listener-op
289292
// will replace this code entirely anyway.
290293
async fn get_node_name_ip_mapping(client: &Client) -> Result<HashMap<String, String>, Error> {
291-
let nodes = client.list_nodes().await.context(KubeClientFetchSnafu)?;
294+
let nodes = client
295+
.list_nodes()
296+
.await
297+
.map_err(Box::new)
298+
.context(KubeClientFetchSnafu)?;
292299

293300
let mut result = HashMap::new();
294301
for node in nodes {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub(super) async fn list(client: &Client, namespace: Option<&str>) -> Result<Vec
1616
let services = client
1717
.list_services(namespace, &params)
1818
.await
19+
.map_err(Box::new)
1920
.context(KubeClientFetchSnafu)?;
2021

2122
for service in services {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(super) async fn list(client: &Client, namespace: Option<&str>) -> Result<Vec
1717
let services = client
1818
.list_services(namespace, &params)
1919
.await
20+
.map_err(Box::new)
2021
.context(KubeClientFetchSnafu)?;
2122

2223
let console_services = services

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ pub struct Stacklet {
4242
#[derive(Debug, Snafu)]
4343
pub enum Error {
4444
#[snafu(display("failed to create Kubernetes client"))]
45-
KubeClientCreate { source: k8s::Error },
45+
KubeClientCreate { source: Box<k8s::Error> },
4646

4747
#[snafu(display("failed to fetch data from the Kubernetes API"))]
48-
KubeClientFetch { source: k8s::Error },
48+
KubeClientFetch { source: Box<k8s::Error> },
4949

5050
#[snafu(display("no namespace set for custom resource {crd_name:?}"))]
5151
CustomCrdNamespace { crd_name: String },
@@ -87,6 +87,7 @@ pub async fn get_credentials_for_product(
8787
let product_cluster = match client
8888
.get_namespaced_object(namespace, object_name, &product_gvk)
8989
.await
90+
.map_err(Box::new)
9091
.context(KubeClientFetchSnafu)?
9192
{
9293
Some(obj) => obj,
@@ -124,6 +125,7 @@ async fn list_stackable_stacklets(
124125
let objects = match client
125126
.list_objects(&product_gvk, namespace)
126127
.await
128+
.map_err(Box::new)
127129
.context(KubeClientFetchSnafu)?
128130
{
129131
Some(obj) => obj,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub(super) async fn list(client: &Client, namespace: Option<&str>) -> Result<Vec
1616
let services = client
1717
.list_services(namespace, &params)
1818
.await
19+
.map_err(Box::new)
1920
.context(KubeClientFetchSnafu)?;
2021

2122
for service in services {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(super) async fn list(client: &Client, namespace: Option<&str>) -> Result<Vec
1717
let services = client
1818
.list_services(namespace, &params)
1919
.await
20+
.map_err(Box::new)
2021
.context(KubeClientFetchSnafu)?;
2122

2223
for service in services {

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub enum Error {
5151
GVKDiscoveryRun { source: kube::error::Error },
5252

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

5656
// Using output close to Display for ObjectRef https://docs.rs/kube-runtime/0.99.0/src/kube_runtime/reflector/object_ref.rs.html#292-296
5757
#[snafu(display("failed to resolve GVK: {kind}.{version}.{group}",
@@ -440,13 +440,16 @@ impl Client {
440440
pub async fn create_namespace(&self, name: String) -> Result<()> {
441441
let namespace_api: Api<Namespace> = Api::all(self.client.clone());
442442
namespace_api
443-
.create(&PostParams::default(), &Namespace {
444-
metadata: ObjectMeta {
445-
name: Some(name),
443+
.create(
444+
&PostParams::default(),
445+
&Namespace {
446+
metadata: ObjectMeta {
447+
name: Some(name),
448+
..Default::default()
449+
},
446450
..Default::default()
447451
},
448-
..Default::default()
449-
})
452+
)
450453
.await
451454
.context(KubeClientPatchSnafu)?;
452455

0 commit comments

Comments
 (0)