leases: add WithLabel

This adds a new WithLabel function, which allows to set a single label on
a lease, without having to first construct an intermediate map[string]string.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2023-09-11 18:39:57 +02:00
parent 1480e3bd4f
commit f7089ba225
3 changed files with 45 additions and 14 deletions

View File

@@ -75,9 +75,7 @@ When you are done, use the unmount command.
ctx, done, err := client.WithLease(ctx,
leases.WithID(target),
leases.WithExpiration(24*time.Hour),
leases.WithLabels(map[string]string{
"containerd.io/gc.ref.snapshot." + snapshotter: target,
}),
leases.WithLabel("containerd.io/gc.ref.snapshot."+snapshotter, target),
)
if err != nil && !errdefs.IsAlreadyExists(err) {
return err