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

View File

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