@@ -11,69 +11,42 @@ import (
1111)
1212
1313type  (
14- 	// GetFn is a function that can be used to intercept GET calls. 
15- 	GetFn  func (ctx  context.Context , client  client.WithWatch , key  client.ObjectKey , obj  client.Object , opts  ... client.GetOption ) error 
16- 	// ListFn is a function that can be used to intercept LIST calls. 
17- 	ListFn  func (ctx  context.Context , client  client.WithWatch , list  client.ObjectList , opts  ... client.ListOption ) error 
18- 	// CreateFn is a function that can be used to intercept CREATE calls. 
19- 	CreateFn  func (ctx  context.Context , client  client.WithWatch , obj  client.Object , opts  ... client.CreateOption ) error 
20- 	// DeleteFn is a function that can be used to intercept DELETE calls. 
21- 	DeleteFn  func (ctx  context.Context , client  client.WithWatch , obj  client.Object , opts  ... client.DeleteOption ) error 
22- 	// DeleteAllOfFn is a function that can be used to intercept Collection DELETE calls. 
23- 	DeleteAllOfFn  func (ctx  context.Context , client  client.WithWatch , obj  client.Object , opts  ... client.DeleteAllOfOption ) error 
24- 	// UpdateFn is a function that can be used to intercept UPDATE calls. 
25- 	UpdateFn  func (ctx  context.Context , client  client.WithWatch , obj  client.Object , opts  ... client.UpdateOption ) error 
26- 	// PatchFn is a function that can be used to intercept PATCH calls. 
27- 	PatchFn  func (ctx  context.Context , client  client.WithWatch , obj  client.Object , patch  client.Patch , opts  ... client.PatchOption ) error 
28- 	// WatchFn is a function that can be used to intercept WATCH calls. 
29- 	WatchFn  func (ctx  context.Context , client  client.WithWatch , obj  client.ObjectList , opts  ... client.ListOption ) (watch.Interface , error )
30- 	// SubResourceFn is a function that can be used to intercept SubResource calls. 
31- 	SubResourceFn  func (client  client.WithWatch , subResource  string ) client.SubResourceClient 
32- 
33- 	// SubResourceGetFn is a function that can be used to intercept SubResource GET calls. 
34- 	SubResourceGetFn  func (ctx  context.Context , client  client.SubResourceClient , obj  client.Object , subResource  client.Object , opts  ... client.SubResourceGetOption ) error 
35- 	// SubResourceCreateFn is a function that can be used to intercept SubResource CREATE calls. 
36- 	SubResourceCreateFn  func (ctx  context.Context , client  client.SubResourceClient , obj  client.Object , subResource  client.Object , opts  ... client.SubResourceCreateOption ) error 
37- 	// SubResourceUpdateFn is a function that can be used to intercept SubResource UPDATE calls. 
38- 	SubResourceUpdateFn  func (ctx  context.Context , client  client.SubResourceClient , obj  client.Object , opts  ... client.SubResourceUpdateOption ) error 
39- 	// SubResourcePatchFn is a function that can be used to intercept SubResource PATCH calls. 
40- 	SubResourcePatchFn  func (ctx  context.Context , client  client.SubResourceClient , obj  client.Object , patch  client.Patch , opts  ... client.SubResourcePatchOption ) error 
41- 
42- 	// Fns contains functions that are called instead of the underlying client's methods. 
43- 	Fns  struct  {
44- 		Get          GetFn 
45- 		List         ListFn 
46- 		Create       CreateFn 
47- 		Delete       DeleteFn 
48- 		DeleteAllOf  DeleteAllOfFn 
49- 		Update       UpdateFn 
50- 		Patch        PatchFn 
51- 		Watch        WatchFn 
52- 		SubResource  SubResourceFn 
14+ 
15+ 	// Funcs contains functions that are called instead of the underlying client's methods. 
16+ 	Funcs  struct  {
17+ 		Get          func (ctx  context.Context , client  client.WithWatch , key  client.ObjectKey , obj  client.Object , opts  ... client.GetOption ) error 
18+ 		List         func (ctx  context.Context , client  client.WithWatch , list  client.ObjectList , opts  ... client.ListOption ) error 
19+ 		Create       func (ctx  context.Context , client  client.WithWatch , obj  client.Object , opts  ... client.CreateOption ) error 
20+ 		Delete       func (ctx  context.Context , client  client.WithWatch , obj  client.Object , opts  ... client.DeleteOption ) error 
21+ 		DeleteAllOf  func (ctx  context.Context , client  client.WithWatch , obj  client.Object , opts  ... client.DeleteAllOfOption ) error 
22+ 		Update       func (ctx  context.Context , client  client.WithWatch , obj  client.Object , opts  ... client.UpdateOption ) error 
23+ 		Patch        func (ctx  context.Context , client  client.WithWatch , obj  client.Object , patch  client.Patch , opts  ... client.PatchOption ) error 
24+ 		Watch        func (ctx  context.Context , client  client.WithWatch , obj  client.ObjectList , opts  ... client.ListOption ) (watch.Interface , error )
25+ 		SubResource  func (client  client.WithWatch , subResource  string ) client.SubResourceClient 
5326	}
5427
55- 	// SubResourceFns  is a set of functions that can be used to intercept calls to a SubResourceClient. 
56- 	SubResourceFns  struct  {
57- 		Get     SubResourceGetFn 
58- 		Create  SubResourceCreateFn 
59- 		Update  SubResourceUpdateFn 
60- 		Patch   SubResourcePatchFn 
28+ 	// SubResourceFuncs  is a set of functions that can be used to intercept calls to a SubResourceClient. 
29+ 	SubResourceFuncs  struct  {
30+ 		Get     func ( ctx  context. Context ,  client  client. SubResourceClient ,  obj  client. Object ,  subResource  client. Object ,  opts   ... client. SubResourceGetOption )  error 
31+ 		Create  func ( ctx  context. Context ,  client  client. SubResourceClient ,  obj  client. Object ,  subResource  client. Object ,  opts   ... client. SubResourceCreateOption )  error 
32+ 		Update  func ( ctx  context. Context ,  client  client. SubResourceClient ,  obj  client. Object ,  opts   ... client. SubResourceUpdateOption )  error 
33+ 		Patch   func ( ctx  context. Context ,  client  client. SubResourceClient ,  obj  client. Object ,  patch  client. Patch ,  opts   ... client. SubResourcePatchOption )  error 
6134	}
6235)
6336
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 (interceptedClient  client.WithWatch , fns   Fns ) client.WithWatch  {
66- 	return  interceptor {client : interceptedClient , fns :  fns }
37+ // NewClient returns a new interceptor client that calls the functions in funcs  instead of the underlying client's methods, if they are not nil. 
38+ func  NewClient (interceptedClient  client.WithWatch , funcs   Funcs ) client.WithWatch  {
39+ 	return  interceptor {client : interceptedClient , funcs :  funcs }
6740}
6841
6942// NewSubResourceClient returns a SubResourceClient that intercepts calls to the provided client with the provided functions. 
70- func  NewSubResourceClient (interceptedClient  client.SubResourceClient , fns   SubResourceFns ) client.SubResourceClient  {
71- 	return  subResourceInterceptor {client : interceptedClient , fns :  fns }
43+ func  NewSubResourceClient (interceptedClient  client.SubResourceClient , funcs   SubResourceFuncs ) client.SubResourceClient  {
44+ 	return  subResourceInterceptor {client : interceptedClient , funcs :  funcs }
7245}
7346
7447type  interceptor  struct  {
7548	client  client.WithWatch 
76- 	fns      Fns 
49+ 	funcs    Funcs 
7750}
7851
7952var  _  client.WithWatch  =  & interceptor {}
@@ -87,50 +60,50 @@ func (c interceptor) IsObjectNamespaced(obj runtime.Object) (bool, error) {
8760}
8861
8962func  (c  interceptor ) Get (ctx  context.Context , key  client.ObjectKey , obj  client.Object , opts  ... client.GetOption ) error  {
90- 	if  c .fns .Get  !=  nil  {
91- 		return  c .fns .Get (ctx , c .client , key , obj , opts ... )
63+ 	if  c .funcs .Get  !=  nil  {
64+ 		return  c .funcs .Get (ctx , c .client , key , obj , opts ... )
9265	}
9366	return  c .client .Get (ctx , key , obj , opts ... )
9467}
9568
9669func  (c  interceptor ) List (ctx  context.Context , list  client.ObjectList , opts  ... client.ListOption ) error  {
97- 	if  c .fns .List  !=  nil  {
98- 		return  c .fns .List (ctx , c .client , list , opts ... )
70+ 	if  c .funcs .List  !=  nil  {
71+ 		return  c .funcs .List (ctx , c .client , list , opts ... )
9972	}
10073	return  c .client .List (ctx , list , opts ... )
10174}
10275
10376func  (c  interceptor ) Create (ctx  context.Context , obj  client.Object , opts  ... client.CreateOption ) error  {
104- 	if  c .fns .Create  !=  nil  {
105- 		return  c .fns .Create (ctx , c .client , obj , opts ... )
77+ 	if  c .funcs .Create  !=  nil  {
78+ 		return  c .funcs .Create (ctx , c .client , obj , opts ... )
10679	}
10780	return  c .client .Create (ctx , obj , opts ... )
10881}
10982
11083func  (c  interceptor ) Delete (ctx  context.Context , obj  client.Object , opts  ... client.DeleteOption ) error  {
111- 	if  c .fns .Delete  !=  nil  {
112- 		return  c .fns .Delete (ctx , c .client , obj , opts ... )
84+ 	if  c .funcs .Delete  !=  nil  {
85+ 		return  c .funcs .Delete (ctx , c .client , obj , opts ... )
11386	}
11487	return  c .client .Delete (ctx , obj , opts ... )
11588}
11689
11790func  (c  interceptor ) Update (ctx  context.Context , obj  client.Object , opts  ... client.UpdateOption ) error  {
118- 	if  c .fns .Update  !=  nil  {
119- 		return  c .fns .Update (ctx , c .client , obj , opts ... )
91+ 	if  c .funcs .Update  !=  nil  {
92+ 		return  c .funcs .Update (ctx , c .client , obj , opts ... )
12093	}
12194	return  c .client .Update (ctx , obj , opts ... )
12295}
12396
12497func  (c  interceptor ) Patch (ctx  context.Context , obj  client.Object , patch  client.Patch , opts  ... client.PatchOption ) error  {
125- 	if  c .fns .Patch  !=  nil  {
126- 		return  c .fns .Patch (ctx , c .client , obj , patch , opts ... )
98+ 	if  c .funcs .Patch  !=  nil  {
99+ 		return  c .funcs .Patch (ctx , c .client , obj , patch , opts ... )
127100	}
128101	return  c .client .Patch (ctx , obj , patch , opts ... )
129102}
130103
131104func  (c  interceptor ) DeleteAllOf (ctx  context.Context , obj  client.Object , opts  ... client.DeleteAllOfOption ) error  {
132- 	if  c .fns .DeleteAllOf  !=  nil  {
133- 		return  c .fns .DeleteAllOf (ctx , c .client , obj , opts ... )
105+ 	if  c .funcs .DeleteAllOf  !=  nil  {
106+ 		return  c .funcs .DeleteAllOf (ctx , c .client , obj , opts ... )
134107	}
135108	return  c .client .DeleteAllOf (ctx , obj , opts ... )
136109}
@@ -140,8 +113,8 @@ func (c interceptor) Status() client.SubResourceWriter {
140113}
141114
142115func  (c  interceptor ) SubResource (subResource  string ) client.SubResourceClient  {
143- 	if  c .fns .SubResource  !=  nil  {
144- 		return  c .fns .SubResource (c .client , subResource )
116+ 	if  c .funcs .SubResource  !=  nil  {
117+ 		return  c .funcs .SubResource (c .client , subResource )
145118	}
146119	return  c .client .SubResource (subResource )
147120}
@@ -155,43 +128,43 @@ func (c interceptor) RESTMapper() meta.RESTMapper {
155128}
156129
157130func  (c  interceptor ) Watch (ctx  context.Context , obj  client.ObjectList , opts  ... client.ListOption ) (watch.Interface , error ) {
158- 	if  c .fns .Watch  !=  nil  {
159- 		return  c .fns .Watch (ctx , c .client , obj , opts ... )
131+ 	if  c .funcs .Watch  !=  nil  {
132+ 		return  c .funcs .Watch (ctx , c .client , obj , opts ... )
160133	}
161134	return  c .client .Watch (ctx , obj , opts ... )
162135}
163136
164137type  subResourceInterceptor  struct  {
165138	client  client.SubResourceClient 
166- 	fns      SubResourceFns 
139+ 	funcs    SubResourceFuncs 
167140}
168141
169142var  _  client.SubResourceClient  =  & subResourceInterceptor {}
170143
171144func  (s  subResourceInterceptor ) Get (ctx  context.Context , obj  client.Object , subResource  client.Object , opts  ... client.SubResourceGetOption ) error  {
172- 	if  s .fns .Get  !=  nil  {
173- 		return  s .fns .Get (ctx , s .client , obj , subResource , opts ... )
145+ 	if  s .funcs .Get  !=  nil  {
146+ 		return  s .funcs .Get (ctx , s .client , obj , subResource , opts ... )
174147	}
175148	return  s .client .Get (ctx , obj , subResource , opts ... )
176149}
177150
178151func  (s  subResourceInterceptor ) Create (ctx  context.Context , obj  client.Object , subResource  client.Object , opts  ... client.SubResourceCreateOption ) error  {
179- 	if  s .fns .Create  !=  nil  {
180- 		return  s .fns .Create (ctx , s .client , obj , subResource , opts ... )
152+ 	if  s .funcs .Create  !=  nil  {
153+ 		return  s .funcs .Create (ctx , s .client , obj , subResource , opts ... )
181154	}
182155	return  s .client .Create (ctx , obj , subResource , opts ... )
183156}
184157
185158func  (s  subResourceInterceptor ) Update (ctx  context.Context , obj  client.Object , opts  ... client.SubResourceUpdateOption ) error  {
186- 	if  s .fns .Update  !=  nil  {
187- 		return  s .fns .Update (ctx , s .client , obj , opts ... )
159+ 	if  s .funcs .Update  !=  nil  {
160+ 		return  s .funcs .Update (ctx , s .client , obj , opts ... )
188161	}
189162	return  s .client .Update (ctx , obj , opts ... )
190163}
191164
192165func  (s  subResourceInterceptor ) Patch (ctx  context.Context , obj  client.Object , patch  client.Patch , opts  ... client.SubResourcePatchOption ) error  {
193- 	if  s .fns .Patch  !=  nil  {
194- 		return  s .fns .Patch (ctx , s .client , obj , patch , opts ... )
166+ 	if  s .funcs .Patch  !=  nil  {
167+ 		return  s .funcs .Patch (ctx , s .client , obj , patch , opts ... )
195168	}
196169	return  s .client .Patch (ctx , obj , patch , opts ... )
197170}
0 commit comments