Skip to content

Commit d9a14a5

Browse files
committed
Add prefix to avoid argument name conflict with go reserved words "package"
1 parent 0826954 commit d9a14a5

File tree

5 files changed

+70
-70
lines changed

5 files changed

+70
-70
lines changed

cmd/client-gen/generators/fake/generator_fake_for_type.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func (c *Fake$.type|publicPlural$) List(opts $.ListOptions|raw$) (result *$.type
345345
`
346346

347347
var getTemplate = `
348-
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
348+
// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
349349
func (c *Fake$.type|publicPlural$) Get(name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
350350
obj, err := c.Fake.
351351
$if .namespaced$Invokes($.NewGetAction|raw$($.type|allLowercasePlural$Resource, c.ns, name), &$.resultType|raw${})
@@ -358,11 +358,11 @@ func (c *Fake$.type|publicPlural$) Get(name string, options $.GetOptions|raw$) (
358358
`
359359

360360
var getSubresourceTemplate = `
361-
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
362-
func (c *Fake$.type|publicPlural$) Get($.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
361+
// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
362+
func (c *Fake$.type|publicPlural$) Get(_$.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
363363
obj, err := c.Fake.
364-
$if .namespaced$Invokes($.NewGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, "$.subresourcePath$", $.type|private$Name), &$.resultType|raw${})
365-
$else$Invokes($.NewRootGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", $.type|private$Name), &$.resultType|raw${})$end$
364+
$if .namespaced$Invokes($.NewGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, "$.subresourcePath$", _$.type|private$Name), &$.resultType|raw${})
365+
$else$Invokes($.NewRootGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", _$.type|private$Name), &$.resultType|raw${})$end$
366366
if obj == nil {
367367
return nil, err
368368
}
@@ -371,7 +371,7 @@ func (c *Fake$.type|publicPlural$) Get($.type|private$Name string, options $.Get
371371
`
372372

373373
var deleteTemplate = `
374-
// Delete takes name of the $.type|private$ and deletes it. Returns an error if one occurs.
374+
// Delete takes name of the _$.type|private$ and deletes it. Returns an error if one occurs.
375375
func (c *Fake$.type|publicPlural$) Delete(name string, options *$.DeleteOptions|raw$) error {
376376
_, err := c.Fake.
377377
$if .namespaced$Invokes($.NewDeleteAction|raw$($.type|allLowercasePlural$Resource, c.ns, name), &$.type|raw${})
@@ -391,11 +391,11 @@ func (c *Fake$.type|publicPlural$) DeleteCollection(options *$.DeleteOptions|raw
391391
}
392392
`
393393
var createTemplate = `
394-
// 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.
395-
func (c *Fake$.type|publicPlural$) Create($.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
394+
// 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.
395+
func (c *Fake$.type|publicPlural$) Create(_$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
396396
obj, err := c.Fake.
397-
$if .namespaced$Invokes($.NewCreateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, $.inputType|private$), &$.resultType|raw${})
398-
$else$Invokes($.NewRootCreateAction|raw$($.inputType|allLowercasePlural$Resource, $.inputType|private$), &$.resultType|raw${})$end$
397+
$if .namespaced$Invokes($.NewCreateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, _$.inputType|private$), &$.resultType|raw${})
398+
$else$Invokes($.NewRootCreateAction|raw$($.inputType|allLowercasePlural$Resource, _$.inputType|private$), &$.resultType|raw${})$end$
399399
if obj == nil {
400400
return nil, err
401401
}
@@ -404,11 +404,11 @@ func (c *Fake$.type|publicPlural$) Create($.inputType|private$ *$.inputType|raw$
404404
`
405405

406406
var createSubresourceTemplate = `
407-
// 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.
408-
func (c *Fake$.type|publicPlural$) Create($.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
407+
// 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.
408+
func (c *Fake$.type|publicPlural$) Create(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
409409
obj, err := c.Fake.
410-
$if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", c.ns, $.inputType|private$), &$.resultType|raw${})
411-
$else$Invokes($.NewRootCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", $.inputType|private$), &$.resultType|raw${})$end$
410+
$if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, _$.type|private$Name, "$.subresourcePath$", c.ns, _$.inputType|private$), &$.resultType|raw${})
411+
$else$Invokes($.NewRootCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", _$.inputType|private$), &$.resultType|raw${})$end$
412412
if obj == nil {
413413
return nil, err
414414
}
@@ -417,11 +417,11 @@ func (c *Fake$.type|publicPlural$) Create($.type|private$Name string, $.inputTyp
417417
`
418418

419419
var updateTemplate = `
420-
// 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.
421-
func (c *Fake$.type|publicPlural$) Update($.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
420+
// 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.
421+
func (c *Fake$.type|publicPlural$) Update(_$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
422422
obj, err := c.Fake.
423-
$if .namespaced$Invokes($.NewUpdateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, $.inputType|private$), &$.resultType|raw${})
424-
$else$Invokes($.NewRootUpdateAction|raw$($.inputType|allLowercasePlural$Resource, $.inputType|private$), &$.resultType|raw${})$end$
423+
$if .namespaced$Invokes($.NewUpdateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, _$.inputType|private$), &$.resultType|raw${})
424+
$else$Invokes($.NewRootUpdateAction|raw$($.inputType|allLowercasePlural$Resource, _$.inputType|private$), &$.resultType|raw${})$end$
425425
if obj == nil {
426426
return nil, err
427427
}
@@ -430,11 +430,11 @@ func (c *Fake$.type|publicPlural$) Update($.inputType|private$ *$.inputType|raw$
430430
`
431431

432432
var updateSubresourceTemplate = `
433-
// 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.
434-
func (c *Fake$.type|publicPlural$) Update($.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
433+
// 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.
434+
func (c *Fake$.type|publicPlural$) Update(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
435435
obj, err := c.Fake.
436-
$if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", c.ns, $.inputType|private$), &$.inputType|raw${})
437-
$else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", $.inputType|private$), &$.resultType|raw${})$end$
436+
$if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", c.ns, _$.inputType|private$), &$.inputType|raw${})
437+
$else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", _$.inputType|private$), &$.resultType|raw${})$end$
438438
if obj == nil {
439439
return nil, err
440440
}
@@ -445,10 +445,10 @@ func (c *Fake$.type|publicPlural$) Update($.type|private$Name string, $.inputTyp
445445
var updateStatusTemplate = `
446446
// UpdateStatus was generated because the type contains a Status member.
447447
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
448-
func (c *Fake$.type|publicPlural$) UpdateStatus($.type|private$ *$.type|raw$) (*$.type|raw$, error) {
448+
func (c *Fake$.type|publicPlural$) UpdateStatus(_$.type|private$ *$.type|raw$) (*$.type|raw$, error) {
449449
obj, err := c.Fake.
450-
$if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", c.ns, $.type|private$), &$.type|raw${})
451-
$else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", $.type|private$), &$.type|raw${})$end$
450+
$if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", c.ns, _$.type|private$), &$.type|raw${})
451+
$else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", _$.type|private$), &$.type|raw${})$end$
452452
if obj == nil {
453453
return nil, err
454454
}

cmd/client-gen/generators/generator_for_type.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ func generateInterface(tags util.Tags) string {
304304
}
305305

306306
var subresourceDefaultVerbTemplates = map[string]string{
307-
"create": `Create($.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (*$.resultType|raw$, error)`,
308-
"list": `List($.type|private$Name string, opts $.ListOptions|raw$) (*$.resultType|raw$List, error)`,
309-
"update": `Update($.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (*$.resultType|raw$, error)`,
310-
"get": `Get($.type|private$Name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)`,
307+
"create": `Create(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (*$.resultType|raw$, error)`,
308+
"list": `List(_$.type|private$Name string, opts $.ListOptions|raw$) (*$.resultType|raw$List, error)`,
309+
"update": `Update(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (*$.resultType|raw$, error)`,
310+
"get": `Get(_$.type|private$Name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)`,
311311
}
312312

313313
var defaultVerbTemplates = map[string]string{
@@ -405,7 +405,7 @@ func (c *$.type|privatePlural$) List(opts $.ListOptions|raw$) (result *$.resultT
405405

406406
var listSubresourceTemplate = `
407407
// List takes $.type|raw$ name, label and field selectors, and returns the list of $.resultType|publicPlural$ that match those selectors.
408-
func (c *$.type|privatePlural$) List($.type|private$Name string, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) {
408+
func (c *$.type|privatePlural$) List(_$.type|private$Name string, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) {
409409
var timeout time.Duration
410410
if opts.TimeoutSeconds != nil{
411411
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
@@ -414,7 +414,7 @@ func (c *$.type|privatePlural$) List($.type|private$Name string, opts $.ListOpti
414414
err = c.client.Get().
415415
$if .namespaced$Namespace(c.ns).$end$
416416
Resource("$.type|resource$").
417-
Name($.type|private$Name).
417+
Name(_$.type|private$Name).
418418
SubResource("$.subresourcePath$").
419419
VersionedParams(&opts, $.schemeParameterCodec|raw$).
420420
Timeout(timeout).
@@ -425,7 +425,7 @@ func (c *$.type|privatePlural$) List($.type|private$Name string, opts $.ListOpti
425425
`
426426

427427
var getTemplate = `
428-
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
428+
// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any.
429429
func (c *$.type|privatePlural$) Get(name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
430430
result = &$.resultType|raw${}
431431
err = c.client.Get().
@@ -440,13 +440,13 @@ func (c *$.type|privatePlural$) Get(name string, options $.GetOptions|raw$) (res
440440
`
441441

442442
var getSubresourceTemplate = `
443-
// Get takes name of the $.type|private$, and returns the corresponding $.resultType|raw$ object, and an error if there is any.
444-
func (c *$.type|privatePlural$) Get($.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
443+
// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|raw$ object, and an error if there is any.
444+
func (c *$.type|privatePlural$) Get(_$.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
445445
result = &$.resultType|raw${}
446446
err = c.client.Get().
447447
$if .namespaced$Namespace(c.ns).$end$
448448
Resource("$.type|resource$").
449-
Name($.type|private$Name).
449+
Name(_$.type|private$Name).
450450
SubResource("$.subresourcePath$").
451451
VersionedParams(&options, $.schemeParameterCodec|raw$).
452452
Do().
@@ -456,7 +456,7 @@ func (c *$.type|privatePlural$) Get($.type|private$Name string, options $.GetOpt
456456
`
457457

458458
var deleteTemplate = `
459-
// Delete takes name of the $.type|private$ and deletes it. Returns an error if one occurs.
459+
// Delete takes name of the _$.type|private$ and deletes it. Returns an error if one occurs.
460460
func (c *$.type|privatePlural$) Delete(name string, options *$.DeleteOptions|raw$) error {
461461
return c.client.Delete().
462462
$if .namespaced$Namespace(c.ns).$end$
@@ -487,60 +487,60 @@ func (c *$.type|privatePlural$) DeleteCollection(options *$.DeleteOptions|raw$,
487487
`
488488

489489
var createSubresourceTemplate = `
490-
// 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($.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
490+
// 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(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
492492
result = &$.resultType|raw${}
493493
err = c.client.Post().
494494
$if .namespaced$Namespace(c.ns).$end$
495495
Resource("$.type|resource$").
496-
Name($.type|private$Name).
496+
Name(_$.type|private$Name).
497497
SubResource("$.subresourcePath$").
498-
Body($.inputType|private$).
498+
Body(_$.inputType|private$).
499499
Do().
500500
Into(result)
501501
return
502502
}
503503
`
504504

505505
var createTemplate = `
506-
// 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($.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
506+
// 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(_$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
508508
result = &$.resultType|raw${}
509509
err = c.client.Post().
510510
$if .namespaced$Namespace(c.ns).$end$
511511
Resource("$.type|resource$").
512-
Body($.inputType|private$).
512+
Body(_$.inputType|private$).
513513
Do().
514514
Into(result)
515515
return
516516
}
517517
`
518518

519519
var updateSubresourceTemplate = `
520-
// 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($.type|private$Name string, $.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
520+
// 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(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
522522
result = &$.resultType|raw${}
523523
err = c.client.Put().
524524
$if .namespaced$Namespace(c.ns).$end$
525525
Resource("$.type|resource$").
526-
Name($.type|private$Name).
526+
Name(_$.type|private$Name).
527527
SubResource("$.subresourcePath$").
528-
Body($.inputType|private$).
528+
Body(_$.inputType|private$).
529529
Do().
530530
Into(result)
531531
return
532532
}
533533
`
534534

535535
var updateTemplate = `
536-
// 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($.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
536+
// 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(_$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) {
538538
result = &$.resultType|raw${}
539539
err = c.client.Put().
540540
$if .namespaced$Namespace(c.ns).$end$
541541
Resource("$.type|resource$").
542-
Name($.inputType|private$.Name).
543-
Body($.inputType|private$).
542+
Name(_$.inputType|private$.Name).
543+
Body(_$.inputType|private$).
544544
Do().
545545
Into(result)
546546
return
@@ -551,14 +551,14 @@ var updateStatusTemplate = `
551551
// UpdateStatus was generated because the type contains a Status member.
552552
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
553553
554-
func (c *$.type|privatePlural$) UpdateStatus($.type|private$ *$.type|raw$) (result *$.type|raw$, err error) {
554+
func (c *$.type|privatePlural$) UpdateStatus(_$.type|private$ *$.type|raw$) (result *$.type|raw$, err error) {
555555
result = &$.type|raw${}
556556
err = c.client.Put().
557557
$if .namespaced$Namespace(c.ns).$end$
558558
Resource("$.type|resource$").
559-
Name($.type|private$.Name).
559+
Name(_$.type|private$.Name).
560560
SubResource("status").
561-
Body($.type|private$).
561+
Body(_$.type|private$).
562562
Do().
563563
Into(result)
564564
return

cmd/informer-gen/generators/informer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ type $.type|public$Informer interface {
124124
`
125125

126126
var typeInformerStruct = `
127-
type $.type|private$Informer struct {
127+
type _$.type|private$Informer struct {
128128
factory $.interfacesSharedInformerFactory|raw$
129129
tweakListOptions $.interfacesTweakListOptionsFunc|raw$
130130
$if .namespaced$namespace string$end$
@@ -168,19 +168,19 @@ func NewFiltered$.type|public$Informer(client $.clientSetInterface|raw$$if .name
168168
`
169169

170170
var typeInformerConstructor = `
171-
func (f *$.type|private$Informer) defaultInformer(client $.clientSetInterface|raw$, resyncPeriod $.timeDuration|raw$) $.cacheSharedIndexInformer|raw$ {
171+
func (f *_$.type|private$Informer) defaultInformer(client $.clientSetInterface|raw$, resyncPeriod $.timeDuration|raw$) $.cacheSharedIndexInformer|raw$ {
172172
return NewFiltered$.type|public$Informer(client$if .namespaced$, f.namespace$end$, resyncPeriod, $.cacheIndexers|raw${$.cacheNamespaceIndex|raw$: $.cacheMetaNamespaceIndexFunc|raw$}, f.tweakListOptions)
173173
}
174174
`
175175

176176
var typeInformerInformer = `
177-
func (f *$.type|private$Informer) Informer() $.cacheSharedIndexInformer|raw$ {
177+
func (f *_$.type|private$Informer) Informer() $.cacheSharedIndexInformer|raw$ {
178178
return f.factory.$.informerFor$(&$.type|raw${}, f.defaultInformer)
179179
}
180180
`
181181

182182
var typeInformerLister = `
183-
func (f *$.type|private$Informer) Lister() $.lister|raw$ {
183+
func (f *_$.type|private$Informer) Lister() $.lister|raw$ {
184184
return $.newLister|raw$(f.Informer().GetIndexer())
185185
}
186186
`

cmd/informer-gen/generators/versioninterface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ func New(f $.interfacesSharedInformerFactory|raw$, namespace string, tweakListOp
104104
var versionFuncTemplate = `
105105
// $.type|publicPlural$ returns a $.type|public$Informer.
106106
func (v *version) $.type|publicPlural$() $.type|public$Informer {
107-
return &$.type|private$Informer{factory: v.factory$if .namespaced$, namespace: v.namespace$end$, tweakListOptions: v.tweakListOptions}
107+
return &_$.type|private$Informer{factory: v.factory$if .namespaced$, namespace: v.namespace$end$, tweakListOptions: v.tweakListOptions}
108108
}
109109
`

0 commit comments

Comments
 (0)