@@ -123,6 +123,8 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
123
123
"ApplyPatchType" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/types" , Name : "ApplyPatchType" }),
124
124
"watchInterface" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/watch" , Name : "Interface" }),
125
125
"jsonMarshal" : c .Universe .Type (types.Name {Package : "encoding/json" , Name : "Marshal" }),
126
+ "fmtErrorf" : c .Universe .Type (types.Name {Package : "fmt" , Name : "Errorf" }),
127
+ "contextContext" : c .Universe .Type (types.Name {Package : "context" , Name : "Context" }),
126
128
127
129
"NewRootListActionWithOptions" : c .Universe .Function (types.Name {Package : pkgClientGoTesting , Name : "NewRootListActionWithOptions" }),
128
130
"NewListActionWithOptions" : c .Universe .Function (types.Name {Package : pkgClientGoTesting , Name : "NewListActionWithOptions" }),
@@ -332,7 +334,7 @@ var $.type|allLowercasePlural$Kind = $.SchemeGroupVersion|raw$.WithKind("$.type|
332
334
333
335
var listTemplate = `
334
336
// List takes label and field selectors, and returns the list of $.type|publicPlural$ that match those selectors.
335
- func (c *Fake$.type|publicPlural$) List(ctx context.Context , opts $.ListOptions|raw$) (result *$.type|raw$List, err error) {
337
+ func (c *Fake$.type|publicPlural$) List(ctx $.contextContext|raw$ , opts $.ListOptions|raw$) (result *$.type|raw$List, err error) {
336
338
emptyResult := &$.type|raw$List{}
337
339
obj, err := c.Fake.
338
340
$if .namespaced$Invokes($.NewListActionWithOptions|raw$($.type|allLowercasePlural$Resource, $.type|allLowercasePlural$Kind, c.ns, opts), emptyResult)
@@ -346,7 +348,7 @@ func (c *Fake$.type|publicPlural$) List(ctx context.Context, opts $.ListOptions|
346
348
347
349
var listUsingOptionsTemplate = `
348
350
// List takes label and field selectors, and returns the list of $.type|publicPlural$ that match those selectors.
349
- func (c *Fake$.type|publicPlural$) List(ctx context.Context , opts $.ListOptions|raw$) (result *$.type|raw$List, err error) {
351
+ func (c *Fake$.type|publicPlural$) List(ctx $.contextContext|raw$ , opts $.ListOptions|raw$) (result *$.type|raw$List, err error) {
350
352
emptyResult := &$.type|raw$List{}
351
353
obj, err := c.Fake.
352
354
$if .namespaced$Invokes($.NewListActionWithOptions|raw$($.type|allLowercasePlural$Resource, $.type|allLowercasePlural$Kind, c.ns, opts), emptyResult)
@@ -371,7 +373,7 @@ func (c *Fake$.type|publicPlural$) List(ctx context.Context, opts $.ListOptions|
371
373
372
374
var getTemplate = `
373
375
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
374
- func (c *Fake$.type|publicPlural$) Get(ctx context.Context , name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
376
+ func (c *Fake$.type|publicPlural$) Get(ctx $.contextContext|raw$ , name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
375
377
emptyResult := &$.resultType|raw${}
376
378
obj, err := c.Fake.
377
379
$if .namespaced$Invokes($.NewGetActionWithOptions|raw$($.type|allLowercasePlural$Resource, c.ns, name, options), emptyResult)
@@ -385,7 +387,7 @@ func (c *Fake$.type|publicPlural$) Get(ctx context.Context, name string, options
385
387
386
388
var getSubresourceTemplate = `
387
389
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
388
- func (c *Fake$.type|publicPlural$) Get(ctx context.Context , $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
390
+ func (c *Fake$.type|publicPlural$) Get(ctx $.contextContext|raw$ , $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
389
391
emptyResult := &$.resultType|raw${}
390
392
obj, err := c.Fake.
391
393
$if .namespaced$Invokes($.NewGetSubresourceActionWithOptions|raw$($.type|allLowercasePlural$Resource, c.ns, "$.subresourcePath$", $.type|private$Name, options), emptyResult)
@@ -399,7 +401,7 @@ func (c *Fake$.type|publicPlural$) Get(ctx context.Context, $.type|private$Name
399
401
400
402
var deleteTemplate = `
401
403
// Delete takes name of the $.type|private$ and deletes it. Returns an error if one occurs.
402
- func (c *Fake$.type|publicPlural$) Delete(ctx context.Context , name string, opts $.DeleteOptions|raw$) error {
404
+ func (c *Fake$.type|publicPlural$) Delete(ctx $.contextContext|raw$ , name string, opts $.DeleteOptions|raw$) error {
403
405
_, err := c.Fake.
404
406
$if .namespaced$Invokes($.NewDeleteActionWithOptions|raw$($.type|allLowercasePlural$Resource, c.ns, name, opts), &$.type|raw${})
405
407
$else$Invokes($.NewRootDeleteActionWithOptions|raw$($.type|allLowercasePlural$Resource, name, opts), &$.type|raw${})$end$
@@ -409,7 +411,7 @@ func (c *Fake$.type|publicPlural$) Delete(ctx context.Context, name string, opts
409
411
410
412
var deleteCollectionTemplate = `
411
413
// DeleteCollection deletes a collection of objects.
412
- func (c *Fake$.type|publicPlural$) DeleteCollection(ctx context.Context , opts $.DeleteOptions|raw$, listOpts $.ListOptions|raw$) error {
414
+ func (c *Fake$.type|publicPlural$) DeleteCollection(ctx $.contextContext|raw$ , opts $.DeleteOptions|raw$, listOpts $.ListOptions|raw$) error {
413
415
$if .namespaced$action := $.NewDeleteCollectionActionWithOptions|raw$($.type|allLowercasePlural$Resource, c.ns, opts, listOpts)
414
416
$else$action := $.NewRootDeleteCollectionActionWithOptions|raw$($.type|allLowercasePlural$Resource, opts, listOpts)
415
417
$end$
@@ -419,7 +421,7 @@ func (c *Fake$.type|publicPlural$) DeleteCollection(ctx context.Context, opts $.
419
421
`
420
422
var createTemplate = `
421
423
// Create takes the representation of a $.inputType|private$ and creates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
422
- func (c *Fake$.type|publicPlural$) Create(ctx context.Context , $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
424
+ func (c *Fake$.type|publicPlural$) Create(ctx $.contextContext|raw$ , $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
423
425
emptyResult := &$.resultType|raw${}
424
426
obj, err := c.Fake.
425
427
$if .namespaced$Invokes($.NewCreateActionWithOptions|raw$($.inputType|allLowercasePlural$Resource, c.ns, $.inputType|private$, opts), emptyResult)
@@ -433,7 +435,7 @@ func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.inputType|priva
433
435
434
436
var createSubresourceTemplate = `
435
437
// Create takes the representation of a $.inputType|private$ and creates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
436
- func (c *Fake$.type|publicPlural$) Create(ctx context.Context , $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
438
+ func (c *Fake$.type|publicPlural$) Create(ctx $.contextContext|raw$ , $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
437
439
emptyResult := &$.resultType|raw${}
438
440
obj, err := c.Fake.
439
441
$if .namespaced$Invokes($.NewCreateSubresourceActionWithOptions|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", c.ns, $.inputType|private$, opts), emptyResult)
@@ -447,7 +449,7 @@ func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.type|private$Na
447
449
448
450
var updateTemplate = `
449
451
// Update takes the representation of a $.inputType|private$ and updates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
450
- func (c *Fake$.type|publicPlural$) Update(ctx context.Context , $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
452
+ func (c *Fake$.type|publicPlural$) Update(ctx $.contextContext|raw$ , $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
451
453
emptyResult := &$.resultType|raw${}
452
454
obj, err := c.Fake.
453
455
$if .namespaced$Invokes($.NewUpdateActionWithOptions|raw$($.inputType|allLowercasePlural$Resource, c.ns, $.inputType|private$, opts), emptyResult)
@@ -461,7 +463,7 @@ func (c *Fake$.type|publicPlural$) Update(ctx context.Context, $.inputType|priva
461
463
462
464
var updateSubresourceTemplate = `
463
465
// Update takes the representation of a $.inputType|private$ and updates it. Returns the server's representation of the $.resultType|private$, and an error, if there is any.
464
- func (c *Fake$.type|publicPlural$) Update(ctx context.Context , $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
466
+ func (c *Fake$.type|publicPlural$) Update(ctx $.contextContext|raw$ , $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
465
467
emptyResult := &$.resultType|raw${}
466
468
obj, err := c.Fake.
467
469
$if .namespaced$Invokes($.NewUpdateSubresourceActionWithOptions|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", c.ns, $.inputType|private$, opts), &$.inputType|raw${})
@@ -476,7 +478,7 @@ func (c *Fake$.type|publicPlural$) Update(ctx context.Context, $.type|private$Na
476
478
var updateStatusTemplate = `
477
479
// UpdateStatus was generated because the type contains a Status member.
478
480
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
479
- func (c *Fake$.type|publicPlural$) UpdateStatus(ctx context.Context , $.type|private$ *$.type|raw$, opts $.UpdateOptions|raw$) (result *$.type|raw$, err error) {
481
+ func (c *Fake$.type|publicPlural$) UpdateStatus(ctx $.contextContext|raw$ , $.type|private$ *$.type|raw$, opts $.UpdateOptions|raw$) (result *$.type|raw$, err error) {
480
482
emptyResult := &$.type|raw${}
481
483
obj, err := c.Fake.
482
484
$if .namespaced$Invokes($.NewUpdateSubresourceActionWithOptions|raw$($.type|allLowercasePlural$Resource, "status", c.ns, $.type|private$, opts), emptyResult)
@@ -490,7 +492,7 @@ func (c *Fake$.type|publicPlural$) UpdateStatus(ctx context.Context, $.type|priv
490
492
491
493
var watchTemplate = `
492
494
// Watch returns a $.watchInterface|raw$ that watches the requested $.type|privatePlural$.
493
- func (c *Fake$.type|publicPlural$) Watch(ctx context.Context , opts $.ListOptions|raw$) ($.watchInterface|raw$, error) {
495
+ func (c *Fake$.type|publicPlural$) Watch(ctx $.contextContext|raw$ , opts $.ListOptions|raw$) ($.watchInterface|raw$, error) {
494
496
return c.Fake.
495
497
$if .namespaced$InvokesWatch($.NewWatchActionWithOptions|raw$($.type|allLowercasePlural$Resource, c.ns, opts))
496
498
$else$InvokesWatch($.NewRootWatchActionWithOptions|raw$($.type|allLowercasePlural$Resource, opts))$end$
@@ -499,7 +501,7 @@ func (c *Fake$.type|publicPlural$) Watch(ctx context.Context, opts $.ListOptions
499
501
500
502
var patchTemplate = `
501
503
// Patch applies the patch and returns the patched $.resultType|private$.
502
- func (c *Fake$.type|publicPlural$) Patch(ctx context.Context , name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error) {
504
+ func (c *Fake$.type|publicPlural$) Patch(ctx $.contextContext|raw$ , name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error) {
503
505
emptyResult := &$.resultType|raw${}
504
506
obj, err := c.Fake.
505
507
$if .namespaced$Invokes($.NewPatchSubresourceActionWithOptions|raw$($.type|allLowercasePlural$Resource, c.ns, name, pt, data, opts, subresources... ), emptyResult)
@@ -513,17 +515,17 @@ func (c *Fake$.type|publicPlural$) Patch(ctx context.Context, name string, pt $.
513
515
514
516
var applyTemplate = `
515
517
// Apply takes the given apply declarative configuration, applies it and returns the applied $.resultType|private$.
516
- func (c *Fake$.type|publicPlural$) Apply(ctx context.Context , $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
518
+ func (c *Fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$ , $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
517
519
if $.inputType|private$ == nil {
518
- return nil, fmt.Errorf ("$.inputType|private$ provided to Apply must not be nil")
520
+ return nil, $.fmtErrorf|raw$ ("$.inputType|private$ provided to Apply must not be nil")
519
521
}
520
522
data, err := $.jsonMarshal|raw$($.inputType|private$)
521
523
if err != nil {
522
524
return nil, err
523
525
}
524
526
name := $.inputType|private$.Name
525
527
if name == nil {
526
- return nil, fmt.Errorf ("$.inputType|private$.Name must be provided to Apply")
528
+ return nil, $.fmtErrorf|raw$ ("$.inputType|private$.Name must be provided to Apply")
527
529
}
528
530
emptyResult := &$.resultType|raw${}
529
531
obj, err := c.Fake.
@@ -539,17 +541,17 @@ func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, $.inputType|privat
539
541
var applyStatusTemplate = `
540
542
// ApplyStatus was generated because the type contains a Status member.
541
543
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
542
- func (c *Fake$.type|publicPlural$) ApplyStatus(ctx context.Context , $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
544
+ func (c *Fake$.type|publicPlural$) ApplyStatus(ctx $.contextContext|raw$ , $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
543
545
if $.inputType|private$ == nil {
544
- return nil, fmt.Errorf ("$.inputType|private$ provided to Apply must not be nil")
546
+ return nil, $.fmtErrorf|raw$ ("$.inputType|private$ provided to Apply must not be nil")
545
547
}
546
548
data, err := $.jsonMarshal|raw$($.inputType|private$)
547
549
if err != nil {
548
550
return nil, err
549
551
}
550
552
name := $.inputType|private$.Name
551
553
if name == nil {
552
- return nil, fmt.Errorf ("$.inputType|private$.Name must be provided to Apply")
554
+ return nil, $.fmtErrorf|raw$ ("$.inputType|private$.Name must be provided to Apply")
553
555
}
554
556
emptyResult := &$.resultType|raw${}
555
557
obj, err := c.Fake.
@@ -565,9 +567,9 @@ func (c *Fake$.type|publicPlural$) ApplyStatus(ctx context.Context, $.inputType|
565
567
var applySubresourceTemplate = `
566
568
// Apply takes top resource name and the apply declarative configuration for $.subresourcePath$,
567
569
// applies it and returns the applied $.resultType|private$, and an error, if there is any.
568
- func (c *Fake$.type|publicPlural$) Apply(ctx context.Context , $.type|private$Name string, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
570
+ func (c *Fake$.type|publicPlural$) Apply(ctx $.contextContext|raw$ , $.type|private$Name string, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
569
571
if $.inputType|private$ == nil {
570
- return nil, fmt.Errorf ("$.inputType|private$ provided to Apply must not be nil")
572
+ return nil, $.fmtErrorf|raw$ ("$.inputType|private$ provided to Apply must not be nil")
571
573
}
572
574
data, err := $.jsonMarshal|raw$($.inputType|private$)
573
575
if err != nil {
0 commit comments