@@ -43,7 +43,9 @@ type genClientForType struct {
43
43
var _ generator.Generator = & genClientForType {}
44
44
45
45
// Filter ignores all but one type because we're making a single file per type.
46
- func (g * genClientForType ) Filter (c * generator.Context , t * types.Type ) bool { return t == g .typeToMatch }
46
+ func (g * genClientForType ) Filter (c * generator.Context , t * types.Type ) bool {
47
+ return t == g .typeToMatch
48
+ }
47
49
48
50
func (g * genClientForType ) Namers (c * generator.Context ) namer.NameSystems {
49
51
return namer.NameSystems {
@@ -116,9 +118,10 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
116
118
"type" : t ,
117
119
"inputType" : & inputType ,
118
120
"resultType" : & resultType ,
119
- "DeleteOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "DeleteOptions" }),
120
- "ListOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "ListOptions" }),
121
+ "CreateOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "CreateOptions" }),
121
122
"GetOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "GetOptions" }),
123
+ "ListOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "ListOptions" }),
124
+ "UpdateOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "UpdateOptions" }),
122
125
"PatchType" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/types" , Name : "PatchType" }),
123
126
},
124
127
})
@@ -135,9 +138,12 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
135
138
"subresourcePath" : "" ,
136
139
"GroupGoName" : g .groupGoName ,
137
140
"Version" : namer .IC (g .version ),
141
+ "CreateOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "CreateOptions" }),
138
142
"DeleteOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "DeleteOptions" }),
139
- "ListOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "ListOptions" }),
140
143
"GetOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "GetOptions" }),
144
+ "ListOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "ListOptions" }),
145
+ "PatchOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "PatchOptions" }),
146
+ "UpdateOptions" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/apis/meta/v1" , Name : "UpdateOptions" }),
141
147
"PatchType" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/types" , Name : "PatchType" }),
142
148
"watchInterface" : c .Universe .Type (types.Name {Package : "k8s.io/apimachinery/pkg/watch" , Name : "Interface" }),
143
149
"RESTClientInterface" : c .Universe .Type (types.Name {Package : "k8s.io/client-go/rest" , Name : "Interface" }),
@@ -304,22 +310,22 @@ func generateInterface(tags util.Tags) string {
304
310
}
305
311
306
312
var subresourceDefaultVerbTemplates = map [string ]string {
307
- "create" : `Create(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (*$.resultType|raw$, error)` ,
313
+ "create" : `Create(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$ ) (*$.resultType|raw$, error)` ,
308
314
"list" : `List(ctx context.Context, $.type|private$Name string, opts $.ListOptions|raw$) (*$.resultType|raw$List, error)` ,
309
- "update" : `Update(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (*$.resultType|raw$, error)` ,
315
+ "update" : `Update(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$ ) (*$.resultType|raw$, error)` ,
310
316
"get" : `Get(ctx context.Context, $.type|private$Name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)` ,
311
317
}
312
318
313
319
var defaultVerbTemplates = map [string ]string {
314
- "create" : `Create(context.Context, *$.inputType|raw$) (*$.resultType|raw$, error)` ,
315
- "update" : `Update(context.Context, *$.inputType|raw$) (*$.resultType|raw$, error)` ,
316
- "updateStatus" : `UpdateStatus(context.Context, *$.type|raw$) (*$.type|raw$, error)` ,
317
- "delete" : `Delete(ctx context.Context, name string, options *$.DeleteOptions|raw$) error` ,
318
- "deleteCollection" : `DeleteCollection(ctx context.Context, options *$.DeleteOptions|raw$, listOptions $.ListOptions|raw$) error` ,
319
- "get" : `Get(ctx context.Context, name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)` ,
320
+ "create" : `Create(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions |raw$) (*$.resultType|raw$, error)` ,
321
+ "update" : `Update(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions |raw$) (*$.resultType|raw$, error)` ,
322
+ "updateStatus" : `UpdateStatus(ctx context.Context, $.inputType|private$ *$.type|raw$, opts $.UpdateOptions |raw$) (*$.type|raw$, error)` ,
323
+ "delete" : `Delete(ctx context.Context, name string, opts *$.DeleteOptions|raw$) error` ,
324
+ "deleteCollection" : `DeleteCollection(ctx context.Context, opts *$.DeleteOptions|raw$, listOpts $.ListOptions|raw$) error` ,
325
+ "get" : `Get(ctx context.Context, name string, opts $.GetOptions|raw$) (*$.resultType|raw$, error)` ,
320
326
"list" : `List(ctx context.Context, opts $.ListOptions|raw$) (*$.resultType|raw$List, error)` ,
321
327
"watch" : `Watch(ctx context.Context, opts $.ListOptions|raw$) ($.watchInterface|raw$, error)` ,
322
- "patch" : `Patch(ctx context.Context, name string, pt $.PatchType|raw$, data []byte, subresources ...string) (result *$.resultType|raw$, err error)` ,
328
+ "patch" : `Patch(ctx context.Context, name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error)` ,
323
329
}
324
330
325
331
// group client will implement this interface.
@@ -488,13 +494,14 @@ func (c *$.type|privatePlural$) DeleteCollection(ctx context.Context, options *$
488
494
489
495
var createSubresourceTemplate = `
490
496
// 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.
491
- func (c *$.type|privatePlural$) Create(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
497
+ func (c *$.type|privatePlural$) Create(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$ ) (result *$.resultType|raw$, err error) {
492
498
result = &$.resultType|raw${}
493
499
err = c.client.Post().
494
500
$if .namespaced$Namespace(c.ns).$end$
495
501
Resource("$.type|resource$").
496
502
Name($.type|private$Name).
497
503
SubResource("$.subresourcePath$").
504
+ VersionedParams(&opts, $.schemeParameterCodec|raw$).
498
505
Body($.inputType|private$).
499
506
Do(ctx).
500
507
Into(result)
@@ -504,11 +511,12 @@ func (c *$.type|privatePlural$) Create(ctx context.Context, $.type|private$Name
504
511
505
512
var createTemplate = `
506
513
// 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.
507
- func (c *$.type|privatePlural$) Create(ctx context.Context, $.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
514
+ func (c *$.type|privatePlural$) Create(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$ ) (result *$.resultType|raw$, err error) {
508
515
result = &$.resultType|raw${}
509
516
err = c.client.Post().
510
517
$if .namespaced$Namespace(c.ns).$end$
511
518
Resource("$.type|resource$").
519
+ VersionedParams(&opts, $.schemeParameterCodec|raw$).
512
520
Body($.inputType|private$).
513
521
Do(ctx).
514
522
Into(result)
@@ -518,13 +526,14 @@ func (c *$.type|privatePlural$) Create(ctx context.Context, $.inputType|private$
518
526
519
527
var updateSubresourceTemplate = `
520
528
// Update takes the top resource name and 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.
521
- func (c *$.type|privatePlural$) Update(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
529
+ func (c *$.type|privatePlural$) Update(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$ ) (result *$.resultType|raw$, err error) {
522
530
result = &$.resultType|raw${}
523
531
err = c.client.Put().
524
532
$if .namespaced$Namespace(c.ns).$end$
525
533
Resource("$.type|resource$").
526
534
Name($.type|private$Name).
527
535
SubResource("$.subresourcePath$").
536
+ VersionedParams(&opts, $.schemeParameterCodec|raw$).
528
537
Body($.inputType|private$).
529
538
Do(ctx).
530
539
Into(result)
@@ -534,12 +543,13 @@ func (c *$.type|privatePlural$) Update(ctx context.Context, $.type|private$Name
534
543
535
544
var updateTemplate = `
536
545
// 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.
537
- func (c *$.type|privatePlural$) Update(ctx context.Context, $.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
546
+ func (c *$.type|privatePlural$) Update(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$ ) (result *$.resultType|raw$, err error) {
538
547
result = &$.resultType|raw${}
539
548
err = c.client.Put().
540
549
$if .namespaced$Namespace(c.ns).$end$
541
550
Resource("$.type|resource$").
542
551
Name($.inputType|private$.Name).
552
+ VersionedParams(&opts, $.schemeParameterCodec|raw$).
543
553
Body($.inputType|private$).
544
554
Do(ctx).
545
555
Into(result)
@@ -550,14 +560,14 @@ func (c *$.type|privatePlural$) Update(ctx context.Context, $.inputType|private$
550
560
var updateStatusTemplate = `
551
561
// UpdateStatus was generated because the type contains a Status member.
552
562
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
553
-
554
- func (c *$.type|privatePlural$) UpdateStatus(ctx context.Context, $.type|private$ *$.type|raw$) (result *$.type|raw$, err error) {
563
+ func (c *$.type|privatePlural$) UpdateStatus(ctx context.Context, $.type|private$ *$.type|raw$, opts $.UpdateOptions|raw$) (result *$.type|raw$, err error) {
555
564
result = &$.type|raw${}
556
565
err = c.client.Put().
557
566
$if .namespaced$Namespace(c.ns).$end$
558
567
Resource("$.type|resource$").
559
568
Name($.type|private$.Name).
560
569
SubResource("status").
570
+ VersionedParams(&opts, $.schemeParameterCodec|raw$).
561
571
Body($.type|private$).
562
572
Do(ctx).
563
573
Into(result)
@@ -584,13 +594,14 @@ func (c *$.type|privatePlural$) Watch(ctx context.Context, opts $.ListOptions|ra
584
594
585
595
var patchTemplate = `
586
596
// Patch applies the patch and returns the patched $.resultType|private$.
587
- func (c *$.type|privatePlural$) Patch(ctx context.Context, name string, pt $.PatchType|raw$, data []byte, subresources ...string) (result *$.resultType|raw$, err error) {
597
+ func (c *$.type|privatePlural$) Patch(ctx context.Context, name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error) {
588
598
result = &$.resultType|raw${}
589
599
err = c.client.Patch(pt).
590
600
$if .namespaced$Namespace(c.ns).$end$
591
601
Resource("$.type|resource$").
592
- SubResource(subresources...).
593
602
Name(name).
603
+ SubResource(subresources...).
604
+ VersionedParams(&opts, $.schemeParameterCodec|raw$).
594
605
Body(data).
595
606
Do(ctx).
596
607
Into(result)
0 commit comments