Skip to content

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

Merged
ditahkk merged 1 commit into
zsoftly:mainfrom
cokerrd:feat/volume-response-message
Aug 21, 2026
Merged

feat: add user feedback for volume attach/detach commands#46
ditahkk merged 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

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cdf824c6-344d-419e-831a-ca33fcd92e94

📝 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.

@ditahkk ditahkk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. Blank output on success was confusing and your diagnosis is correct. Two inline notes before merge.

Also, we added a DCO sign-off requirement after you opened this PR. See CONTRIBUTING.md. Rebase with --signoff and force-push to pass the new check.

Comment thread internal/commands/volume.go Outdated
formatSize(vol.Size),
vol.VirtualMachineID,
}}
headers := []string{"STATUS", "MESSAGE"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The output no longer names the volume or VM, and scripts reading --output json lose the old keys. Since the API returns nothing, consider echoing the slugs the user passed in, or follow the pattern firewall create and portforward create use. Your choice on the shape. Please also note the output change in CHANGELOG.md.

Comment thread pkg/api/volume/volume.go Outdated

// Attach attaches a volume to a virtual machine.
func (s *Service) Attach(ctx context.Context, volumeSlug, vmSlug string) (*Volume, error) {
func (s *Service) Attach(ctx context.Context, volumeSlug, vmSlug string) (*singleResponse, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same return-type issue as on #45. Attach and Detach now return the unexported singleResponse, and the old signature breaks external callers. An exported result type fixes both. instance.ActionResponse is an existing pattern to mirror if useful.


svc := volume.NewService(newTestClient(t, srv))
vol, err := svc.Attach(context.Background(), "root-4153", "test-vm-1")
resp, err := svc.Attach(context.Background(), "root-4153", "test-vm-1")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The mock still builds a full Volume fixture but nothing asserts on it now. Trim it or assert on it. Fine to skip.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

got it, I'll just assert on it

@cokerrd
cokerrd force-pushed the feat/volume-response-message branch from 970d985 to f954be3 Compare August 20, 2026 02:20
Signed-off-by: Coker Richard <82083946+cokerrd@users.noreply.github.com>
@cokerrd
cokerrd force-pushed the feat/volume-response-message branch from f954be3 to 77249d2 Compare August 20, 2026 02:23
@cokerrd

cokerrd commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

updates have been pushed

@ditahkk
ditahkk merged commit c4265e9 into zsoftly:main Aug 21, 2026
12 of 13 checks passed
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.

2 participants