diff --git a/client.go b/client.go index 6c5814425..f340e9509 100644 --- a/client.go +++ b/client.go @@ -133,7 +133,7 @@ func (c *Client) Containers(ctx context.Context, filters ...string) ([]Container // NewContainer will create a new container in container with the provided id // the id must be unique within the namespace func (c *Client) NewContainer(ctx context.Context, id string, opts ...NewContainerOpts) (Container, error) { - ctx, done, err := c.withLease(ctx) + ctx, done, err := c.WithLease(ctx) if err != nil { return nil, err } @@ -214,7 +214,7 @@ func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpt) (Image } store := c.ContentStore() - ctx, done, err := c.withLease(ctx) + ctx, done, err := c.WithLease(ctx) if err != nil { return nil, err } @@ -587,7 +587,7 @@ func (c *Client) Import(ctx context.Context, ref string, reader io.Reader, opts return nil, err } - ctx, done, err := c.withLease(ctx) + ctx, done, err := c.WithLease(ctx) if err != nil { return nil, err } diff --git a/lease.go b/lease.go index 6ecc58dec..8eb3bc0fe 100644 --- a/lease.go +++ b/lease.go @@ -51,7 +51,8 @@ func (c *Client) ListLeases(ctx context.Context) ([]Lease, error) { return leases, nil } -func (c *Client) withLease(ctx context.Context) (context.Context, func() error, error) { +// WithLease attaches a lease on the context +func (c *Client) WithLease(ctx context.Context) (context.Context, func() error, error) { _, ok := leases.Lease(ctx) if ok { return ctx, func() error { diff --git a/task.go b/task.go index c69579764..2cbcbaff1 100644 --- a/task.go +++ b/task.go @@ -356,7 +356,7 @@ func (t *task) Resize(ctx context.Context, w, h uint32) error { } func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (Image, error) { - ctx, done, err := t.client.withLease(ctx) + ctx, done, err := t.client.WithLease(ctx) if err != nil { return nil, err }