Skip to content

Commit ce19127

Browse files
committed
refactor: remove verbose parameter and replace with tracing-based logging
- Remove verbose: bool fields from all structs (Config, TofuTemplateRenderer, AnsibleTemplateRenderer, CommandExecutor) - Update all constructors to remove verbose parameters - Update CLI documentation to reflect removal of --verbose flag - Rename test functions to accurately reflect new tracing-based approach - Add Default implementations for CommandExecutor and LxdClient to satisfy clippy - Update GitHub workflows to remove outdated --verbose references - Update project documentation to use RUST_LOG environment variable instead of CLI verbose flags The tracing crate provides better log level control through RUST_LOG environment variable, making the manual verbose boolean parameter redundant.
1 parent 1728f9d commit ce19127

20 files changed

+160
-228
lines changed

.github/workflows/test-e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ jobs:
5757
5858
- name: Run E2E test
5959
run: |
60-
# Run the E2E test with verbose output for better debugging
60+
# Run the E2E test with debug logging for better debugging
6161
# Use sudo -E and preserve PATH to ensure cargo is accessible
6262
echo "🚀 Starting E2E test at $(date)"
63-
sudo -E env "PATH=$PATH" cargo run --bin e2e-tests -- --verbose
63+
sudo -E env "PATH=$PATH" cargo run --bin e2e-tests
6464
echo "✅ E2E test completed at $(date)"
6565
env:
6666
# Preserve environment variables for the E2E test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ cargo run --bin e2e-tests
121121
# Keep the test environment after completion
122122
cargo run --bin e2e-tests -- --keep
123123

124-
# Run with verbose output
125-
cargo run --bin e2e-tests -- --verbose
124+
# Use custom templates directory
125+
cargo run --bin e2e-tests -- --templates-dir ./custom/templates
126126

127127
# See all available options
128128
cargo run --bin e2e-tests -- --help

docs/console-commands.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ torrust-deploy check [OPTIONS]
7171
**Options**:
7272

7373
- `--fix` - Attempt to auto-install missing tools
74-
- `--verbose` - Show detailed validation steps
74+
75+
**Environment Variables**:
76+
77+
- `RUST_LOG=debug` - Show detailed validation steps via tracing
7578

7679
**Example Output**:
7780

@@ -141,7 +144,10 @@ torrust-deploy provision <environment> [OPTIONS]
141144

142145
- `--auto-approve` - Skip confirmation prompts
143146
- `--keep-on-failure` - Don't cleanup on provision failure
144-
- `--verbose` - Detailed provisioning logs
147+
148+
**Environment Variables**:
149+
150+
- `RUST_LOG=debug` - Detailed provisioning logs via tracing
145151

146152
---
147153

@@ -333,7 +339,8 @@ torrust-deploy destroy <environment> [OPTIONS]
333339

334340
## Notes
335341

336-
- All commands should support `--verbose` flag for detailed output
342+
- All commands use the tracing crate for logging (control verbosity with `RUST_LOG` environment variable)
343+
- Set `RUST_LOG=debug` for detailed output, `RUST_LOG=info` for standard output
337344
- Configuration should be environment-aware once multi-env support is added
338345
- Error handling should be consistent across all commands
339346
- Each command should validate prerequisites before execution

docs/current-implementation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ These features are fully working in the E2E test environment:
5151

5252
- **`Config` struct**: Centralizes all deployment parameters
5353
- **Path Management**: Handles SSH keys, templates, build directories
54-
- **Runtime Parameters**: Verbose mode, cleanup behavior, provider settings
54+
- **Runtime Parameters**: Cleanup behavior, provider settings, SSH configuration
5555

5656
#### Service Container
5757

docs/deployment-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ torrust-deploy status # List all environments (future)
7474

7575
```bash
7676
# Simulate current working functionality through E2E tests
77-
cargo run --bin e2e-tests --verbose
77+
cargo run --bin e2e-tests
7878

7979
# This runs equivalent to:
8080
# provision: Creates LXD container with OpenTofu

docs/e2e-testing.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@ cargo run --bin e2e-tests
2121
### Command Line Options
2222

2323
- `--keep` - Keep the test environment after completion (useful for debugging)
24-
- `--verbose` - Enable verbose output to see detailed execution steps
24+
- `--templates-dir` - Specify custom templates directory path
2525
- `--help` - Show help information
2626

2727
### Examples
2828

2929
```bash
30-
# Run with verbose output
31-
cargo run --bin e2e-tests -- --verbose
30+
# Run basic e2e tests
31+
cargo run --bin e2e-tests
3232

3333
# Keep environment for debugging
3434
cargo run --bin e2e-tests -- --keep
3535

36+
# Use custom templates directory
37+
cargo run --bin e2e-tests -- --templates-dir ./custom/templates
38+
3639
# Combine options
37-
cargo run --bin e2e-tests -- --verbose --keep
40+
cargo run --bin e2e-tests -- --keep --templates-dir ./custom/templates
3841
```
3942

4043
## 📋 Test Sequence
@@ -158,7 +161,7 @@ GitHub Actions runners sometimes experience intermittent network connectivity pr
158161
Use the `--keep` flag to inspect the environment after test completion:
159162

160163
```bash
161-
cargo run --bin e2e-tests -- --keep --verbose
164+
cargo run --bin e2e-tests -- --keep
162165

163166
# After test completion, connect to the container:
164167
lxc exec torrust-vm -- /bin/bash

docs/e2e-tests-refactoring-plan.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ The current implementation executes most operations sequentially:
542542
```rust
543543
async fn run_parallel_validations(&self, container_ip: &str) -> Result<()> {
544544
let validators = vec![
545-
CloudInitValidator::new(&self.config.ssh_key_path, &self.config.ssh_username, self.config.verbose),
546-
DockerValidator::new(&self.config.ssh_key_path, &self.config.ssh_username, self.config.verbose),
547-
DockerComposeValidator::new(&self.config.ssh_key_path, &self.config.ssh_username, self.config.verbose),
545+
CloudInitValidator::new(&self.config.ssh_key_path, &self.config.ssh_username, container_ip),
546+
DockerValidator::new(&self.config.ssh_key_path, &self.config.ssh_username, container_ip),
547+
DockerComposeValidator::new(&self.config.ssh_key_path, &self.config.ssh_username, container_ip),
548548
];
549549

550550
let validation_tasks: Vec<_> = validators

src/actions/cloud_init.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ impl CloudInitValidator {
1717
/// * `ssh_key_path` - Path to the SSH private key file
1818
/// * `username` - SSH username to use for connections
1919
/// * `host_ip` - IP address of the target host
20-
/// * `verbose` - Whether to enable verbose SSH output
2120
#[must_use]
22-
pub fn new(ssh_key_path: &Path, username: &str, host_ip: IpAddr, verbose: bool) -> Self {
23-
let ssh_client = SshClient::new(ssh_key_path, username, host_ip, verbose);
21+
pub fn new(ssh_key_path: &Path, username: &str, host_ip: IpAddr) -> Self {
22+
let ssh_client = SshClient::new(ssh_key_path, username, host_ip);
2423
Self { ssh_client }
2524
}
2625
}

src/actions/docker.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ impl DockerValidator {
1717
/// * `ssh_key_path` - Path to the SSH private key file
1818
/// * `username` - SSH username to use for connections
1919
/// * `host_ip` - IP address of the target host
20-
/// * `verbose` - Whether to enable verbose SSH output
2120
#[must_use]
22-
pub fn new(ssh_key_path: &Path, username: &str, host_ip: IpAddr, verbose: bool) -> Self {
23-
let ssh_client = SshClient::new(ssh_key_path, username, host_ip, verbose);
21+
pub fn new(ssh_key_path: &Path, username: &str, host_ip: IpAddr) -> Self {
22+
let ssh_client = SshClient::new(ssh_key_path, username, host_ip);
2423
Self { ssh_client }
2524
}
2625
}

src/actions/docker_compose.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ impl DockerComposeValidator {
1717
/// * `ssh_key_path` - Path to the SSH private key file
1818
/// * `username` - SSH username to use for connections
1919
/// * `host_ip` - IP address of the target host
20-
/// * `verbose` - Whether to enable verbose SSH output
2120
#[must_use]
22-
pub fn new(ssh_key_path: &Path, username: &str, host_ip: IpAddr, verbose: bool) -> Self {
23-
let ssh_client = SshClient::new(ssh_key_path, username, host_ip, verbose);
21+
pub fn new(ssh_key_path: &Path, username: &str, host_ip: IpAddr) -> Self {
22+
let ssh_client = SshClient::new(ssh_key_path, username, host_ip);
2423
Self { ssh_client }
2524
}
2625
}

0 commit comments

Comments
 (0)