Show image names in vm list and raise default memory

Make `banger vm list` easier to scan by resolving each VM image ID back to the registered image name when that mapping is available, while still falling back to a short ID for unknown images.

Raise the shared default VM memory from 1024 MiB to 2048 MiB so new VMs, CLI help, and daemon-side defaults all align on a 2 GiB baseline.

Add CLI coverage for the image-name rendering path and validate the change with go test ./..., make build, `banger vm list`, and `banger vm create --help`.
This commit is contained in:
Thales Maciel 2026-03-21 22:21:47 -03:00
parent 3b7e77a2de
commit 786d235f7f
No known key found for this signature in database
GPG key ID: 33112E6833C34679
3 changed files with 98 additions and 18 deletions

View file

@ -519,6 +519,59 @@ func TestPrintImageListTableShowsRootfsSizes(t *testing.T) {
}
}
func TestPrintVMListTableShowsImageNames(t *testing.T) {
var out bytes.Buffer
err := printVMListTable(&out, []model.VMRecord{
{
ID: "0123456789abcdef",
Name: "alp-fast",
ImageID: "image-alpine-123456",
State: model.VMStateRunning,
CreatedAt: time.Now().Add(-1 * time.Hour),
Spec: model.VMSpec{
VCPUCount: 2,
MemoryMiB: model.DefaultMemoryMiB,
WorkDiskSizeBytes: model.DefaultWorkDiskSize,
},
Runtime: model.VMRuntime{GuestIP: "172.16.0.4"},
},
{
ID: "fedcba9876543210",
Name: "mystery",
ImageID: "abcdef1234567890",
State: model.VMStateStopped,
CreatedAt: time.Now().Add(-2 * time.Hour),
Spec: model.VMSpec{
VCPUCount: 1,
MemoryMiB: 512,
WorkDiskSizeBytes: 4 * 1024 * 1024 * 1024,
},
},
}, map[string]string{
"image-alpine-123456": "alpine",
})
if err != nil {
t.Fatalf("printVMListTable() error = %v", err)
}
output := out.String()
if !strings.Contains(output, "IMAGE") || !strings.Contains(output, "MEM") {
t.Fatalf("output = %q, want vm list headers", output)
}
if !strings.Contains(output, "alp-fast") || !strings.Contains(output, "alpine") {
t.Fatalf("output = %q, want resolved image name", output)
}
if strings.Contains(output, "image-alpine-123456") {
t.Fatalf("output = %q, should not include full image id when name is known", output)
}
if !strings.Contains(output, shortID("abcdef1234567890")) {
t.Fatalf("output = %q, want short image id fallback", output)
}
if !strings.Contains(output, fmt.Sprintf("%d MiB", model.DefaultMemoryMiB)) {
t.Fatalf("output = %q, want updated default memory display", output)
}
}
func TestPrintVMPortsTableSortsAndRendersURLEndpoints(t *testing.T) {
result := api.VMPortsResult{
Name: "alpha",