Skip to content

feat: add user feedback for volume attach/detach commands - #46

Open
cokerrd wants to merge 1 commit into
zsoftly:mainfrom
cokerrd:feat/volume-response-message
Open

feat: add user feedback for volume attach/detach commands#46
cokerrd wants to merge 1 commit into
zsoftly:mainfrom
cokerrd:feat/volume-response-message

Conversation

@cokerrd

@cokerrd cokerrd commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Adds feedback on the volume attach and volume detach commands. Previously the commands on success would display blank responses

Screenshot 2026-07-24 at 18 10 40 Screenshot 2026-07-24 at 18 10 53

Changes

  • Replaced previous (SLUG ,NAME, SIZE and VM ID) headers with (STATUS and MESSAGE) headers
  • Updated volume attach and detach tests to include status and message
new.mov

Summary by CodeRabbit

  • Improvements

    • Updated volume attach and detach commands to display operation status and messages.
    • Attach and detach responses now provide clearer feedback, such as whether storage is being attached or detached.
  • Tests

    • Added coverage to verify returned operation statuses and messages for volume attachment and detachment.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Volume attach and detach now propagate the complete API response envelope and display its STATUS and MESSAGE fields instead of volume details. Tests validate the returned response metadata.

Changes

Volume response propagation

Layer / File(s) Summary
API response contract
pkg/api/volume/volume.go, pkg/api/volume/volume_test.go
Attach and Detach return singleResponse envelopes, with tests validating operation status and messages.
CLI response output
internal/commands/volume.go
Attach and detach render response STATUS and MESSAGE tables while preserving error handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: ditahm6, godsonten, ditahkk

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding success feedback for volume attach and detach commands.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/api/volume/volume.go (1)

175-183: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Expose the response type used by the exported methods.

Attach and Detach now return *singleResponse, but singleResponse is unexported. Callers can use inferred values, but cannot name this type in interfaces, mocks, or function signatures. Rename it to SingleResponse or return another exported response type.

Also applies to: 186-192

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/volume/volume.go` around lines 175 - 183, Export the response type
returned by the exported Attach and Detach methods by renaming singleResponse to
SingleResponse and updating all references, including method signatures, local
variables, and related response uses. Preserve the existing response fields and
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/api/volume/volume_test.go`:
- Around line 160-164: Extend the attach response assertions in the relevant
volume tests, alongside the existing Status and Message checks, to verify that
resp.Data preserves the mock values for ID, Slug, and VirtualMachineID. Apply
the same envelope-data assertions to the additional test block referenced by the
comment, covering the new &resp return contract end to end.

---

Nitpick comments:
In `@pkg/api/volume/volume.go`:
- Around line 175-183: Export the response type returned by the exported Attach
and Detach methods by renaming singleResponse to SingleResponse and updating all
references, including method signatures, local variables, and related response
uses. Preserve the existing response fields and behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c31ca0f-1f9d-4b23-b482-128933870757

📥 Commits

Reviewing files that changed from the base of the PR and between b9d121c and 970d985.

📒 Files selected for processing (3)
  • internal/commands/volume.go
  • pkg/api/volume/volume.go
  • pkg/api/volume/volume_test.go

Comment on lines +160 to +164
if resp.Message != "Attaching block storage." {
t.Errorf("resp.Message = %q, want %q", resp.Message, "Attaching block storage.")
}
if resp.Status != "Success" {
t.Errorf("resp.Status = %q, want %q", resp.Status, "Success")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that the full response envelope preserves Data.

The mocks populate Data, but these tests only check Status and Message. Add assertions for fields such as resp.Data.ID, resp.Data.Slug, and resp.Data.VirtualMachineID for attach, so the new &resp return contract is covered end to end.

Proposed assertions
 if resp.Status != "Success" {
 	t.Errorf("resp.Status = %q, want %q", resp.Status, "Success")
 }
+if resp.Data.ID != "vol-1" {
+	t.Errorf("resp.Data.ID = %q, want %q", resp.Data.ID, "vol-1")
+}
+if resp.Data.Slug != "root-4153" {
+	t.Errorf("resp.Data.Slug = %q, want %q", resp.Data.Slug, "root-4153")
+}

Also applies to: 190-194

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/volume/volume_test.go` around lines 160 - 164, Extend the attach
response assertions in the relevant volume tests, alongside the existing Status
and Message checks, to verify that resp.Data preserves the mock values for ID,
Slug, and VirtualMachineID. Apply the same envelope-data assertions to the
additional test block referenced by the comment, covering the new &resp return
contract end to end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant