elemental-toolkit/pkg
Fredrik Lönnegren f29ac2690f Avoid panic when MaxSnaps is set to 0
When the MaxSnaps configuration option is set to 0 the following panic
occurs during installation:

```
[PANICKED] Test Panicked
  In [It] at: /usr/lib64/go/1.24/src/runtime/panic.go:115 @ 07/01/25 10:04:57.47

  runtime error: index out of range [0] with length 0

  Full Stack Trace
    github.com/rancher/elemental-toolkit/v2/pkg/snapshotter.(*LoopDevice).cleanOldSnapshots(0xc00025a300)
        /home/frelon/src/elemental-toolkit/pkg/snapshotter/loopdevice.go:468 +0x3e7
    github.com/rancher/elemental-toolkit/v2/pkg/snapshotter.(*LoopDevice).CloseTransaction(0xc00025a300, 0xc000234a00)
        /home/frelon/src/elemental-toolkit/pkg/snapshotter/loopdevice.go:271 +0x11d5
    github.com/rancher/elemental-toolkit/v2/pkg/snapshotter_test.init.func3.12()
        /home/frelon/src/elemental-toolkit/pkg/snapshotter/loopdevice_test.go:204 +0x38e
```

This commit checks that we don't try to delete old snapshots in case
there are none.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
(cherry picked from commit d8450e01b9)
2025-07-31 17:49:46 +02:00
..
action Update year in headers 2025-03-13 16:20:24 +01:00
bootloader Update year in headers 2025-03-13 16:20:24 +01:00
cloudinit Update year in headers 2025-03-13 16:20:24 +01:00
config Update year in headers 2025-03-13 16:20:24 +01:00
constants Update year in headers 2025-03-13 16:20:24 +01:00
efi Update year in headers 2025-03-13 16:20:24 +01:00
elemental Update year in headers 2025-03-13 16:20:24 +01:00
error Update year in headers 2025-03-13 16:20:24 +01:00
features Update year in headers 2025-03-13 16:20:24 +01:00
http Update year in headers 2025-03-13 16:20:24 +01:00
mocks Update year in headers 2025-03-13 16:20:24 +01:00
partitioner Update year in headers 2025-03-13 16:20:24 +01:00
snapshotter Avoid panic when MaxSnaps is set to 0 2025-07-31 17:49:46 +02:00
systemd Update year in headers 2025-03-13 16:20:24 +01:00
types Update year in headers 2025-03-13 16:20:24 +01:00
utils Update year in headers 2025-03-13 16:20:24 +01:00