mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-14 06:15:45 +00:00
Remove lowercasing for project imports
This commit provides a fix for the scenario where a project has an uppercase letter in the project import path. Prior to this fix the generated files would end up in different directories with some of the imports being lower-cased during generation. An example of this would be a project such as 'github.com/MixedCase/project' would result in some of the imports with 'github.com/mixedcase/project' causing a broken build.
This commit is contained in:
parent
2fb9fc2400
commit
4fd1ad69ab
@ -130,7 +130,7 @@ func DefaultNameSystem() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func packageForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetPackage string, groupPackageName string, groupGoName string, apiPath string, srcTreePath string, inputPackage string, boilerplate []byte) generator.Package {
|
func packageForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetPackage string, groupPackageName string, groupGoName string, apiPath string, srcTreePath string, inputPackage string, boilerplate []byte) generator.Package {
|
||||||
groupVersionClientPackage := strings.ToLower(filepath.Join(clientsetPackage, "typed", groupPackageName, gv.Version.NonEmpty()))
|
groupVersionClientPackage := filepath.Join(clientsetPackage, "typed", strings.ToLower(groupPackageName), strings.ToLower(gv.Version.NonEmpty()))
|
||||||
return &generator.DefaultPackage{
|
return &generator.DefaultPackage{
|
||||||
PackageName: strings.ToLower(gv.Version.NonEmpty()),
|
PackageName: strings.ToLower(gv.Version.NonEmpty()),
|
||||||
PackagePath: groupVersionClientPackage,
|
PackagePath: groupVersionClientPackage,
|
||||||
|
@ -30,9 +30,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func PackageForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetPackage string, groupPackageName string, groupGoName string, inputPackage string, boilerplate []byte) generator.Package {
|
func PackageForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetPackage string, groupPackageName string, groupGoName string, inputPackage string, boilerplate []byte) generator.Package {
|
||||||
outputPackage := strings.ToLower(filepath.Join(clientsetPackage, "typed", groupPackageName, gv.Version.NonEmpty(), "fake"))
|
outputPackage := filepath.Join(clientsetPackage, "typed", strings.ToLower(groupPackageName), strings.ToLower(gv.Version.NonEmpty()), "fake")
|
||||||
// TODO: should make this a function, called by here and in client-generator.go
|
// TODO: should make this a function, called by here and in client-generator.go
|
||||||
realClientPackage := filepath.Join(clientsetPackage, "typed", groupPackageName, gv.Version.NonEmpty())
|
realClientPackage := filepath.Join(clientsetPackage, "typed", strings.ToLower(groupPackageName), strings.ToLower(gv.Version.NonEmpty()))
|
||||||
return &generator.DefaultPackage{
|
return &generator.DefaultPackage{
|
||||||
PackageName: "fake",
|
PackageName: "fake",
|
||||||
PackagePath: outputPackage,
|
PackagePath: outputPackage,
|
||||||
|
@ -60,12 +60,12 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
|
|||||||
imports = append(imports, g.imports.ImportLines()...)
|
imports = append(imports, g.imports.ImportLines()...)
|
||||||
for _, group := range g.groups {
|
for _, group := range g.groups {
|
||||||
for _, version := range group.Versions {
|
for _, version := range group.Versions {
|
||||||
groupClientPackage := filepath.Join(g.fakeClientsetPackage, "typed", group.PackageName, version.NonEmpty())
|
groupClientPackage := filepath.Join(g.fakeClientsetPackage, "typed", strings.ToLower(group.PackageName), strings.ToLower(version.NonEmpty()))
|
||||||
fakeGroupClientPackage := filepath.Join(groupClientPackage, "fake")
|
fakeGroupClientPackage := filepath.Join(groupClientPackage, "fake")
|
||||||
|
|
||||||
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
|
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
|
||||||
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.NonEmpty(), groupClientPackage)))
|
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", groupAlias, strings.ToLower(version.NonEmpty()), groupClientPackage))
|
||||||
imports = append(imports, strings.ToLower(fmt.Sprintf("fake%s%s \"%s\"", groupAlias, version.NonEmpty(), fakeGroupClientPackage)))
|
imports = append(imports, fmt.Sprintf("fake%s%s \"%s\"", groupAlias, strings.ToLower(version.NonEmpty()), fakeGroupClientPackage))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// the package that has the clientset Interface
|
// the package that has the clientset Interface
|
||||||
|
@ -64,7 +64,7 @@ func (g *genFakeForGroup) Namers(c *generator.Context) namer.NameSystems {
|
|||||||
func (g *genFakeForGroup) Imports(c *generator.Context) (imports []string) {
|
func (g *genFakeForGroup) Imports(c *generator.Context) (imports []string) {
|
||||||
imports = g.imports.ImportLines()
|
imports = g.imports.ImportLines()
|
||||||
if len(g.types) != 0 {
|
if len(g.types) != 0 {
|
||||||
imports = append(imports, strings.ToLower(fmt.Sprintf("%s \"%s\"", filepath.Base(g.realClientPackage), g.realClientPackage)))
|
imports = append(imports, fmt.Sprintf("%s \"%s\"", strings.ToLower(filepath.Base(g.realClientPackage)), g.realClientPackage))
|
||||||
}
|
}
|
||||||
return imports
|
return imports
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,9 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
|
|||||||
imports = append(imports, g.imports.ImportLines()...)
|
imports = append(imports, g.imports.ImportLines()...)
|
||||||
for _, group := range g.groups {
|
for _, group := range g.groups {
|
||||||
for _, version := range group.Versions {
|
for _, version := range group.Versions {
|
||||||
typedClientPath := filepath.Join(g.clientsetPackage, "typed", group.PackageName, version.NonEmpty())
|
typedClientPath := filepath.Join(g.clientsetPackage, "typed", strings.ToLower(group.PackageName), strings.ToLower(version.NonEmpty()))
|
||||||
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
|
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
|
||||||
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.NonEmpty(), typedClientPath)))
|
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", groupAlias, strings.ToLower(version.NonEmpty()), typedClientPath))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -69,10 +69,11 @@ func (g *GenScheme) Imports(c *generator.Context) (imports []string) {
|
|||||||
packagePath = filepath.Dir(packagePath)
|
packagePath = filepath.Dir(packagePath)
|
||||||
}
|
}
|
||||||
packagePath = filepath.Join(packagePath, "install")
|
packagePath = filepath.Join(packagePath, "install")
|
||||||
imports = append(imports, strings.ToLower(fmt.Sprintf("%s \"%s\"", groupAlias, path.Vendorless(packagePath))))
|
|
||||||
|
imports = append(imports, fmt.Sprintf("%s \"%s\"", groupAlias, path.Vendorless(packagePath)))
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.Version.NonEmpty(), path.Vendorless(packagePath))))
|
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", groupAlias, strings.ToLower(version.Version.NonEmpty()), path.Vendorless(packagePath)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user