@@ -16,19 +16,58 @@ func NewClient(client client.WithWatch, fns Fns) client.WithWatch {
16
16
return interceptor {client : client , fns : fns }
17
17
}
18
18
19
- // Fns contains functions that are called instead of the underlying
20
- // client's methods.
21
- type Fns struct {
22
- Get func (ctx context.Context , client client.WithWatch , key client.ObjectKey , obj client.Object , opts ... client.GetOption ) error
23
- List func (ctx context.Context , client client.WithWatch , list client.ObjectList , opts ... client.ListOption ) error
24
- Create func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.CreateOption ) error
25
- Delete func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.DeleteOption ) error
26
- DeleteAllOf func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.DeleteAllOfOption ) error
27
- Update func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.UpdateOption ) error
28
- Patch func (ctx context.Context , client client.WithWatch , obj client.Object , patch client.Patch , opts ... client.PatchOption ) error
29
- Watch func (ctx context.Context , client client.WithWatch , obj client.ObjectList , opts ... client.ListOption ) (watch.Interface , error )
30
- SubResource func (client client.WithWatch , subResource string ) client.SubResourceClient
31
- }
19
+ type (
20
+ // GetFn is a function that can be used to intercept GET calls.
21
+ GetFn func (ctx context.Context , client client.WithWatch , key client.ObjectKey , obj client.Object , opts ... client.GetOption ) error
22
+ // ListFn is a function that can be used to intercept LIST calls.
23
+ ListFn func (ctx context.Context , client client.WithWatch , list client.ObjectList , opts ... client.ListOption ) error
24
+ // CreateFn is a function that can be used to intercept CREATE calls.
25
+ CreateFn func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.CreateOption ) error
26
+ // DeleteFn is a function that can be used to intercept DELETE calls.
27
+ DeleteFn func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.DeleteOption ) error
28
+ // DeleteAllOfFn is a function that can be used to intercept Collection DELETE calls.
29
+ DeleteAllOfFn func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.DeleteAllOfOption ) error
30
+ // UpdateFn is a function that can be used to intercept UPDATE calls.
31
+ UpdateFn func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.UpdateOption ) error
32
+ // PatchFn is a function that can be used to intercept PATCH calls.
33
+ PatchFn func (ctx context.Context , client client.WithWatch , obj client.Object , patch client.Patch , opts ... client.PatchOption ) error
34
+ // WatchFn is a function that can be used to intercept WATCH calls.
35
+ WatchFn func (ctx context.Context , client client.WithWatch , obj client.ObjectList , opts ... client.ListOption ) (watch.Interface , error )
36
+ // SubResourceFn is a function that can be used to intercept SubResource calls.
37
+ SubResourceFn func (client client.WithWatch , subResource string ) client.SubResourceClient
38
+
39
+ // SubResourceGetFn is a function that can be used to intercept SubResource GET calls.
40
+ SubResourceGetFn func (ctx context.Context , client client.SubResourceClient , obj client.Object , subResource client.Object , opts ... client.SubResourceGetOption ) error
41
+ // SubResourceCreateFn is a function that can be used to intercept SubResource CREATE calls.
42
+ SubResourceCreateFn func (ctx context.Context , client client.SubResourceClient , obj client.Object , subResource client.Object , opts ... client.SubResourceCreateOption ) error
43
+ // SubResourceUpdateFn is a function that can be used to intercept SubResource UPDATE calls.
44
+ SubResourceUpdateFn func (ctx context.Context , client client.SubResourceClient , obj client.Object , opts ... client.SubResourceUpdateOption ) error
45
+ // SubResourcePatchFn is a function that can be used to intercept SubResource PATCH calls.
46
+ SubResourcePatchFn func (ctx context.Context , client client.SubResourceClient , obj client.Object , patch client.Patch , opts ... client.SubResourcePatchOption ) error
47
+
48
+ // Fns contains functions that are called instead of the underlying
49
+ // client's methods.
50
+ Fns struct {
51
+ Get GetFn
52
+ List ListFn
53
+ Create CreateFn
54
+ Delete DeleteFn
55
+ DeleteAllOf DeleteAllOfFn
56
+ Update UpdateFn
57
+ Patch PatchFn
58
+ Watch WatchFn
59
+ SubResource SubResourceFn
60
+ }
61
+
62
+ // SubResourceInterceptorFns is a set of functions that can be used to intercept
63
+ // calls to a SubResourceClient.
64
+ SubResourceInterceptorFns struct {
65
+ Get SubResourceGetFn
66
+ Create SubResourceCreateFn
67
+ Update SubResourceUpdateFn
68
+ Patch SubResourcePatchFn
69
+ }
70
+ )
32
71
33
72
type interceptor struct {
34
73
client client.WithWatch
@@ -120,15 +159,6 @@ func (c interceptor) Watch(ctx context.Context, obj client.ObjectList, opts ...c
120
159
return c .client .Watch (ctx , obj , opts ... )
121
160
}
122
161
123
- // SubResourceInterceptorFns is a set of functions that can be used to intercept
124
- // calls to a SubResourceClient.
125
- type SubResourceInterceptorFns struct {
126
- Get func (ctx context.Context , client client.SubResourceClient , obj client.Object , subResource client.Object , opts ... client.SubResourceGetOption ) error
127
- Create func (ctx context.Context , client client.SubResourceClient , obj client.Object , subResource client.Object , opts ... client.SubResourceCreateOption ) error
128
- Update func (ctx context.Context , client client.SubResourceClient , obj client.Object , opts ... client.SubResourceUpdateOption ) error
129
- Patch func (ctx context.Context , client client.SubResourceClient , obj client.Object , patch client.Patch , opts ... client.SubResourcePatchOption ) error
130
- }
131
-
132
162
type subResourceInterceptor struct {
133
163
client client.SubResourceClient
134
164
fns SubResourceInterceptorFns
0 commit comments