From 996dea44071acc13c46fe6dd9ae1ad0fd7a1f5c9 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:30:02 -0400 Subject: [PATCH] Refactor Name --- cmd/soroban-cli/src/commands/network/container/logs.rs | 2 +- cmd/soroban-cli/src/commands/network/container/shared.rs | 8 ++------ cmd/soroban-cli/src/commands/network/container/start.rs | 2 +- cmd/soroban-cli/src/commands/network/container/stop.rs | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/cmd/soroban-cli/src/commands/network/container/logs.rs b/cmd/soroban-cli/src/commands/network/container/logs.rs index 6d2908edc..99b36af9b 100644 --- a/cmd/soroban-cli/src/commands/network/container/logs.rs +++ b/cmd/soroban-cli/src/commands/network/container/logs.rs @@ -24,7 +24,7 @@ pub struct Cmd { impl Cmd { pub async fn run(&self) -> Result<(), Error> { - let container_name = Name::new(self.name.clone()).get_internal_container_name(); + let container_name = Name(self.name.clone()).get_internal_container_name(); let docker = self.container_args.connect_to_docker().await?; let logs_stream = &mut docker.logs( &container_name, diff --git a/cmd/soroban-cli/src/commands/network/container/shared.rs b/cmd/soroban-cli/src/commands/network/container/shared.rs index 5f4ac1166..f819f3ed3 100644 --- a/cmd/soroban-cli/src/commands/network/container/shared.rs +++ b/cmd/soroban-cli/src/commands/network/container/shared.rs @@ -126,12 +126,8 @@ impl fmt::Display for Network { } } -pub struct Name(String); +pub struct Name(pub String); impl Name { - pub fn new(name: String) -> Self { - Self(name) - } - pub fn get_internal_container_name(&self) -> String { format!("stellar-{}", self.0) } @@ -178,4 +174,4 @@ async fn check_docker_connection(docker: &Docker) -> Result<(), bollard::errors: Err(err) } } -} \ No newline at end of file +} diff --git a/cmd/soroban-cli/src/commands/network/container/start.rs b/cmd/soroban-cli/src/commands/network/container/start.rs index 35bf166c1..46348c297 100644 --- a/cmd/soroban-cli/src/commands/network/container/start.rs +++ b/cmd/soroban-cli/src/commands/network/container/start.rs @@ -164,7 +164,7 @@ impl Cmd { } fn container_name(&self) -> Name { - Name::new(self.name.clone().unwrap_or(self.network.to_string())) + Name(self.name.clone().unwrap_or(self.network.to_string())) } fn print_log_message(&self) { diff --git a/cmd/soroban-cli/src/commands/network/container/stop.rs b/cmd/soroban-cli/src/commands/network/container/stop.rs index c47dda32d..733c86436 100644 --- a/cmd/soroban-cli/src/commands/network/container/stop.rs +++ b/cmd/soroban-cli/src/commands/network/container/stop.rs @@ -29,7 +29,7 @@ pub struct Cmd { impl Cmd { pub async fn run(&self) -> Result<(), Error> { - let container_name = Name::new(self.name.clone()); + let container_name = Name(self.name.clone()); let docker = self.container_args.connect_to_docker().await?; println!( "ℹ️ Stopping container: {}",