Skip to content

Commit

Permalink
include multiple versions in clientset
Browse files Browse the repository at this point in the history
update client-gen to use the term "internalversion" rather than "unversioned";
leave internal one unqualified;
cleanup client-gen
  • Loading branch information
Chao Xu committed Oct 29, 2016
1 parent 3bda688 commit 850729b
Show file tree
Hide file tree
Showing 581 changed files with 3,177 additions and 2,067 deletions.
2 changes: 1 addition & 1 deletion cmd/kube-controller-manager/app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ go_library(
"//pkg/apis/batch:go_default_library",
"//pkg/apis/componentconfig:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/core/unversioned:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/core/internalversion:go_default_library",
"//pkg/client/leaderelection:go_default_library",
"//pkg/client/leaderelection/resourcelock:go_default_library",
"//pkg/client/record:go_default_library",
Expand Down
2 changes: 1 addition & 1 deletion cmd/kube-controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/batch"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
"k8s.io/kubernetes/pkg/client/leaderelection"
"k8s.io/kubernetes/pkg/client/leaderelection/resourcelock"
"k8s.io/kubernetes/pkg/client/record"
Expand Down
2 changes: 1 addition & 1 deletion cmd/kube-proxy/app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ go_library(
"//cmd/kube-proxy/app/options:go_default_library",
"//pkg/api:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/core/unversioned:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/core/internalversion:go_default_library",
"//pkg/client/record:go_default_library",
"//pkg/client/unversioned/clientcmd:go_default_library",
"//pkg/client/unversioned/clientcmd/api:go_default_library",
Expand Down
2 changes: 1 addition & 1 deletion cmd/kube-proxy/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"k8s.io/kubernetes/cmd/kube-proxy/app/options"
"k8s.io/kubernetes/pkg/api"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/node/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go_library(
"//cmd/kubeadm/app/util:go_default_library",
"//pkg/apis/certificates:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/certificates/unversioned:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/certificates/internalversion:go_default_library",
"//pkg/client/unversioned/clientcmd:go_default_library",
"//pkg/client/unversioned/clientcmd/api:go_default_library",
"//pkg/kubelet/util/csr:go_default_library",
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/node/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
"k8s.io/kubernetes/pkg/apis/certificates"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
certclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/certificates/unversioned"
certclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/certificates/internalversion"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/wait"
Expand Down
8 changes: 4 additions & 4 deletions cmd/kubelet/app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ go_library(
"//pkg/capabilities:go_default_library",
"//pkg/client/chaosclient:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/authentication/unversioned:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/authorization/unversioned:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/certificates/unversioned:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/core/unversioned:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/authentication/internalversion:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/authorization/internalversion:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/certificates/internalversion:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/core/internalversion:go_default_library",
"//pkg/client/record:go_default_library",
"//pkg/client/restclient:go_default_library",
"//pkg/client/unversioned/auth:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubelet/app/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/auth/group"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
authenticationclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/authentication/unversioned"
authorizationclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/authorization/unversioned"
authenticationclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/authentication/internalversion"
authorizationclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/authorization/internalversion"
alwaysallowauthorizer "k8s.io/kubernetes/pkg/genericapiserver/authorizer"
"k8s.io/kubernetes/pkg/kubelet/server"
"k8s.io/kubernetes/pkg/types"
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubelet/app/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/golang/glog"

unversionedcertificates "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/certificates/unversioned"
unversionedcertificates "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/certificates/internalversion"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubelet/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
"k8s.io/kubernetes/pkg/capabilities"
"k8s.io/kubernetes/pkg/client/chaosclient"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/restclient"
clientauth "k8s.io/kubernetes/pkg/client/unversioned/auth"
Expand Down
2 changes: 1 addition & 1 deletion cmd/libs/go2idl/client-gen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ go_binary(
deps = [
"//cmd/libs/go2idl/client-gen/args:go_default_library",
"//cmd/libs/go2idl/client-gen/generators:go_default_library",
"//pkg/api/unversioned:go_default_library",
"//cmd/libs/go2idl/client-gen/types:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:github.com/spf13/pflag",
"//vendor:k8s.io/gengo/args",
Expand Down
2 changes: 1 addition & 1 deletion cmd/libs/go2idl/client-gen/args/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ go_library(
name = "go_default_library",
srcs = ["args.go"],
tags = ["automanaged"],
deps = ["//pkg/api/unversioned:go_default_library"],
deps = ["//cmd/libs/go2idl/client-gen/types:go_default_library"],
)
11 changes: 4 additions & 7 deletions cmd/libs/go2idl/client-gen/args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@ limitations under the License.

package args

import "k8s.io/kubernetes/pkg/api/unversioned"
import "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/types"

// ClientGenArgs is a wrapper for arguments to client-gen.
type Args struct {
// TODO: we should make another type declaration of GroupVersion out of the
// unversioned package, which is part of our API. Tools like client-gen
// shouldn't depend on an API.
GroupVersions []unversioned.GroupVersion
Groups []types.GroupVersions

// GroupVersionToInputPath is a map between GroupVersion and the path to
// the respective types.go. We still need GroupVersions in the struct because
// we need an order.
GroupVersionToInputPath map[unversioned.GroupVersion]string
GroupVersionToInputPath map[types.GroupVersion]string

// Overrides for which types should be included in the client.
IncludedTypesOverrides map[unversioned.GroupVersion][]string
IncludedTypesOverrides map[types.GroupVersion][]string

// ClientsetName is the name of the clientset to be generated. It's
// populated from command-line arguments.
Expand Down
3 changes: 1 addition & 2 deletions cmd/libs/go2idl/client-gen/generators/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ go_library(
deps = [
"//cmd/libs/go2idl/client-gen/args:go_default_library",
"//cmd/libs/go2idl/client-gen/generators/fake:go_default_library",
"//cmd/libs/go2idl/client-gen/generators/normalization:go_default_library",
"//pkg/api/unversioned:go_default_library",
"//cmd/libs/go2idl/client-gen/types:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:k8s.io/gengo/args",
"//vendor:k8s.io/gengo/generator",
Expand Down
38 changes: 20 additions & 18 deletions cmd/libs/go2idl/client-gen/generators/client_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import (
"k8s.io/gengo/types"
clientgenargs "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/args"
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/generators/fake"
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/generators/normalization"
"k8s.io/kubernetes/pkg/api/unversioned"
clientgentypes "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/types"

"github.com/golang/glog"
)
Expand Down Expand Up @@ -62,10 +61,10 @@ func generatedBy(customArgs clientgenargs.Args) string {
return fmt.Sprintf("\n// This package is generated by client-gen with the default arguments.\n\n")
}

func packageForGroup(gv unversioned.GroupVersion, typeList []*types.Type, packageBasePath string, apiPath string, srcTreePath string, inputPath string, boilerplate []byte, generatedBy string) generator.Package {
outputPackagePath := filepath.Join(packageBasePath, gv.Group, gv.Version)
func packageForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, packageBasePath string, apiPath string, srcTreePath string, inputPath string, boilerplate []byte, generatedBy string) generator.Package {
outputPackagePath := strings.ToLower(filepath.Join(packageBasePath, gv.Group.NonEmpty(), gv.Version.NonEmpty()))
return &generator.DefaultPackage{
PackageName: gv.Version,
PackageName: strings.ToLower(gv.Version.NonEmpty()),
PackagePath: outputPackagePath,
HeaderText: boilerplate,
PackageDocumentation: []byte(
Expand All @@ -87,21 +86,21 @@ func packageForGroup(gv unversioned.GroupVersion, typeList []*types.Type, packag
OptionalName: strings.ToLower(c.Namers["private"].Name(t)),
},
outputPackage: outputPackagePath,
group: normalization.BeforeFirstDot(gv.Group),
version: gv.Version,
group: gv.Group.NonEmpty(),
version: gv.Version.String(),
typeToMatch: t,
imports: generator.NewImportTracker(),
})
}

generators = append(generators, &genGroup{
DefaultGen: generator.DefaultGen{
OptionalName: normalization.BeforeFirstDot(gv.Group) + "_client",
OptionalName: gv.Group.NonEmpty() + "_client",
},
outputPackage: outputPackagePath,
inputPacakge: inputPath,
group: gv.Group,
version: gv.Version,
group: gv.Group.NonEmpty(),
version: gv.Version.String(),
apiPath: apiPath,
types: typeList,
imports: generator.NewImportTracker(),
Expand Down Expand Up @@ -144,7 +143,7 @@ func packageForClientset(customArgs clientgenargs.Args, typedClientBasePath stri
DefaultGen: generator.DefaultGen{
OptionalName: "clientset",
},
groupVersions: customArgs.GroupVersions,
groups: customArgs.Groups,
typedClientPath: typedClientBasePath,
outputPackage: customArgs.ClientsetName,
imports: generator.NewImportTracker(),
Expand All @@ -170,7 +169,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat

generatedBy := generatedBy(customArgs)

gvToTypes := map[unversioned.GroupVersion][]*types.Type{}
gvToTypes := map[clientgentypes.GroupVersion][]*types.Type{}
for gv, inputDir := range customArgs.GroupVersionToInputPath {
p := context.Universe.Package(inputDir)
for n, t := range p.Types {
Expand Down Expand Up @@ -215,12 +214,15 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
}

orderer := namer.Orderer{Namer: namer.NewPrivateNamer(0)}
for _, gv := range customArgs.GroupVersions {
types := gvToTypes[gv]
inputPath := customArgs.GroupVersionToInputPath[gv]
packageList = append(packageList, packageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), typedClientBasePath, customArgs.ClientsetAPIPath, arguments.OutputBase, inputPath, boilerplate, generatedBy))
if customArgs.FakeClient {
packageList = append(packageList, fake.PackageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), typedClientBasePath, arguments.OutputBase, inputPath, boilerplate, generatedBy))
for _, group := range customArgs.Groups {
for _, version := range group.Versions {
gv := clientgentypes.GroupVersion{Group: group.Group, Version: version}
types := gvToTypes[gv]
inputPath := customArgs.GroupVersionToInputPath[gv]
packageList = append(packageList, packageForGroup(gv, orderer.OrderTypes(types), typedClientBasePath, customArgs.ClientsetAPIPath, arguments.OutputBase, inputPath, boilerplate, generatedBy))
if customArgs.FakeClient {
packageList = append(packageList, fake.PackageForGroup(gv, orderer.OrderTypes(types), typedClientBasePath, arguments.OutputBase, inputPath, boilerplate, generatedBy))
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/libs/go2idl/client-gen/generators/fake/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ go_library(
tags = ["automanaged"],
deps = [
"//cmd/libs/go2idl/client-gen/args:go_default_library",
"//cmd/libs/go2idl/client-gen/generators/normalization:go_default_library",
"//pkg/api/unversioned:go_default_library",
"//cmd/libs/go2idl/client-gen/types:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:k8s.io/gengo/generator",
"//vendor:k8s.io/gengo/namer",
Expand Down
20 changes: 10 additions & 10 deletions cmd/libs/go2idl/client-gen/generators/fake/fake_client_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ import (
"k8s.io/gengo/generator"
"k8s.io/gengo/types"
clientgenargs "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/args"
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/generators/normalization"
"k8s.io/kubernetes/pkg/api/unversioned"
clientgentypes "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/types"
)

func PackageForGroup(gv unversioned.GroupVersion, typeList []*types.Type, packageBasePath string, srcTreePath string, inputPath string, boilerplate []byte, generatedBy string) generator.Package {
outputPackagePath := filepath.Join(packageBasePath, gv.Group, gv.Version, "fake")
func PackageForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, packageBasePath string, srcTreePath string, inputPath string, boilerplate []byte, generatedBy string) generator.Package {
outputPackagePath := strings.ToLower(filepath.Join(packageBasePath, gv.Group.NonEmpty(), gv.Version.NonEmpty(), "fake"))
// TODO: should make this a function, called by here and in client-generator.go
realClientPath := filepath.Join(packageBasePath, gv.Group, gv.Version)
realClientPath := filepath.Join(packageBasePath, gv.Group.NonEmpty(), gv.Version.NonEmpty())
return &generator.DefaultPackage{
PackageName: "fake",
PackagePath: outputPackagePath,
Expand All @@ -56,21 +55,22 @@ func PackageForGroup(gv unversioned.GroupVersion, typeList []*types.Type, packag
OptionalName: "fake_" + strings.ToLower(c.Namers["private"].Name(t)),
},
outputPackage: outputPackagePath,
group: normalization.BeforeFirstDot(gv.Group),
group: gv.Group.NonEmpty(),
version: gv.Version.String(),
inputPackage: inputPath,
version: gv.Version,
typeToMatch: t,
imports: generator.NewImportTracker(),
})
}

generators = append(generators, &genFakeForGroup{
DefaultGen: generator.DefaultGen{
OptionalName: "fake_" + normalization.BeforeFirstDot(gv.Group) + "_client",
OptionalName: "fake_" + gv.Group.NonEmpty() + "_client",
},
outputPackage: outputPackagePath,
realClientPath: realClientPath,
group: normalization.BeforeFirstDot(gv.Group),
group: gv.Group.NonEmpty(),
version: gv.Version.String(),
types: typeList,
imports: generator.NewImportTracker(),
})
Expand Down Expand Up @@ -112,7 +112,7 @@ func PackageForClientset(customArgs clientgenargs.Args, typedClientBasePath stri
DefaultGen: generator.DefaultGen{
OptionalName: "clientset_generated",
},
groupVersions: customArgs.GroupVersions,
groups: customArgs.Groups,
typedClientPath: typedClientBasePath,
outputPackage: "fake",
imports: generator.NewImportTracker(),
Expand Down
Loading

0 comments on commit 850729b

Please sign in to comment.