Skip to content

Commit a0f9d3c

Browse files
committed
refactor: extract SDK into packages/sdk/ workspace package
- Create packages/sdk/ (torrust-tracker-deployer-sdk) with SDK source - Copy builder.rs, deployer.rs, error.rs from src/presentation/sdk/ and update imports: crate:: → torrust_tracker_deployer_lib:: - Create packages/sdk/src/lib.rs with full public API re-exports - Move examples/sdk/ → packages/sdk/examples/ and update imports - Remove SDK [[example]] entries from root Cargo.toml - Add packages/sdk to workspace members - Add packages/sdk/README.md - Update .github/workflows/test-sdk-examples.yml to use -p flag - Update packages/README.md with SDK package entry - Update docs/codebase-architecture.md with Workspace Packages section - Note: root→SDK backward compat re-export deferred (cyclic dep); src/presentation/sdk/ kept intact until Plan 3 extracts shared types
1 parent e642a38 commit a0f9d3c

18 files changed

Lines changed: 947 additions & 306 deletions

.github/workflows/test-sdk-examples.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ jobs:
5656
5757
- name: Build SDK examples
5858
run: |
59-
cargo build --examples
59+
cargo build --examples -p torrust-tracker-deployer-sdk
6060
6161
- name: Run SDK examples
6262
run: |
6363
echo "🚀 Running SDK basic usage example at $(date)"
64-
cargo run --example sdk_basic_usage
64+
cargo run --example sdk_basic_usage -p torrust-tracker-deployer-sdk
6565
echo "✅ SDK basic usage example completed at $(date)"
6666
6767
echo "🚀 Running SDK error handling example at $(date)"
68-
cargo run --example sdk_error_handling
68+
cargo run --example sdk_error_handling -p torrust-tracker-deployer-sdk
6969
echo "✅ SDK error handling example completed at $(date)"
7070
7171
echo "🚀 Running SDK create-from-JSON-file example at $(date)"
72-
cargo run --example sdk_create_from_json_file
72+
cargo run --example sdk_create_from_json_file -p torrust-tracker-deployer-sdk
7373
echo "✅ SDK create-from-JSON-file example completed at $(date)"
7474
7575
echo "🚀 Running SDK validate-config example at $(date)"
76-
cargo run --example sdk_validate_config
76+
cargo run --example sdk_validate_config -p torrust-tracker-deployer-sdk
7777
echo "✅ SDK validate-config example completed at $(date)"
7878
7979
- name: Debug information (on failure)

Cargo.toml

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
members = [
33
"packages/linting",
44
"packages/dependency-installer",
5+
"packages/sdk",
56
]
67
resolver = "2"
78

@@ -40,26 +41,6 @@ path = "src/bin/linter.rs"
4041
name = "test_logging"
4142
path = "src/bin/test_logging.rs"
4243

43-
[[example]]
44-
name = "sdk_basic_usage"
45-
path = "examples/sdk/basic_usage.rs"
46-
47-
[[example]]
48-
name = "sdk_full_deployment"
49-
path = "examples/sdk/full_deployment.rs"
50-
51-
[[example]]
52-
name = "sdk_error_handling"
53-
path = "examples/sdk/error_handling.rs"
54-
55-
[[example]]
56-
name = "sdk_create_from_json_file"
57-
path = "examples/sdk/create_from_json_file.rs"
58-
59-
[[example]]
60-
name = "sdk_validate_config"
61-
path = "examples/sdk/validate_config.rs"
62-
6344
[dependencies]
6445
tokio = { version = "1.0", features = [ "full" ] }
6546
anyhow = "1.0"

docs/codebase-architecture.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ Application initialization and lifecycle management:
213213
-`src/bin/e2e-infrastructure-lifecycle-tests.rs` - E2E infrastructure lifecycle tests
214214
-`src/bin/e2e-complete-workflow-tests.rs` - Complete E2E workflow test suite
215215

216+
### Workspace Packages
217+
218+
Independently versioned Cargo workspace packages in `packages/`:
219+
220+
-`packages/linting/` - Unified linting framework (runs markdownlint, yamllint, taplo, cspell, clippy, rustfmt, shellcheck)
221+
-`packages/dependency-installer/` - Dependency detection and installation for development setup (OpenTofu, Ansible, LXD, cargo-machete)
222+
-`packages/sdk/` - Programmatic SDK (`torrust-tracker-deployer-sdk`) — independently consumable Rust crate for deploying Torrust Tracker instances without the CLI
223+
216224
### Presentation Layer
217225

218226
**CLI Interface and User Interaction:**
@@ -232,6 +240,14 @@ Application initialization and lifecycle management:
232240
-`src/presentation/views/` - User output formatting and message rendering
233241
-`src/presentation/errors.rs` - Unified error types with tiered help system
234242

243+
**SDK Interface (Programmatic API):**
244+
245+
-`src/presentation/sdk/mod.rs` - SDK module root with re-exports (kept for backward compatibility)
246+
-`src/presentation/sdk/builder.rs` - `DeployerBuilder` typed configuration builder
247+
-`src/presentation/sdk/deployer.rs` - `Deployer` facade (main SDK entry point)
248+
-`src/presentation/sdk/error.rs` - SDK-specific error types
249+
- → See `packages/sdk/` for the independently consumable SDK workspace package
250+
235251
### Domain Layer
236252

237253
**Core Domain Entities:**

docs/refactors/active-refactorings.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
| Document | Status | Issue | Target | Created |
44
| ----------------------------------------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------- | ----------------------------------------- | ---------- |
55
| [E2E Test Isolation - Complete Log Directory Support](plans/e2e-test-isolation-log-dir.md) | 📋 Planning | [#365](https://github.com/torrust/torrust-tracker-deployer/issues/365) | Add log_dir to all E2E tests | 2026-02-18 |
6-
| [Extract SDK Workspace Package](plans/extract-sdk-workspace-package.md) | 📋 Planning | TBD | Move SDK into packages/sdk/ | 2026-02-24 |
76
| [Extract Shared Types Package](plans/extract-shared-types-package.md) | 📋 Planning | TBD | Shared value objects for SDK consumers | 2026-02-24 |
87
| [SDK DDD Layer Boundary Fixes](plans/sdk-ddd-layer-boundary-fixes.md) | 📋 Planning | TBD | Remove DDD violations from SDK surface | 2026-02-24 |
98
| [Separate View Data from Views](plans/separate-view-data-from-views.md) | 📋 Planning | TBD | Organize presentation layer command views | 2026-02-16 |

docs/refactors/completed-refactorings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
| Document | Completed | Target | Notes |
44
| ------------------------------------------- | ------------ | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5+
| Extract SDK Workspace Package | Feb 25, 2026 | Create packages/sdk/ as independently consumable workspace package | See git history at `docs/refactors/plans/extract-sdk-workspace-package.md` - Created `packages/sdk/` (`torrust-tracker-deployer-sdk`) with SDK source, README, and examples moved from root `examples/sdk/`; backward compat deferred (cyclic dep resolved in Plan 3), PR #381 |
56
| Presentation CLI/SDK Separation | Feb 25, 2026 | Separate CLI and SDK in presentation layer | See git history at `docs/refactors/plans/presentation-cli-sdk-separation.md` - Moved all CLI-specific modules (controllers, dispatch, input, views, error, errors, tests) under `src/presentation/cli/`, updated 160 files, SDK confirmed zero CLI imports (commit f02024f6, PR #381) |
67
| Extract Template Rendering Services | Feb 10, 2026 | Eliminate rendering duplication | See git history at `docs/refactors/plans/extract-template-rendering-services.md` - Extracted template rendering logic into shared application-layer services for all 8 template types, eliminating duplication between render command and Steps (5 phases completed, final commit 463e7933) |
78
| Split tracker_ports.rs into Submodule | Feb 6, 2026 | Split 562-line file into focused submodule | See git history at `docs/refactors/plans/split-tracker-ports-into-submodule.md` - Refactored monolithic file into tracker_container_setup/ submodule with 5 focused files (container_ports, tracker_ports, config, runtime, mod), PR #319 |

docs/refactors/plans/extract-sdk-workspace-package.md

Lines changed: 0 additions & 271 deletions
This file was deleted.

0 commit comments

Comments
 (0)