feat: [#322] add purge command to remove local environment data#323
Merged
josecelano merged 6 commits intomainfrom Feb 6, 2026
Merged
feat: [#322] add purge command to remove local environment data#323josecelano merged 6 commits intomainfrom
josecelano merged 6 commits intomainfrom
Conversation
Implements Phase 3: User confirmation prompt for purge command. Changes: - Add confirmation flow with warning message - Prompt user for y/N confirmation before deletion - Skip prompt when --force flag is provided - Add IoError variant for stdin read failures - Implement show_confirmation_prompt() helper - Implement read_user_confirmation() helper The confirmation shows: - Warning about irreversible operation - List of what will be deleted (data/, build/, registry) - User prompt accepting y/yes or canceling otherwise Tested manually: - echo "n" | purge env → cancels with UserCancelled error - echo "y" | purge env → confirms and deletes directories - purge env --force → skips prompt and deletes immediately
Implements Phase 4: Comprehensive E2E tests for purge command. Changes: - Add run_purge_command() method to ProcessRunner - Add 5 E2E test scenarios: 1. Purge destroyed environment successfully 2. Fail when purging nonexistent environment 3. Purge with custom working directory 4. Complete lifecycle (create → destroy → purge) 5. Remove only specified environment data - Add assertion helpers: * assert_environment_not_exists() * assert_data_directory_not_exists() * assert_build_directory_not_exists() - Register purge_command module in tests/e2e/mod.rs All 5 tests pass successfully: - test it_should_complete_full_lifecycle_from_create_to_purge ... ok - test it_should_fail_when_purging_nonexistent_environment ... ok - test it_should_purge_destroyed_environment_successfully ... ok - test it_should_purge_with_custom_working_directory ... ok - test it_should_remove_only_specified_environment_data ... ok Tests verify: - Purge removes data/, build/, and registry entry - Error handling for nonexistent environments - Isolation between environments (purge one, others remain) - --force flag skips interactive confirmation - Custom working directory support
Adds comprehensive user documentation for the purge command. Changes: - Create docs/user-guide/commands/purge.md (426 lines) * Command syntax and options * Basic usage (interactive and automated) * What gets purged (data/, build/, registry) * Common use cases and workflows * When to use purge vs when not to * Idempotent operation details * Comprehensive troubleshooting section * Safety considerations and best practices * Comparison table: destroy vs purge * Recommended workflow (destroy → purge) - Update docs/user-guide/commands/README.md * Add purge to Environment Cleanup section * Add purge to command workflow (step 11) * Add purge to plumbing commands list * Add purge to state transitions table - Update docs/issues/322-add-purge-command-to-remove-local-data.md * Mark completed phases with ✅ * Update implementation plan progress * Document E2E test results * Add documentation tasks to Phase 4 Documentation covers: - Interactive vs automated usage (--force flag) - Complete use case scenarios - Normal workflow: destroy → purge - Reusing environment names - Automated cleanup scripts - Troubleshooting common issues - Safety warnings and best practices - Comparison with destroy command
Updates destroy command to suggest purge for complete cleanup.
Changes:
- Update DestroyCommandController::complete_workflow()
- Add purge command hint after successful destroy
- Message format:
💡 Local data preserved for debugging. To completely remove and reuse the name:
torrust-tracker-deployer purge {name} --force
- Add blank line before hint for readability
- Uses UserOutput.result() for informational message
Example output:
✅ Environment 'e2e-deployment' destroyed successfully
💡 Local data preserved for debugging. To completely remove and reuse the name:
torrust-tracker-deployer purge e2e-deployment --force
This improves discoverability of the purge command and guides users
through the complete cleanup workflow (destroy → purge).
Member
Author
|
ACK be2a5a7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
purgecommand that removes local data for environments in any state, with proper confirmation to prevent accidental data loss.Changes
--forceflag for automationdata/,build/, and registry entries--force)docs/user-guide/commands/purge.md(426 lines)Why This Feature
When the
destroycommand runs, it tears down infrastructure but preserves local data for debugging. This means:The
purgecommand solves this by safely removing local data after destruction.Testing
Implementation Details
Closes #322