Skip to content

Commit 638561e

Browse files
committed
refactor: [#220] remove unused update_environment_ssh_port function
- Removed update_environment_ssh_port() from generate_config.rs - not used anywhere - Removed function export from black_box module - Function was originally for bridge networking SSH port updates but never actually used - All 1395+ tests pass
1 parent 862b95d commit 638561e

File tree

2 files changed

+1
-51
lines changed

2 files changed

+1
-51
lines changed

src/testing/e2e/tasks/black_box/generate_config.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -183,53 +183,3 @@ pub fn create_test_environment_config(environment_name: &str) -> String {
183183
})
184184
.to_string()
185185
}
186-
187-
/// Update the SSH port in an existing environment configuration file
188-
///
189-
/// This is needed when using bridge networking where Docker assigns a random
190-
/// mapped port that differs from the configured port (22).
191-
///
192-
/// # Arguments
193-
/// * `environment_name` - Name of the environment
194-
/// * `mapped_ssh_port` - The actual SSH port mapped by Docker
195-
///
196-
/// # Errors
197-
/// Returns an error if the config file cannot be read, parsed, or written
198-
pub fn update_environment_ssh_port(environment_name: &str, mapped_ssh_port: u16) -> Result<()> {
199-
use std::fs;
200-
201-
// Get project root from current directory
202-
let project_root = std::env::current_dir()
203-
.map_err(|e| anyhow::anyhow!("Failed to get current directory: {e}"))?;
204-
205-
// Path to environment config file
206-
let config_path = project_root.join(format!("envs/{environment_name}.json"));
207-
208-
// Read existing config
209-
let config_content = fs::read_to_string(&config_path)
210-
.map_err(|e| anyhow::anyhow!("Failed to read config file: {e}"))?;
211-
212-
// Parse as JSON
213-
let mut config: serde_json::Value = serde_json::from_str(&config_content)
214-
.map_err(|e| anyhow::anyhow!("Failed to parse config JSON: {e}"))?;
215-
216-
// Update SSH port
217-
if let Some(created) = config.get_mut("Created") {
218-
if let Some(created_obj) = created.as_object_mut() {
219-
created_obj.insert("ssh_port".to_string(), serde_json::json!(mapped_ssh_port));
220-
}
221-
}
222-
223-
// Write updated config
224-
fs::write(&config_path, serde_json::to_string_pretty(&config)?)
225-
.map_err(|e| anyhow::anyhow!("Failed to write updated config: {e}"))?;
226-
227-
info!(
228-
environment_name = %environment_name,
229-
mapped_ssh_port = %mapped_ssh_port,
230-
config_path = %config_path.display(),
231-
"Updated environment configuration with mapped SSH port"
232-
);
233-
234-
Ok(())
235-
}

src/testing/e2e/tasks/black_box/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub use test_runner::E2eTestRunner;
5252
// Re-export standalone setup functions
5353
pub use generate_config::{
5454
create_test_environment_config, generate_environment_config,
55-
generate_environment_config_with_port, update_environment_ssh_port,
55+
generate_environment_config_with_port,
5656
};
5757
pub use preflight_cleanup::run_container_preflight_cleanup;
5858
pub use preflight_cleanup::run_preflight_cleanup;

0 commit comments

Comments
 (0)