Show actual disk size instead of size spec in resize command (#51)

* Show actual disk size instead of size spec in resize command

After a --no-disk resize, `dropkit resize` showed the size spec's disk
(e.g. 80 GB for s-2vcpu-4gb) instead of the droplet's actual disk
(25 GB).  This is confusing for users planning temporary scale-ups —
they need to see their real disk to know if they can scale back down.

Read disk from `droplet["disk"]` (actual allocation) instead of
`droplet["size"]["disk"]` (what the size tier offers).  When the two
differ, show an inline hint: "25 GB (size spec: 80 GB, disk was not
resized)" so the situation is immediately clear.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Use actual droplet vcpus and memory, not just disk

Read all three resource fields from the droplet object directly
(droplet["vcpus"], droplet["memory"], droplet["disk"]) instead of
from the size spec (droplet["size"]["vcpus"], etc.).  After a
--no-disk resize these can diverge — the size spec reflects the
new tier while the droplet retains its original resources.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Grzegorz Wierzowiecki
2026-03-24 11:45:47 +01:00
committed by GitHub
parent 3fc2da20ba
commit 44cb274bcc
+21 -4
View File
@@ -3362,14 +3362,31 @@ def resize(
current_table.add_column(style="dim")
current_table.add_column(style="white")
current_vcpus = current_size_info.get("vcpus", "N/A")
current_memory = current_size_info.get("memory", "N/A")
current_disk = current_size_info.get("disk", "N/A")
# Use the droplet's actual resource values, not the size spec's.
# After a --no-disk resize, the size spec reflects the new tier
# (e.g. 80 GB disk for s-2vcpu-4gb) while the droplet's actual
# resources may differ (e.g. still 25 GB disk).
current_vcpus = droplet.get("vcpus", current_size_info.get("vcpus", "N/A"))
current_memory = droplet.get("memory", current_size_info.get("memory", "N/A"))
current_disk = droplet.get("disk", current_size_info.get("disk", "N/A"))
current_price = current_size_info.get("price_monthly", 0)
current_table.add_row("vCPUs:", str(current_vcpus))
current_table.add_row("Memory:", f"{current_memory} MB")
current_table.add_row("Disk:", f"{current_disk} GB")
# Show hint when actual disk is smaller than the size spec
# (happens after a previous --no-disk resize)
spec_disk = current_size_info.get("disk")
if (
isinstance(current_disk, int)
and isinstance(spec_disk, int)
and current_disk < spec_disk
):
current_table.add_row(
"Disk:",
f"{current_disk} GB [dim](size spec: {spec_disk} GB, disk was not resized)[/dim]",
)
else:
current_table.add_row("Disk:", f"{current_disk} GB")
current_table.add_row("Price:", f"${current_price:.2f}/month")
console.print(current_table)