Skip to content

Commit

Permalink
Revert "Reduce Error enum size by boxing ClashingMountPathDetails"
Browse files Browse the repository at this point in the history
This reverts commit 8727f9a.
  • Loading branch information
sbernauer committed Sep 26, 2024
1 parent e8220b9 commit b7b43b8
Showing 1 changed file with 21 additions and 36 deletions.
57 changes: 21 additions & 36 deletions crates/stackable-operator/src/builder/pod/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,25 @@ pub enum Error {

#[snafu(display(
"The volumeMount is clashing with an already existing volumeMount with the same mountPath but a different content. \
The shared mountPath is {:?}, \
the existing mount's volume name is {:?}, \
the existing mount's subPath is {:?}, \
the existing mount's SubPathExpr is {:?}, \
the new mount's volume name is {:?}, \
the new mount's subPath is {:?}, \
the new mount's SubPathExpr is {:?}",
details.mount_path,
details.existing_volume_name,
details.existing_sub_path,
details.existing_sub_path_expr,
details.new_volume_name,
details.new_sub_path,
details.new_sub_path_expr
The shared mountPath is {mount_path:?}, \
the existing mount's volume name is {existing_volume_name:?}, \
the existing mount's subPath is {existing_sub_path:?}, \
the existing mount's SubPathExpr is {existing_sub_path_expr:?}, \
the new mount's volume name is {new_volume_name:?}, \
the new mount's subPath is {new_sub_path:?}, \
the new mount's SubPathExpr is {new_sub_path_expr:?}"
))]
ClashingMountPath {
/// We need to box the details, so that the [`Error`] enum does not get too big
details: Box<ClashingMountPathDetails>,
mount_path: String,
existing_volume_name: String,
existing_sub_path: Option<String>,
existing_sub_path_expr: Option<String>,
new_volume_name: String,
new_sub_path: Option<String>,
new_sub_path_expr: Option<String>,
},
}

#[derive(Debug)]
pub struct ClashingMountPathDetails {
mount_path: String,
existing_volume_name: String,
existing_sub_path: Option<String>,
existing_sub_path_expr: Option<String>,
new_volume_name: String,
new_sub_path: Option<String>,
new_sub_path_expr: Option<String>,
}

/// A builder to build [`Container`] objects.
///
/// This will automatically create the necessary volumes and mounts for each `ConfigMap` which is added.
Expand Down Expand Up @@ -244,15 +231,13 @@ impl ContainerBuilder {
ensure!(
existing_volume_mount == &volume_mount,
ClashingMountPathSnafu {
details: Box::new(ClashingMountPathDetails {
mount_path: volume_mount.mount_path,
existing_volume_name: existing_volume_mount.name.clone(),
existing_sub_path: existing_volume_mount.sub_path.clone(),
existing_sub_path_expr: existing_volume_mount.sub_path_expr.clone(),
new_volume_name: volume_mount.name,
new_sub_path: volume_mount.sub_path,
new_sub_path_expr: volume_mount.sub_path_expr,
}),
mount_path: volume_mount.mount_path,
existing_volume_name: existing_volume_mount.name.clone(),
existing_sub_path: existing_volume_mount.sub_path.clone(),
existing_sub_path_expr: existing_volume_mount.sub_path_expr.clone(),
new_volume_name: volume_mount.name,
new_sub_path: volume_mount.sub_path,
new_sub_path_expr: volume_mount.sub_path_expr,
}
);
} else {
Expand Down

0 comments on commit b7b43b8

Please sign in to comment.