@@ -20,6 +20,7 @@ import (
20
20
"context"
21
21
22
22
leasesapi "github.com/containerd/containerd/api/services/leases/v1"
23
+ "github.com/containerd/containerd/errdefs"
23
24
"github.com/containerd/containerd/leases"
24
25
)
25
26
@@ -47,7 +48,7 @@ func (pm *proxyManager) Create(ctx context.Context, opts ...leases.Opt) (leases.
47
48
Labels : l .Labels ,
48
49
})
49
50
if err != nil {
50
- return leases.Lease {}, err
51
+ return leases.Lease {}, errdefs . FromGRPC ( err )
51
52
}
52
53
53
54
return leases.Lease {
@@ -57,19 +58,27 @@ func (pm *proxyManager) Create(ctx context.Context, opts ...leases.Opt) (leases.
57
58
}, nil
58
59
}
59
60
60
- func (pm * proxyManager ) Delete (ctx context.Context , l leases.Lease ) error {
61
+ func (pm * proxyManager ) Delete (ctx context.Context , l leases.Lease , opts ... leases.DeleteOpt ) error {
62
+ var do leases.DeleteOptions
63
+ for _ , opt := range opts {
64
+ if err := opt (ctx , & do ); err != nil {
65
+ return err
66
+ }
67
+ }
68
+
61
69
_ , err := pm .client .Delete (ctx , & leasesapi.DeleteRequest {
62
- ID : l .ID ,
70
+ ID : l .ID ,
71
+ Sync : do .Synchronous ,
63
72
})
64
- return err
73
+ return errdefs . FromGRPC ( err )
65
74
}
66
75
67
76
func (pm * proxyManager ) List (ctx context.Context , filters ... string ) ([]leases.Lease , error ) {
68
77
resp , err := pm .client .List (ctx , & leasesapi.ListRequest {
69
78
Filters : filters ,
70
79
})
71
80
if err != nil {
72
- return nil , err
81
+ return nil , errdefs . FromGRPC ( err )
73
82
}
74
83
l := make ([]leases.Lease , len (resp .Leases ))
75
84
for i := range resp .Leases {
0 commit comments