mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Client-gen: add fake clients to testoutput; in fake clients, fix the imports of packages that contains dots in the name
This commit is contained in:
parent
616af686cb
commit
79c3d6683c
@ -62,7 +62,7 @@ func PackageForGroup(gv unversioned.GroupVersion, typeList []*types.Type, packag
|
||||
|
||||
generators = append(generators, &genFakeForGroup{
|
||||
DefaultGen: generator.DefaultGen{
|
||||
OptionalName: "fake_" + gv.Group + "_client",
|
||||
OptionalName: "fake_" + normalization.BeforeFirstDot(gv.Group) + "_client",
|
||||
},
|
||||
outputPackage: outputPackagePath,
|
||||
realClientPath: realClientPath,
|
||||
|
@ -60,10 +60,11 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
|
||||
for _, gv := range g.groupVersions {
|
||||
group := normalization.Group(gv.Group)
|
||||
version := normalization.Version(gv.Version)
|
||||
undotted_group := normalization.BeforeFirstDot(group)
|
||||
typedClientPath := filepath.Join(g.typedClientPath, group, version)
|
||||
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", version, group, typedClientPath))
|
||||
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", version, undotted_group, typedClientPath))
|
||||
fakeTypedClientPath := filepath.Join(typedClientPath, "fake")
|
||||
imports = append(imports, fmt.Sprintf("fake%s%s \"%s\"", version, group, fakeTypedClientPath))
|
||||
imports = append(imports, fmt.Sprintf("fake%s%s \"%s\"", version, undotted_group, fakeTypedClientPath))
|
||||
}
|
||||
// the package that has the clientset Interface
|
||||
imports = append(imports, fmt.Sprintf("clientset \"%s\"", g.clientsetPath))
|
||||
@ -96,7 +97,7 @@ func (g *genClientset) GenerateType(c *generator.Context, t *types.Type, w io.Wr
|
||||
}
|
||||
allGroups := []arg{}
|
||||
for _, gv := range g.groupVersions {
|
||||
group := normalization.Group(gv.Group)
|
||||
group := normalization.BeforeFirstDot(normalization.Group(gv.Group))
|
||||
version := normalization.Version(gv.Version)
|
||||
allGroups = append(allGroups, arg{namer.IC(group), version + group})
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ func main() {
|
||||
ClientsetName: "test_internalclientset",
|
||||
ClientsetOutputPath: "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/clientset_generated/",
|
||||
ClientsetOnly: false,
|
||||
FakeClient: false,
|
||||
FakeClient: true,
|
||||
CmdArgs: cmdArgs,
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user