Skip to content

Commit a2867a8

Browse files
committed
Remove redundant enum
I kept the trait but realized the enum is a bit redundant, especially since we have the Context enum
1 parent 50be98e commit a2867a8

File tree

1 file changed

+7
-50
lines changed

1 file changed

+7
-50
lines changed

src/mz-debug/src/main.rs

+7-50
Original file line numberDiff line numberDiff line change
@@ -129,41 +129,6 @@ pub struct Args {
129129
pub trait ContainerDumper {
130130
fn dump_container_resources(&self) -> impl std::future::Future<Output = ()>;
131131
}
132-
pub enum ContainerServiceDumper<'n> {
133-
K8s(K8sDumper<'n>),
134-
Docker(DockerDumper),
135-
}
136-
137-
impl<'n> ContainerServiceDumper<'n> {
138-
fn new_k8s_dumper(
139-
context: &'n Context,
140-
client: KubernetesClient,
141-
k8s_namespaces: Vec<String>,
142-
k8s_context: Option<String>,
143-
k8s_dump_secret_values: bool,
144-
) -> Self {
145-
Self::K8s(K8sDumper::new(
146-
context,
147-
client,
148-
k8s_namespaces,
149-
k8s_context,
150-
k8s_dump_secret_values,
151-
))
152-
}
153-
154-
fn new_docker_dumper(context: &'n Context, docker_container_id: String) -> Self {
155-
Self::Docker(DockerDumper::new(context, docker_container_id))
156-
}
157-
}
158-
159-
impl<'n> ContainerDumper for ContainerServiceDumper<'n> {
160-
async fn dump_container_resources(&self) {
161-
match self {
162-
ContainerServiceDumper::K8s(dumper) => dumper.dump_container_resources().await,
163-
ContainerServiceDumper::Docker(dumper) => dumper.dump_container_resources().await,
164-
}
165-
}
166-
}
167132
#[derive(Clone)]
168133
struct SelfManagedContext {
169134
dump_k8s: bool,
@@ -316,7 +281,7 @@ async fn initialize_context(
316281
async fn run(context: Context) -> Result<(), anyhow::Error> {
317282
// Depending on if the user is debugging either a k8s environments or docker environment,
318283
// dump the respective system's resources
319-
let container_system_dumper = match &context.debug_mode_context {
284+
match &context.debug_mode_context {
320285
DebugModeContext::SelfManaged(SelfManagedContext {
321286
k8s_client,
322287
dump_k8s,
@@ -326,34 +291,26 @@ async fn run(context: Context) -> Result<(), anyhow::Error> {
326291
..
327292
}) => {
328293
if *dump_k8s {
329-
Some(ContainerServiceDumper::new_k8s_dumper(
294+
let dumper = K8sDumper::new(
330295
&context,
331296
k8s_client.clone(),
332297
k8s_namespaces.clone(),
333298
k8s_context.clone(),
334299
*k8s_dump_secret_values,
335-
))
336-
} else {
337-
None
300+
);
301+
dumper.dump_container_resources().await;
338302
}
339303
}
340304
DebugModeContext::Emulator(EmulatorContext {
341305
dump_docker,
342306
docker_container_id,
343307
}) => {
344308
if *dump_docker {
345-
Some(ContainerServiceDumper::new_docker_dumper(
346-
&context,
347-
docker_container_id.clone(),
348-
))
349-
} else {
350-
None
351-
}
352-
}
353-
};
354-
if let Some(dumper) = container_system_dumper {
309+
let dumper = DockerDumper::new(&context, docker_container_id.clone());
355310
dumper.dump_container_resources().await;
356311
}
312+
}
313+
};
357314

358315
if context.dump_system_catalog {
359316
// Dump the system catalog.

0 commit comments

Comments
 (0)