-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmod.rs
More file actions
74 lines (72 loc) · 2.72 KB
/
mod.rs
File metadata and controls
74 lines (72 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! External Tool Adapters
//!
//! This module contains thin wrappers (adapters) for external CLI tools used throughout
//! the project. These adapters provide a consistent Rust interface for interacting with
//! external command-line tools.
//!
//! ## Design Philosophy
//!
//! All adapters in this module follow these principles:
//!
//! - **Thin wrappers**: Minimal business logic, primarily command builders
//! - **Consistent pattern**: All use `CommandExecutor` from `crate::shared::command`
//! - **Generic and reusable**: Designed to be usable across different projects
//! - **Infrastructure concerns**: Handle external system interactions
//!
//! ## Architecture
//!
//! Each adapter:
//!
//! 1. Wraps an external CLI tool (SSH, Docker, Ansible, LXD, `OpenTofu`)
//! 2. Uses `CommandExecutor` as a collaborator for actual command execution
//! 3. Provides domain-specific methods that return typed results
//! 4. Handles tool-specific error cases with structured error types
//!
//! ## Available Adapters
//!
//! - **`ansible`** - Ansible configuration management tool wrapper
//! - **`docker`** - Docker container platform wrapper
//! - **`lxd`** - LXD container and VM management wrapper
//! - **`network`** - Network diagnostic tools (netstat, ss) wrappers
//! - **`ssh`** - SSH secure shell client wrapper
//! - **`tofu`** - `OpenTofu` infrastructure provisioning wrapper
//!
//! ## Example Usage
//!
//! ```ignore
//! use std::sync::Arc;
//! use torrust_tracker_deployer_lib::adapters::ssh::{SshClient, SshConfig};
//! use torrust_tracker_deployer_lib::adapters::docker::DockerClient;
//!
//! // Create SSH client adapter
//! let ssh_config = SshConfig::default();
//! let ssh_client = SshClient::new(Arc::new(ssh_config));
//!
//! // Create Docker client adapter
//! let docker_client = DockerClient::new();
//! ```
//!
//! ## Relationship with Infrastructure Layer
//!
//! While these adapters live at the top level (`src/adapters/`), application-specific
//! logic for using these tools remains in `src/infrastructure/external_tools/`:
//!
//! - **`src/adapters/`**: Generic CLI wrappers (this module)
//! - **`src/infrastructure/external_tools/`**: Application-specific tool configuration
//! (e.g., Ansible inventory rendering, `OpenTofu` template generation)
//!
//! This separation ensures adapters remain reusable while application-specific logic
//! stays in the infrastructure layer.
pub mod ansible;
pub mod docker;
pub mod lxd;
pub mod network;
pub mod ssh;
pub mod tofu;
// Re-exports for commonly used types
pub use ansible::AnsibleClient;
pub use docker::DockerClient;
pub use lxd::LxdClient;
pub use network::{NetstatClient, SsClient};
pub use ssh::{SshClient, SshConfig, SshConnectionConfig, SshCredentials, SshPublicKey};
pub use tofu::OpenTofuClient;