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:
Chao Xu 2016-04-18 10:50:54 -07:00
parent 616af686cb
commit 79c3d6683c
3 changed files with 6 additions and 5 deletions

View File

@ -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,

View File

@ -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})
}

View File

@ -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 {