Skip to content

Commit b66b57a

Browse files
committed
Cleanup
1 parent 483deea commit b66b57a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/client/interceptor/intercept.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ import (
1010
"sigs.k8s.io/controller-runtime/pkg/client"
1111
)
1212

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-
1813
type (
1914
// GetFn is a function that can be used to intercept GET calls.
2015
GetFn func(ctx context.Context, client client.WithWatch, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error
@@ -66,6 +61,16 @@ type (
6661
}
6762
)
6863

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+
6974
type interceptor struct {
7075
client client.WithWatch
7176
fns Fns
@@ -163,11 +168,6 @@ type subResourceInterceptor struct {
163168

164169
var _ client.SubResourceClient = &subResourceInterceptor{}
165170

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-
171171
func (s subResourceInterceptor) Get(ctx context.Context, obj client.Object, subResource client.Object, opts ...client.SubResourceGetOption) error {
172172
if s.fns.Get != nil {
173173
return s.fns.Get(ctx, s.client, obj, subResource, opts...)

0 commit comments

Comments
 (0)