From 334504cec5ec2e5c3d5c9c2b56fcea774c1fd1fe Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Wed, 15 Jan 2020 16:25:40 +0800 Subject: [PATCH] Add prefix to avoid argument name conflict with go reserved words "package" --- .../fake/generator_fake_for_type.go | 54 ++++++------ .../generators/generator_for_type.go | 88 +++++++++++++++++-- cmd/informer-gen/generators/informer.go | 8 +- .../generators/versioninterface.go | 2 +- cmd/lister-gen/generators/lister.go | 22 ++--- 5 files changed, 122 insertions(+), 52 deletions(-) diff --git a/cmd/client-gen/generators/fake/generator_fake_for_type.go b/cmd/client-gen/generators/fake/generator_fake_for_type.go index 9efe024f..e765ab49 100644 --- a/cmd/client-gen/generators/fake/generator_fake_for_type.go +++ b/cmd/client-gen/generators/fake/generator_fake_for_type.go @@ -348,8 +348,8 @@ func (c *Fake$.type|publicPlural$) List(ctx context.Context, opts $.ListOptions| ` var getTemplate = ` -// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. -func (c *Fake$.type|publicPlural$) Get(ctx context.Context, name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { +// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. +func (c *Fake$.type|publicPlural$) Get(name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { obj, err := c.Fake. $if .namespaced$Invokes($.NewGetAction|raw$($.type|allLowercasePlural$Resource, c.ns, name), &$.resultType|raw${}) $else$Invokes($.NewRootGetAction|raw$($.type|allLowercasePlural$Resource, name), &$.resultType|raw${})$end$ @@ -361,11 +361,11 @@ func (c *Fake$.type|publicPlural$) Get(ctx context.Context, name string, options ` var getSubresourceTemplate = ` -// Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. -func (c *Fake$.type|publicPlural$) Get(ctx context.Context, $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { +// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. +func (c *Fake$.type|publicPlural$) Get(_$.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { obj, err := c.Fake. - $if .namespaced$Invokes($.NewGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, "$.subresourcePath$", $.type|private$Name), &$.resultType|raw${}) - $else$Invokes($.NewRootGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", $.type|private$Name), &$.resultType|raw${})$end$ + $if .namespaced$Invokes($.NewGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, "$.subresourcePath$", _$.type|private$Name), &$.resultType|raw${}) + $else$Invokes($.NewRootGetSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", _$.type|private$Name), &$.resultType|raw${})$end$ if obj == nil { return nil, err } @@ -374,8 +374,8 @@ func (c *Fake$.type|publicPlural$) Get(ctx context.Context, $.type|private$Name ` var deleteTemplate = ` -// Delete takes name of the $.type|private$ and deletes it. Returns an error if one occurs. -func (c *Fake$.type|publicPlural$) Delete(ctx context.Context, name string, opts $.DeleteOptions|raw$) error { +// Delete takes name of the _$.type|private$ and deletes it. Returns an error if one occurs. +func (c *Fake$.type|publicPlural$) Delete(name string, options *$.DeleteOptions|raw$) error { _, err := c.Fake. $if .namespaced$Invokes($.NewDeleteAction|raw$($.type|allLowercasePlural$Resource, c.ns, name), &$.type|raw${}) $else$Invokes($.NewRootDeleteAction|raw$($.type|allLowercasePlural$Resource, name), &$.type|raw${})$end$ @@ -394,11 +394,11 @@ func (c *Fake$.type|publicPlural$) DeleteCollection(ctx context.Context, opts $. } ` var createTemplate = ` -// 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. -func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) { +// 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. +func (c *Fake$.type|publicPlural$) Create(_$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) { obj, err := c.Fake. - $if .namespaced$Invokes($.NewCreateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, $.inputType|private$), &$.resultType|raw${}) - $else$Invokes($.NewRootCreateAction|raw$($.inputType|allLowercasePlural$Resource, $.inputType|private$), &$.resultType|raw${})$end$ + $if .namespaced$Invokes($.NewCreateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, _$.inputType|private$), &$.resultType|raw${}) + $else$Invokes($.NewRootCreateAction|raw$($.inputType|allLowercasePlural$Resource, _$.inputType|private$), &$.resultType|raw${})$end$ if obj == nil { return nil, err } @@ -407,11 +407,11 @@ func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.inputType|priva ` var createSubresourceTemplate = ` -// 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. -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) { +// 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. +func (c *Fake$.type|publicPlural$) Create(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) { obj, err := c.Fake. - $if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", c.ns, $.inputType|private$), &$.resultType|raw${}) - $else$Invokes($.NewRootCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, "$.subresourcePath$", $.inputType|private$), &$.resultType|raw${})$end$ + $if .namespaced$Invokes($.NewCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, _$.type|private$Name, "$.subresourcePath$", c.ns, _$.inputType|private$), &$.resultType|raw${}) + $else$Invokes($.NewRootCreateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", _$.inputType|private$), &$.resultType|raw${})$end$ if obj == nil { return nil, err } @@ -420,11 +420,11 @@ func (c *Fake$.type|publicPlural$) Create(ctx context.Context, $.type|private$Na ` var updateTemplate = ` -// 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. -func (c *Fake$.type|publicPlural$) Update(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) { +// 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. +func (c *Fake$.type|publicPlural$) Update(_$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) { obj, err := c.Fake. - $if .namespaced$Invokes($.NewUpdateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, $.inputType|private$), &$.resultType|raw${}) - $else$Invokes($.NewRootUpdateAction|raw$($.inputType|allLowercasePlural$Resource, $.inputType|private$), &$.resultType|raw${})$end$ + $if .namespaced$Invokes($.NewUpdateAction|raw$($.inputType|allLowercasePlural$Resource, c.ns, _$.inputType|private$), &$.resultType|raw${}) + $else$Invokes($.NewRootUpdateAction|raw$($.inputType|allLowercasePlural$Resource, _$.inputType|private$), &$.resultType|raw${})$end$ if obj == nil { return nil, err } @@ -433,11 +433,11 @@ func (c *Fake$.type|publicPlural$) Update(ctx context.Context, $.inputType|priva ` var updateSubresourceTemplate = ` -// 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. -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) { +// 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. +func (c *Fake$.type|publicPlural$) Update(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) { obj, err := c.Fake. - $if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", c.ns, $.inputType|private$), &$.inputType|raw${}) - $else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", $.inputType|private$), &$.resultType|raw${})$end$ + $if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", c.ns, _$.inputType|private$), &$.inputType|raw${}) + $else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "$.subresourcePath$", _$.inputType|private$), &$.resultType|raw${})$end$ if obj == nil { return nil, err } @@ -448,10 +448,10 @@ func (c *Fake$.type|publicPlural$) Update(ctx context.Context, $.type|private$Na var updateStatusTemplate = ` // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *Fake$.type|publicPlural$) UpdateStatus(ctx context.Context, $.type|private$ *$.type|raw$, opts $.UpdateOptions|raw$) (*$.type|raw$, error) { +func (c *Fake$.type|publicPlural$) UpdateStatus(_$.type|private$ *$.type|raw$) (*$.type|raw$, error) { obj, err := c.Fake. - $if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", c.ns, $.type|private$), &$.type|raw${}) - $else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", $.type|private$), &$.type|raw${})$end$ + $if .namespaced$Invokes($.NewUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", c.ns, _$.type|private$), &$.type|raw${}) + $else$Invokes($.NewRootUpdateSubresourceAction|raw$($.type|allLowercasePlural$Resource, "status", _$.type|private$), &$.type|raw${})$end$ if obj == nil { return nil, err } diff --git a/cmd/client-gen/generators/generator_for_type.go b/cmd/client-gen/generators/generator_for_type.go index 13664d0d..b224e7f3 100644 --- a/cmd/client-gen/generators/generator_for_type.go +++ b/cmd/client-gen/generators/generator_for_type.go @@ -310,10 +310,10 @@ func generateInterface(tags util.Tags) string { } var subresourceDefaultVerbTemplates = map[string]string{ - "create": `Create(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (*$.resultType|raw$, error)`, - "list": `List(ctx context.Context, $.type|private$Name string, opts $.ListOptions|raw$) (*$.resultType|raw$List, error)`, - "update": `Update(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (*$.resultType|raw$, error)`, - "get": `Get(ctx context.Context, $.type|private$Name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)`, + "create": `Create(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (*$.resultType|raw$, error)`, + "list": `List(_$.type|private$Name string, opts $.ListOptions|raw$) (*$.resultType|raw$List, error)`, + "update": `Update(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (*$.resultType|raw$, error)`, + "get": `Get(_$.type|private$Name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)`, } var defaultVerbTemplates = map[string]string{ @@ -411,7 +411,11 @@ func (c *$.type|privatePlural$) List(ctx context.Context, opts $.ListOptions|raw var listSubresourceTemplate = ` // List takes $.type|raw$ name, label and field selectors, and returns the list of $.resultType|publicPlural$ that match those selectors. +<<<<<<< HEAD func (c *$.type|privatePlural$) List(ctx context.Context, $.type|private$Name string, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) { +======= +func (c *$.type|privatePlural$) List(_$.type|private$Name string, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) { +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" var timeout time.Duration if opts.TimeoutSeconds != nil{ timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -420,7 +424,7 @@ func (c *$.type|privatePlural$) List(ctx context.Context, $.type|private$Name st err = c.client.Get(). $if .namespaced$Namespace(c.ns).$end$ Resource("$.type|resource$"). - Name($.type|private$Name). + Name(_$.type|private$Name). SubResource("$.subresourcePath$"). VersionedParams(&opts, $.schemeParameterCodec|raw$). Timeout(timeout). @@ -431,8 +435,13 @@ func (c *$.type|privatePlural$) List(ctx context.Context, $.type|private$Name st ` var getTemplate = ` +<<<<<<< HEAD // Get takes name of the $.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. func (c *$.type|privatePlural$) Get(ctx context.Context, name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { +======= +// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|private$ object, and an error if there is any. +func (c *$.type|privatePlural$) Get(name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" result = &$.resultType|raw${} err = c.client.Get(). $if .namespaced$Namespace(c.ns).$end$ @@ -446,13 +455,18 @@ func (c *$.type|privatePlural$) Get(ctx context.Context, name string, options $. ` var getSubresourceTemplate = ` +<<<<<<< HEAD // Get takes name of the $.type|private$, and returns the corresponding $.resultType|raw$ object, and an error if there is any. func (c *$.type|privatePlural$) Get(ctx context.Context, $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { +======= +// Get takes name of the _$.type|private$, and returns the corresponding $.resultType|raw$ object, and an error if there is any. +func (c *$.type|privatePlural$) Get(_$.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) { +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" result = &$.resultType|raw${} err = c.client.Get(). $if .namespaced$Namespace(c.ns).$end$ Resource("$.type|resource$"). - Name($.type|private$Name). + Name(_$.type|private$Name). SubResource("$.subresourcePath$"). VersionedParams(&options, $.schemeParameterCodec|raw$). Do(ctx). @@ -462,8 +476,13 @@ func (c *$.type|privatePlural$) Get(ctx context.Context, $.type|private$Name str ` var deleteTemplate = ` +<<<<<<< HEAD // Delete takes name of the $.type|private$ and deletes it. Returns an error if one occurs. func (c *$.type|privatePlural$) Delete(ctx context.Context, name string, opts $.DeleteOptions|raw$) error { +======= +// Delete takes name of the _$.type|private$ and deletes it. Returns an error if one occurs. +func (c *$.type|privatePlural$) Delete(name string, options *$.DeleteOptions|raw$) error { +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" return c.client.Delete(). $if .namespaced$Namespace(c.ns).$end$ Resource("$.type|resource$"). @@ -493,65 +512,106 @@ func (c *$.type|privatePlural$) DeleteCollection(ctx context.Context, opts $.Del ` var createSubresourceTemplate = ` +<<<<<<< HEAD // 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. func (c *$.type|privatePlural$) Create(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) { +======= +// 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. +func (c *$.type|privatePlural$) Create(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) { +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" result = &$.resultType|raw${} err = c.client.Post(). $if .namespaced$Namespace(c.ns).$end$ Resource("$.type|resource$"). - Name($.type|private$Name). + Name(_$.type|private$Name). SubResource("$.subresourcePath$"). +<<<<<<< HEAD VersionedParams(&opts, $.schemeParameterCodec|raw$). Body($.inputType|private$). Do(ctx). +======= + Body(_$.inputType|private$). + Do(). +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" Into(result) return } ` var createTemplate = ` +<<<<<<< HEAD // 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. func (c *$.type|privatePlural$) Create(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) { +======= +// 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. +func (c *$.type|privatePlural$) Create(_$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) { +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" result = &$.resultType|raw${} err = c.client.Post(). $if .namespaced$Namespace(c.ns).$end$ Resource("$.type|resource$"). +<<<<<<< HEAD VersionedParams(&opts, $.schemeParameterCodec|raw$). Body($.inputType|private$). Do(ctx). +======= + Body(_$.inputType|private$). + Do(). +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" Into(result) return } ` var updateSubresourceTemplate = ` +<<<<<<< HEAD // 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. func (c *$.type|privatePlural$) Update(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) { +======= +// 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. +func (c *$.type|privatePlural$) Update(_$.type|private$Name string, _$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) { +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" result = &$.resultType|raw${} err = c.client.Put(). $if .namespaced$Namespace(c.ns).$end$ Resource("$.type|resource$"). - Name($.type|private$Name). + Name(_$.type|private$Name). SubResource("$.subresourcePath$"). +<<<<<<< HEAD VersionedParams(&opts, $.schemeParameterCodec|raw$). Body($.inputType|private$). Do(ctx). +======= + Body(_$.inputType|private$). + Do(). +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" Into(result) return } ` var updateTemplate = ` +<<<<<<< HEAD // 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. func (c *$.type|privatePlural$) Update(ctx context.Context, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) { +======= +// 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. +func (c *$.type|privatePlural$) Update(_$.inputType|private$ *$.inputType|raw$) (result *$.resultType|raw$, err error) { +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" result = &$.resultType|raw${} err = c.client.Put(). $if .namespaced$Namespace(c.ns).$end$ Resource("$.type|resource$"). +<<<<<<< HEAD Name($.inputType|private$.Name). VersionedParams(&opts, $.schemeParameterCodec|raw$). Body($.inputType|private$). Do(ctx). +======= + Name(_$.inputType|private$.Name). + Body(_$.inputType|private$). + Do(). +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" Into(result) return } @@ -560,16 +620,26 @@ func (c *$.type|privatePlural$) Update(ctx context.Context, $.inputType|private$ var updateStatusTemplate = ` // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +<<<<<<< HEAD func (c *$.type|privatePlural$) UpdateStatus(ctx context.Context, $.type|private$ *$.type|raw$, opts $.UpdateOptions|raw$) (result *$.type|raw$, err error) { +======= + +func (c *$.type|privatePlural$) UpdateStatus(_$.type|private$ *$.type|raw$) (result *$.type|raw$, err error) { +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" result = &$.type|raw${} err = c.client.Put(). $if .namespaced$Namespace(c.ns).$end$ Resource("$.type|resource$"). - Name($.type|private$.Name). + Name(_$.type|private$.Name). SubResource("status"). +<<<<<<< HEAD VersionedParams(&opts, $.schemeParameterCodec|raw$). Body($.type|private$). Do(ctx). +======= + Body(_$.type|private$). + Do(). +>>>>>>> d9a14a5... Add prefix to avoid argument name conflict with go reserved words "package" Into(result) return } diff --git a/cmd/informer-gen/generators/informer.go b/cmd/informer-gen/generators/informer.go index da00e6e6..a71385f1 100644 --- a/cmd/informer-gen/generators/informer.go +++ b/cmd/informer-gen/generators/informer.go @@ -124,7 +124,7 @@ type $.type|public$Informer interface { ` var typeInformerStruct = ` -type $.type|private$Informer struct { +type _$.type|private$Informer struct { factory $.interfacesSharedInformerFactory|raw$ tweakListOptions $.interfacesTweakListOptionsFunc|raw$ $if .namespaced$namespace string$end$ @@ -168,19 +168,19 @@ func NewFiltered$.type|public$Informer(client $.clientSetInterface|raw$$if .name ` var typeInformerConstructor = ` -func (f *$.type|private$Informer) defaultInformer(client $.clientSetInterface|raw$, resyncPeriod $.timeDuration|raw$) $.cacheSharedIndexInformer|raw$ { +func (f *_$.type|private$Informer) defaultInformer(client $.clientSetInterface|raw$, resyncPeriod $.timeDuration|raw$) $.cacheSharedIndexInformer|raw$ { return NewFiltered$.type|public$Informer(client$if .namespaced$, f.namespace$end$, resyncPeriod, $.cacheIndexers|raw${$.cacheNamespaceIndex|raw$: $.cacheMetaNamespaceIndexFunc|raw$}, f.tweakListOptions) } ` var typeInformerInformer = ` -func (f *$.type|private$Informer) Informer() $.cacheSharedIndexInformer|raw$ { +func (f *_$.type|private$Informer) Informer() $.cacheSharedIndexInformer|raw$ { return f.factory.$.informerFor$(&$.type|raw${}, f.defaultInformer) } ` var typeInformerLister = ` -func (f *$.type|private$Informer) Lister() $.lister|raw$ { +func (f *_$.type|private$Informer) Lister() $.lister|raw$ { return $.newLister|raw$(f.Informer().GetIndexer()) } ` diff --git a/cmd/informer-gen/generators/versioninterface.go b/cmd/informer-gen/generators/versioninterface.go index 3b51f8dc..441975be 100644 --- a/cmd/informer-gen/generators/versioninterface.go +++ b/cmd/informer-gen/generators/versioninterface.go @@ -104,6 +104,6 @@ func New(f $.interfacesSharedInformerFactory|raw$, namespace string, tweakListOp var versionFuncTemplate = ` // $.type|publicPlural$ returns a $.type|public$Informer. func (v *version) $.type|publicPlural$() $.type|public$Informer { - return &$.type|private$Informer{factory: v.factory$if .namespaced$, namespace: v.namespace$end$, tweakListOptions: v.tweakListOptions} + return &_$.type|private$Informer{factory: v.factory$if .namespaced$, namespace: v.namespace$end$, tweakListOptions: v.tweakListOptions} } ` diff --git a/cmd/lister-gen/generators/lister.go b/cmd/lister-gen/generators/lister.go index 496145b1..e69413b8 100644 --- a/cmd/lister-gen/generators/lister.go +++ b/cmd/lister-gen/generators/lister.go @@ -284,8 +284,8 @@ type $.type|public$Lister interface { ` var typeListerStruct = ` -// $.type|private$Lister implements the $.type|public$Lister interface. -type $.type|private$Lister struct { +// _$.type|private$Lister implements the $.type|public$Lister interface. +type _$.type|private$Lister struct { indexer cache.Indexer } ` @@ -293,13 +293,13 @@ type $.type|private$Lister struct { var typeListerConstructor = ` // New$.type|public$Lister returns a new $.type|public$Lister. func New$.type|public$Lister(indexer cache.Indexer) $.type|public$Lister { - return &$.type|private$Lister{indexer: indexer} + return &_$.type|private$Lister{indexer: indexer} } ` var typeLister_List = ` // List lists all $.type|publicPlural$ in the indexer. -func (s *$.type|private$Lister) List(selector labels.Selector) (ret []*$.type|raw$, err error) { +func (s *_$.type|private$Lister) List(selector labels.Selector) (ret []*$.type|raw$, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { ret = append(ret, m.(*$.type|raw$)) }) @@ -309,14 +309,14 @@ func (s *$.type|private$Lister) List(selector labels.Selector) (ret []*$.type|ra var typeLister_NamespaceLister = ` // $.type|publicPlural$ returns an object that can list and get $.type|publicPlural$. -func (s *$.type|private$Lister) $.type|publicPlural$(namespace string) $.type|public$NamespaceLister { - return $.type|private$NamespaceLister{indexer: s.indexer, namespace: namespace} +func (s *_$.type|private$Lister) $.type|publicPlural$(namespace string) $.type|public$NamespaceLister { + return _$.type|private$NamespaceLister{indexer: s.indexer, namespace: namespace} } ` var typeLister_NonNamespacedGet = ` // Get retrieves the $.type|public$ from the index for a given name. -func (s *$.type|private$Lister) Get(name string) (*$.type|raw$, error) { +func (s *_$.type|private$Lister) Get(name string) (*$.type|raw$, error) { obj, exists, err := s.indexer.GetByKey(name) if err != nil { return nil, err @@ -343,9 +343,9 @@ type $.type|public$NamespaceLister interface { ` var namespaceListerStruct = ` -// $.type|private$NamespaceLister implements the $.type|public$NamespaceLister +// _$.type|private$NamespaceLister implements the $.type|public$NamespaceLister // interface. -type $.type|private$NamespaceLister struct { +type _$.type|private$NamespaceLister struct { indexer cache.Indexer namespace string } @@ -353,7 +353,7 @@ type $.type|private$NamespaceLister struct { var namespaceLister_List = ` // List lists all $.type|publicPlural$ in the indexer for a given namespace. -func (s $.type|private$NamespaceLister) List(selector labels.Selector) (ret []*$.type|raw$, err error) { +func (s _$.type|private$NamespaceLister) List(selector labels.Selector) (ret []*$.type|raw$, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { ret = append(ret, m.(*$.type|raw$)) }) @@ -363,7 +363,7 @@ func (s $.type|private$NamespaceLister) List(selector labels.Selector) (ret []*$ var namespaceLister_Get = ` // Get retrieves the $.type|public$ from the indexer for a given namespace and name. -func (s $.type|private$NamespaceLister) Get(name string) (*$.type|raw$, error) { +func (s _$.type|private$NamespaceLister) Get(name string) (*$.type|raw$, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err