feat: [#377] Add JSON output to release command#379
Merged
Conversation
- Add ReleaseDetailsData DTO (mirrors ConfigureDetailsData pattern) - Fields: environment_name, instance_name, provider, state, instance_ip, created_at - Derives Debug, Clone, PartialEq, Serialize - From<&Environment<Released>> conversion in presentation layer - Add JsonView and TextView for release command - JsonView::render() serializes to pretty-printed JSON - TextView::render() formats as human-readable environment details - Both follow Strategy Pattern from configure command - Update ReleaseCommandController - execute() now accepts output_format: OutputFormat parameter - release_application() returns Environment<Released> instead of () - complete_workflow() renders via view strategy (Text or Json) - Update router to pass output_format to release controller - Register release views module in commands mod.rs - Add unit tests for DTO, JsonView, and TextView
Member
Author
|
ACK e9a9209 |
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
Closes #377. Part of epic #348 (Phase 2 — JSON output for all commands).
Adds
--output-format jsonsupport to thereleasecommand, following the same Strategy Pattern established by theconfigurecommand (#371).Changes
New:
src/presentation/views/commands/release/view_data/release_details.rs—ReleaseDetailsDataDTO withFrom<&Environment<Released>>conversionviews/json_view.rs—JsonView::render()producing pretty-printed JSONviews/text_view.rs—TextView::render()producing formatted human-readable textUpdated: Controller & Router
src/presentation/controllers/release/handler.rs—execute()now acceptsoutput_format: OutputFormat;release_application()returnsEnvironment<Released>instead of discarding it;complete_workflow()uses Strategy Patternsrc/presentation/controllers/release/tests.rs— updated existing tests to passOutputFormat::Textsrc/presentation/dispatch/router.rs— passesoutput_formatfrom context to controllersrc/presentation/views/commands/mod.rs— registeredreleasemoduleJSON Output Example
{ "environment_name": "my-env", "instance_name": "torrust-tracker-vm-my-env", "provider": "lxd", "state": "Released", "instance_ip": "10.140.190.101", "created_at": "2026-02-23T08:26:06.789141249Z" }Usage
Tests
ReleaseDetailsData::from()(conversion + state string + IP presence)JsonView::render()(valid JSON, all fields, null IP)TextView::render()(all sections, not-available IP, formatted timestamp)Reference Implementation
Follows the pattern from
configurecommand (src/presentation/views/commands/configure/).