@@ -172,6 +172,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
172
172
"RESTClientInterface" : c .Universe .Type (types.Name {Package : "k8s.io/client-go/rest" , Name : "Interface" }),
173
173
"schemeParameterCodec" : c .Universe .Variable (types.Name {Package : path .Join (g .clientsetPackage , "scheme" ), Name : "ParameterCodec" }),
174
174
"jsonMarshal" : c .Universe .Type (types.Name {Package : "encoding/json" , Name : "Marshal" }),
175
+ "CheckListFromCacheDataConsistencyIfRequested" : c .Universe .Function (types.Name {Package : "k8s.io/client-go/util/consistencydetector" , Name : "CheckListFromCacheDataConsistencyIfRequested" }),
175
176
}
176
177
177
178
if generateApply {
@@ -223,6 +224,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
223
224
}
224
225
if tags .HasVerb ("list" ) {
225
226
sw .Do (listTemplate , m )
227
+ sw .Do (privateListTemplate , m )
226
228
}
227
229
if tags .HasVerb ("watch" ) {
228
230
sw .Do (watchTemplate , m )
@@ -298,6 +300,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
298
300
sw .Do (adjustTemplate (e .VerbName , e .VerbType , listSubresourceTemplate ), m )
299
301
} else {
300
302
sw .Do (adjustTemplate (e .VerbName , e .VerbType , listTemplate ), m )
303
+ sw .Do (adjustTemplate (e .VerbName , e .VerbType , privateListTemplate ), m )
301
304
}
302
305
}
303
306
@@ -459,6 +462,18 @@ func new$.type|publicPlural$(c *$.GroupGoName$$.Version$Client) *$.type|privateP
459
462
var listTemplate = `
460
463
// List takes label and field selectors, and returns the list of $.resultType|publicPlural$ that match those selectors.
461
464
func (c *$.type|privatePlural$) List(ctx context.Context, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) {
465
+ defer func() {
466
+ if err == nil {
467
+ $.CheckListFromCacheDataConsistencyIfRequested|raw$(ctx, "list request for $.type|resource$", c.list, opts, result)
468
+ }
469
+ }()
470
+ return c.list(ctx, opts)
471
+ }
472
+ `
473
+
474
+ var privateListTemplate = `
475
+ // list takes label and field selectors, and returns the list of $.resultType|publicPlural$ that match those selectors.
476
+ func (c *$.type|privatePlural$) list(ctx context.Context, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) {
462
477
var timeout time.Duration
463
478
if opts.TimeoutSeconds != nil{
464
479
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
0 commit comments