From 6edb87a2f7bd90dc8632338d487690be78686c8b Mon Sep 17 00:00:00 2001 From: Rafael Garcia Date: Wed, 10 Jun 2026 08:10:47 -0400 Subject: [PATCH 1/2] cli: show full snapshot ID in `snapshot list` so get/restore work `snapshot list` truncated the ID to 12 chars (TruncateID), but `snapshot get`/`snapshot restore` require the full 24-char ID, so the displayed ID returned 404. Show the full ID in the list table; `-q` output was already full and is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- pkg/cmd/snapshotcmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/snapshotcmd.go b/pkg/cmd/snapshotcmd.go index 70b8914..a45b60d 100644 --- a/pkg/cmd/snapshotcmd.go +++ b/pkg/cmd/snapshotcmd.go @@ -350,7 +350,7 @@ func handleSnapshotList(ctx context.Context, cmd *cli.Command) error { name = "-" } table.AddRow( - TruncateID(snapshot.ID), + snapshot.ID, name, string(snapshot.Kind), snapshot.SourceInstanceName, From f85254e70c63ba4cd4a8d6fa79ee8e09f516a18d Mon Sep 17 00:00:00 2001 From: rgarcia <72655+rgarcia@users.noreply.github.com> Date: Thu, 11 Jun 2026 22:15:45 +0000 Subject: [PATCH 2/2] cli: exclude snapshot ID column from table truncation The ID column carried the full 24-char ID but was still first in TruncOrder, so a narrow terminal would ellipsize it and defeat copy-paste into snapshot get/restore. Truncate NAME and SOURCE instead, and add a regression test. Co-Authored-By: Claude Opus 4.7 --- pkg/cmd/format_test.go | 32 ++++++++++++++++++++++++++++++++ pkg/cmd/snapshotcmd.go | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 pkg/cmd/format_test.go diff --git a/pkg/cmd/format_test.go b/pkg/cmd/format_test.go new file mode 100644 index 0000000..1c4586d --- /dev/null +++ b/pkg/cmd/format_test.go @@ -0,0 +1,32 @@ +package cmd + +import ( + "bytes" + "os" + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +// TestSnapshotListIDNotTruncated guards the snapshot list table: the ID column +// must keep its full width on a narrow terminal so the printed ID can be copied +// into `snapshot get`/`restore`. Truncatable columns (NAME, SOURCE) absorb the +// shrink instead. +func TestSnapshotListIDNotTruncated(t *testing.T) { + os.Setenv("COLUMNS", "40") + defer os.Unsetenv("COLUMNS") + + const fullID = "0123456789abcdef01234567" // 24-char snapshot ID + + var buf bytes.Buffer + table := NewTableWriter(&buf, "ID", "NAME", "KIND", "SOURCE", "CREATED") + table.TruncOrder = []int{1, 3} + table.AddRow(fullID, "a-very-long-snapshot-name", "memory", "a-very-long-source-instance-name", "3 minutes ago") + + widths := table.renderWidths() + assert.Equal(t, len(fullID), widths[0], "ID column should never be shrunk") + + table.Render() + assert.True(t, strings.Contains(buf.String(), fullID), "rendered table should contain the full ID") +} diff --git a/pkg/cmd/snapshotcmd.go b/pkg/cmd/snapshotcmd.go index a45b60d..d70dd30 100644 --- a/pkg/cmd/snapshotcmd.go +++ b/pkg/cmd/snapshotcmd.go @@ -343,7 +343,7 @@ func handleSnapshotList(ctx context.Context, cmd *cli.Command) error { } table := NewTableWriter(os.Stdout, "ID", "NAME", "KIND", "SOURCE", "CREATED") - table.TruncOrder = []int{0, 3} + table.TruncOrder = []int{1, 3} // NAME first, then SOURCE; never truncate ID (copy-paste target) for _, snapshot := range *snapshots { name := snapshot.Name if name == "" {