fix(server/show): include security_groups in JSON/YAML output (closes #191)#200
Merged
Conversation
…191) server show --format json previously returned security_groups: null because the underlying model.Server has no such field — the table renderer assembled SG names by querying /v2.0/ports?device_id=... and joining against /v2.0/security-groups, but the structured-format path just dumped the raw model and dropped that data. Move the port + SG resolution above the format branch and surface it through a serverShowDetail wrapper that embeds *model.Server (so existing JSON/YAML field names stay at the top level) plus security_groups, ports, and volumes. omitempty keeps the JSON shape for servers without ports; nil SG state therefore omits the field rather than resurrecting the null bug. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI's golangci-lint pulls in gofmt and the embedded *model.Server line needed an extra space for tag-column alignment. Pure formatting; no behaviour change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
JSON shape
```json
{
"id": "...",
"name": "web1",
"flavor": { "id": "..." },
"security_groups": ["IPv4v6-SSH", "3000-9999"],
"ports": [{ "id": "...", "mac_address": "...", "ips": ["..."] }],
"volumes": [{ "id": "...", "device": "/dev/vda", "size_gb": 100 }]
}
```
Test plan
Note
CSV output of `server show` was already not particularly useful (single struct → header + 1 row); behaviour is unchanged for CSV consumers.
🤖 Generated with Claude Code