Fix variable name conflict in clientset generation

This commit is contained in:
Maciej Szulik 2016-12-16 23:56:16 +01:00
parent e3c6ab1c8f
commit e0ecb09fda
2 changed files with 24 additions and 24 deletions

View File

@ -160,19 +160,19 @@ func NewForConfig(c *$.Config|raw$) (*Clientset, error) {
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
} }
var clientset Clientset var cs Clientset
var err error var err error
$range .allGroups$ clientset.$.GroupVersion$Client, err =$.PackageName$.NewForConfig(&configShallowCopy) $range .allGroups$ cs.$.GroupVersion$Client, err =$.PackageName$.NewForConfig(&configShallowCopy)
if err!=nil { if err!=nil {
return nil, err return nil, err
} }
$end$ $end$
clientset.DiscoveryClient, err = $.NewDiscoveryClientForConfig|raw$(&configShallowCopy) cs.DiscoveryClient, err = $.NewDiscoveryClientForConfig|raw$(&configShallowCopy)
if err!=nil { if err!=nil {
glog.Errorf("failed to create the DiscoveryClient: %v", err) glog.Errorf("failed to create the DiscoveryClient: %v", err)
return nil, err return nil, err
} }
return &clientset, nil return &cs, nil
} }
` `
@ -180,21 +180,21 @@ var newClientsetForConfigOrDieTemplate = `
// NewForConfigOrDie creates a new Clientset for the given config and // NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config. // panics if there is an error in the config.
func NewForConfigOrDie(c *$.Config|raw$) *Clientset { func NewForConfigOrDie(c *$.Config|raw$) *Clientset {
var clientset Clientset var cs Clientset
$range .allGroups$ clientset.$.GroupVersion$Client =$.PackageName$.NewForConfigOrDie(c) $range .allGroups$ cs.$.GroupVersion$Client =$.PackageName$.NewForConfigOrDie(c)
$end$ $end$
clientset.DiscoveryClient = $.NewDiscoveryClientForConfigOrDie|raw$(c) cs.DiscoveryClient = $.NewDiscoveryClientForConfigOrDie|raw$(c)
return &clientset return &cs
} }
` `
var newClientsetForRESTClientTemplate = ` var newClientsetForRESTClientTemplate = `
// New creates a new Clientset for the given RESTClient. // New creates a new Clientset for the given RESTClient.
func New(c $.RESTClientInterface|raw$) *Clientset { func New(c $.RESTClientInterface|raw$) *Clientset {
var clientset Clientset var cs Clientset
$range .allGroups$ clientset.$.GroupVersion$Client =$.PackageName$.New(c) $range .allGroups$ cs.$.GroupVersion$Client =$.PackageName$.New(c)
$end$ $end$
clientset.DiscoveryClient = $.NewDiscoveryClient|raw$(c) cs.DiscoveryClient = $.NewDiscoveryClient|raw$(c)
return &clientset return &cs
} }
` `

View File

@ -56,36 +56,36 @@ func NewForConfig(c *restclient.Config) (*Clientset, error) {
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
} }
var clientset Clientset var cs Clientset
var err error var err error
clientset.TestgroupClient, err = internalversiontestgroup.NewForConfig(&configShallowCopy) cs.TestgroupClient, err = internalversiontestgroup.NewForConfig(&configShallowCopy)
if err != nil { if err != nil {
return nil, err return nil, err
} }
clientset.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil { if err != nil {
glog.Errorf("failed to create the DiscoveryClient: %v", err) glog.Errorf("failed to create the DiscoveryClient: %v", err)
return nil, err return nil, err
} }
return &clientset, nil return &cs, nil
} }
// NewForConfigOrDie creates a new Clientset for the given config and // NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config. // panics if there is an error in the config.
func NewForConfigOrDie(c *restclient.Config) *Clientset { func NewForConfigOrDie(c *restclient.Config) *Clientset {
var clientset Clientset var cs Clientset
clientset.TestgroupClient = internalversiontestgroup.NewForConfigOrDie(c) cs.TestgroupClient = internalversiontestgroup.NewForConfigOrDie(c)
clientset.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &clientset return &cs
} }
// New creates a new Clientset for the given RESTClient. // New creates a new Clientset for the given RESTClient.
func New(c restclient.Interface) *Clientset { func New(c restclient.Interface) *Clientset {
var clientset Clientset var cs Clientset
clientset.TestgroupClient = internalversiontestgroup.New(c) cs.TestgroupClient = internalversiontestgroup.New(c)
clientset.DiscoveryClient = discovery.NewDiscoveryClient(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &clientset return &cs
} }