informer-gen: allow package names containing dots

Before 73dc5a96de,
informer-gen calculated the effective package name by using the first
segment of the groupName.

After the commit, the package name is calculated directly from the
PackageName specified, without any normalizations. This meant that if
the actual PackageName contains dots, the effective package name
can now contain dots too. However, this doesn't work well while
parsing files. This also introduced a regression since dots can no longer
be specified in package names.

To fix this, this commit introduces the same normalizations on the
PackageName i.e. the effective package name now uses the first segment
of PackageName.
This commit is contained in:
Nikhita Raghunath 2019-09-06 15:17:25 +05:30
parent 9b376e4e8e
commit 802fed53e3

View File

@ -283,9 +283,10 @@ func factoryInterfacePackage(basePackage string, boilerplate []byte, clientSetPa
func groupPackage(basePackage string, groupVersions clientgentypes.GroupVersions, boilerplate []byte) generator.Package {
packagePath := filepath.Join(basePackage, groupVersions.PackageName)
groupPkgName := strings.Split(string(groupVersions.PackageName), ".")[0]
return &generator.DefaultPackage{
PackageName: groupVersions.PackageName,
PackageName: groupPkgName,
PackagePath: packagePath,
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {