Print n/a for unset timestamps in backup and restore get (#10206)

velero backup get prints <nil> in CREATED for a backup that never
started, and velero restore get prints it in both STARTED and COMPLETED.
The timestamps are *metav1.Time and are appended to the row unformatted,
so a nil pointer reaches the user as Go's nil literal.

This is reachable in ordinary use. A backup that fails validation never
starts, so StartTimestamp is never set, and a restore that fails
validation gets neither timestamp.

formatTimestamp returns n/a for an unset value, matching
humanReadableTimeFromNow, which already handles a zero expiration in the
same row. A set timestamp is unchanged.

Adds tests for both printers, which had no row-level coverage.

Signed-off-by: saral <ilovegojo2580@gmail.com>
This commit is contained in:
Ralthos
2026-08-12 15:42:53 +08:00
committed by GitHub
parent 9a1d2e6eb0
commit 8d275e69cc
5 changed files with 148 additions and 3 deletions
+1
View File
@@ -0,0 +1 @@
Show n/a instead of <nil> for unset timestamps in velero backup get and velero restore get