@@ -10,11 +10,6 @@ import (
10
10
"sigs.k8s.io/controller-runtime/pkg/client"
11
11
)
12
12
13
- // NewClient returns a new interceptor client that calls the functions in fns instead of the underlying client's methods, if they are not nil.
14
- func NewClient (client client.WithWatch , fns Fns ) client.WithWatch {
15
- return interceptor {client : client , fns : fns }
16
- }
17
-
18
13
type (
19
14
// GetFn is a function that can be used to intercept GET calls.
20
15
GetFn func (ctx context.Context , client client.WithWatch , key client.ObjectKey , obj client.Object , opts ... client.GetOption ) error
@@ -66,6 +61,16 @@ type (
66
61
}
67
62
)
68
63
64
+ // NewClient returns a new interceptor client that calls the functions in fns instead of the underlying client's methods, if they are not nil.
65
+ func NewClient (client client.WithWatch , fns Fns ) client.WithWatch {
66
+ return interceptor {client : client , fns : fns }
67
+ }
68
+
69
+ // NewSubResourceClient returns a SubResourceClient that intercepts calls to the provided client with the provided functions.
70
+ func NewSubResourceClient (client client.SubResourceClient , fns SubResourceFns ) client.SubResourceClient {
71
+ return subResourceInterceptor {client : client , fns : fns }
72
+ }
73
+
69
74
type interceptor struct {
70
75
client client.WithWatch
71
76
fns Fns
@@ -163,11 +168,6 @@ type subResourceInterceptor struct {
163
168
164
169
var _ client.SubResourceClient = & subResourceInterceptor {}
165
170
166
- // NewSubResourceClient returns a SubResourceClient that intercepts calls to the provided client with the provided functions.
167
- func NewSubResourceClient (client client.SubResourceClient , fns SubResourceFns ) client.SubResourceClient {
168
- return subResourceInterceptor {client : client , fns : fns }
169
- }
170
-
171
171
func (s subResourceInterceptor ) Get (ctx context.Context , obj client.Object , subResource client.Object , opts ... client.SubResourceGetOption ) error {
172
172
if s .fns .Get != nil {
173
173
return s .fns .Get (ctx , s .client , obj , subResource , opts ... )
0 commit comments