Skip to content

Commit 1e30ad6

Browse files
committed
refactor: move SSH module from infrastructure/adapters to shared
- Move SSH module from src/infrastructure/adapters/ssh to src/shared/ssh - Update all import statements throughout codebase to use new shared location - Update module references in config, application commands, steps, and e2e tests - Update documentation examples within SSH module files - Remove SSH module from infrastructure/adapters module exports - All linters, unit tests, and e2e tests pass successfully This enables SSH module reuse across different parts of the application including e2e tests.
1 parent 09817fa commit 1e30ad6

File tree

23 files changed

+38
-32
lines changed

23 files changed

+38
-32
lines changed

src/application/commands/provision.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ use crate::infrastructure::adapters::ansible::AnsibleClient;
2727
#[allow(unused_imports)]
2828
use crate::infrastructure::adapters::lxd::InstanceName;
2929
use crate::infrastructure::adapters::opentofu::client::{InstanceInfo, OpenTofuError};
30-
use crate::infrastructure::adapters::ssh::{credentials::SshCredentials, SshError};
3130
use crate::infrastructure::ansible::AnsibleTemplateRenderer;
3231
use crate::infrastructure::executor::CommandError;
3332
use crate::infrastructure::tofu::{ProvisionTemplateError, TofuTemplateRenderer};
33+
use crate::shared::ssh::{credentials::SshCredentials, SshError};
3434

3535
/// Comprehensive error type for the `ProvisionCommand`
3636
#[derive(Debug, thiserror::Error)]

src/application/commands/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use crate::application::steps::{
2020
ValidateDockerComposeInstallationStep,
2121
ValidateDockerInstallationStep,
2222
};
23-
use crate::infrastructure::adapters::ssh::credentials::SshCredentials;
2423
use crate::infrastructure::executor::CommandError;
2524
use crate::infrastructure::remote_actions::RemoteActionError;
25+
use crate::shared::ssh::credentials::SshCredentials;
2626

2727
/// Comprehensive error type for the `TestCommand`
2828
#[derive(Debug, thiserror::Error)]

src/application/steps/connectivity/wait_ssh_connectivity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
use tracing::{info, instrument};
2222

23-
use crate::infrastructure::adapters::ssh::{SshClient, SshConnection, SshError};
23+
use crate::shared::ssh::{SshClient, SshConnection, SshError};
2424

2525
/// Step that waits for SSH connectivity to be established on a remote host
2626
pub struct WaitForSSHConnectivityStep {
@@ -78,7 +78,7 @@ impl WaitForSSHConnectivityStep {
7878
mod tests {
7979
use std::net::{IpAddr, Ipv4Addr};
8080

81-
use crate::infrastructure::adapters::ssh::SshCredentials;
81+
use crate::shared::ssh::SshCredentials;
8282

8383
use super::*;
8484

src/application/steps/rendering/ansible_templates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ use std::sync::Arc;
2424
use thiserror::Error;
2525
use tracing::{info, instrument};
2626

27-
use crate::infrastructure::adapters::ssh::credentials::SshCredentials;
2827
use crate::infrastructure::ansible::template::renderer::ConfigurationTemplateError;
2928
use crate::infrastructure::ansible::AnsibleTemplateRenderer;
3029
use crate::infrastructure::template::wrappers::ansible::inventory::{
3130
AnsibleHost, AnsiblePort, AnsiblePortError, InventoryContext, InventoryContextError,
3231
SshPrivateKeyFile, SshPrivateKeyFileError,
3332
};
33+
use crate::shared::ssh::credentials::SshCredentials;
3434

3535
/// Errors that can occur during Ansible template rendering step execution
3636
#[derive(Error, Debug)]

src/application/steps/validation/cloud_init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
2121
use tracing::{info, instrument};
2222

23-
use crate::infrastructure::adapters::ssh::SshConnection;
2423
use crate::infrastructure::remote_actions::{CloudInitValidator, RemoteAction, RemoteActionError};
24+
use crate::shared::ssh::SshConnection;
2525

2626
/// Step that validates cloud-init completion on a remote host
2727
pub struct ValidateCloudInitCompletionStep {
@@ -74,7 +74,7 @@ mod tests {
7474
use std::net::{IpAddr, Ipv4Addr};
7575
use std::path::PathBuf;
7676

77-
use crate::infrastructure::adapters::ssh::SshCredentials;
77+
use crate::shared::ssh::SshCredentials;
7878

7979
use super::*;
8080

src/application/steps/validation/docker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
2020
use tracing::{info, instrument};
2121

22-
use crate::infrastructure::adapters::ssh::SshConnection;
2322
use crate::infrastructure::remote_actions::{DockerValidator, RemoteAction, RemoteActionError};
23+
use crate::shared::ssh::SshConnection;
2424

2525
/// Step that validates Docker installation on a remote host
2626
pub struct ValidateDockerInstallationStep {
@@ -73,7 +73,7 @@ mod tests {
7373
use std::net::{IpAddr, Ipv4Addr};
7474
use std::path::PathBuf;
7575

76-
use crate::infrastructure::adapters::ssh::SshCredentials;
76+
use crate::shared::ssh::SshCredentials;
7777

7878
use super::*;
7979

src/application/steps/validation/docker_compose.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
2121
use tracing::{info, instrument};
2222

23-
use crate::infrastructure::adapters::ssh::SshConnection;
2423
use crate::infrastructure::remote_actions::{
2524
DockerComposeValidator, RemoteAction, RemoteActionError,
2625
};
26+
use crate::shared::ssh::SshConnection;
2727

2828
/// Step that validates Docker Compose installation on a remote host
2929
pub struct ValidateDockerComposeInstallationStep {
@@ -79,7 +79,7 @@ mod tests {
7979
use std::net::{IpAddr, Ipv4Addr};
8080
use std::path::PathBuf;
8181

82-
use crate::infrastructure::adapters::ssh::SshCredentials;
82+
use crate::shared::ssh::SshCredentials;
8383

8484
use super::*;
8585

src/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use std::path::PathBuf;
1818

1919
pub use crate::infrastructure::adapters::lxd::InstanceName;
20-
pub use crate::infrastructure::adapters::ssh::{SshConnection, SshCredentials};
20+
pub use crate::shared::ssh::{SshConnection, SshCredentials};
2121

2222
/// Configuration parameters for deployment environments.
2323
///

src/e2e/containers/actions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//!
2121
//! ```rust,no_run
2222
//! use torrust_tracker_deploy::e2e::containers::{ContainerExecutor, actions::{SshKeySetupAction, SshWaitAction}};
23-
//! use torrust_tracker_deploy::infrastructure::adapters::ssh::SshCredentials;
23+
//! use torrust_tracker_deploy::shared::ssh::SshCredentials;
2424
//! use std::time::Duration;
2525
//!
2626
//! fn setup_container_ssh<T: ContainerExecutor>(

src/e2e/containers/actions/ssh_key_setup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use testcontainers::core::ExecCommand;
99
use tracing::info;
1010

1111
use crate::e2e::containers::ContainerExecutor;
12-
use crate::infrastructure::adapters::ssh::SshCredentials;
12+
use crate::shared::ssh::SshCredentials;
1313

1414
/// Specific error types for SSH key setup operations
1515
#[derive(Debug, thiserror::Error)]
@@ -89,7 +89,7 @@ pub type Result<T> = std::result::Result<T, SshKeySetupError>;
8989
///
9090
/// ```rust,no_run
9191
/// use torrust_tracker_deploy::e2e::containers::{ContainerExecutor, actions::SshKeySetupAction};
92-
/// use torrust_tracker_deploy::infrastructure::adapters::ssh::SshCredentials;
92+
/// use torrust_tracker_deploy::shared::ssh::SshCredentials;
9393
///
9494
/// fn setup_ssh<T: ContainerExecutor>(
9595
/// container: &T,

0 commit comments

Comments
 (0)