Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move typed clients into clientset folder #23608

Merged
merged 2 commits into from
Apr 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/kubelet/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ 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"
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/restclient"
unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned"
clientauth "k8s.io/kubernetes/pkg/client/unversioned/auth"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
Expand Down
9 changes: 5 additions & 4 deletions cmd/libs/go2idl/client-gen/generators/client_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
}

var packageList []generator.Package
typedClientBasePath := filepath.Join(customArgs.ClientsetOutputPath, customArgs.ClientsetName, "typed")

packageList = append(packageList, packageForClientset(customArgs, arguments.OutputPackagePath, boilerplate))
packageList = append(packageList, packageForClientset(customArgs, typedClientBasePath, boilerplate))
if customArgs.FakeClient {
packageList = append(packageList, fake.PackageForClientset(customArgs, arguments.OutputPackagePath, boilerplate))
packageList = append(packageList, fake.PackageForClientset(customArgs, typedClientBasePath, boilerplate))
}

// If --clientset-only=true, we don't regenerate the individual typed clients.
Expand All @@ -188,9 +189,9 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
orderer := namer.Orderer{namer.NewPrivateNamer(0)}
for _, gv := range customArgs.GroupVersions {
types := gvToTypes[gv]
packageList = append(packageList, packageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), arguments.OutputPackagePath, arguments.OutputBase, boilerplate))
packageList = append(packageList, packageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), typedClientBasePath, arguments.OutputBase, boilerplate))
if customArgs.FakeClient {
packageList = append(packageList, fake.PackageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), arguments.OutputPackagePath, arguments.OutputBase, boilerplate))
packageList = append(packageList, fake.PackageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), typedClientBasePath, arguments.OutputBase, boilerplate))
}
}

Expand Down
8 changes: 0 additions & 8 deletions cmd/libs/go2idl/client-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ func main() {
arguments.InputDirs = append(dependencies, []string{
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup",
}...)
// We may change the output path later.
arguments.OutputPackagePath = "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput"
arguments.CustomArgs = clientgenargs.Args{
[]unversioned.GroupVersion{{Group: "testgroup", Version: ""}},
map[unversioned.GroupVersion]string{
Expand All @@ -114,12 +112,6 @@ func main() {
}
glog.Infof("going to generate clientset from these input paths: %v", inputPath)
arguments.InputDirs = append(inputPath, dependencies...)
// TODO: we need to make OutPackagePath a map[string]string. For example,
// we need clientset and the individual typed clients be output to different
// output path.

// We may change the output path later.
arguments.OutputPackagePath = "k8s.io/kubernetes/pkg/client/typed/generated"

arguments.CustomArgs = clientgenargs.Args{
groupVersions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package test_internalclientset

import (
"github.com/golang/glog"
unversionedtestgroup "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/testgroup/unversioned"
unversionedtestgroup "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/clientset_generated/test_internalclientset/typed/testgroup/unversioned"
restclient "k8s.io/kubernetes/pkg/client/restclient"
discovery "k8s.io/kubernetes/pkg/client/typed/discovery"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup"
_ "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testdata/apis/testgroup/install"
. "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/testgroup/unversioned"
. "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/clientset_generated/test_internalclientset/typed/testgroup/unversioned"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
Expand Down
2 changes: 1 addition & 1 deletion contrib/mesos/pkg/executor/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package executor
import (
"k8s.io/kubernetes/contrib/mesos/pkg/node"
"k8s.io/kubernetes/pkg/api"
unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
)

type kubeAPI interface {
Expand Down
2 changes: 1 addition & 1 deletion contrib/mesos/pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"
"time"

unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"

log "github.com/golang/glog"
mesos "github.com/mesos/mesos-go/mesosproto"
Expand Down
2 changes: 1 addition & 1 deletion contrib/mesos/pkg/node/registrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"time"

unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"

log "github.com/golang/glog"
"k8s.io/kubernetes/contrib/mesos/pkg/queue"
Expand Down
4 changes: 2 additions & 2 deletions contrib/mesos/pkg/node/registrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned/fake"
"k8s.io/kubernetes/pkg/client/testing/core"
unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned"
"k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned/fake"
"k8s.io/kubernetes/pkg/runtime"
)

Expand Down
2 changes: 1 addition & 1 deletion contrib/mesos/pkg/scheduler/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ import (
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/client/cache"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/restclient"
unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
cloud "k8s.io/kubernetes/pkg/cloudprovider/providers/mesos"
controllerfw "k8s.io/kubernetes/pkg/controller/framework"
Expand Down
6 changes: 3 additions & 3 deletions docs/devel/generating-clientset.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ $ client-gen --input="api/v1,extensions/v1beta1" --clientset-name="my_release"
```

will generate a clientset named "my_release" which includes clients for api/v1 objects and extensions/v1beta1 objects. You can run `$ client-gen --help` to see other command line arguments.
- Adding expansion methods: client-gen only generates the common methods, such as `Create()` and `Delete()`. You can manually add additional methods through the expansion interface. For example, this [file](../../pkg/client/typed/generated/core/v1/pod_expansion.go) adds additional methods to Pod's client. As a convention, we put the expansion interface and its methods in file ${TYPE}_expansion.go.
- Adding expansion methods: client-gen only generates the common methods, such as `Create()` and `Delete()`. You can manually add additional methods through the expansion interface. For example, this [file](../../pkg/client/clientset_generated/release_1_2/typed/core/v1/pod_expansion.go) adds additional methods to Pod's client. As a convention, we put the expansion interface and its methods in file ${TYPE}_expansion.go.
- Generating Fake clients for testing purposes: client-gen will generate a fake clientset if the command line argument `--fake-clientset` is set. The fake clientset provides the default implementation, you only need to fake out the methods you care about when writing test cases.

The output of client-gen inlcudes:
- Individual typed clients and client for group: They will be generated at `pkg/client/typed/generated/${GROUP}/${VERSION}/`
- clientset: the top-level clientset will be generated at `pkg/client/clientset_generated` by default, and you can change the path via the `--clientset-path` command line argument.
- clientset: the clientset will be generated at `pkg/client/clientset_generated/` by default, and you can change the path via the `--clientset-path` command line argument.
- Individual typed clients and client for group: They will be generated at `pkg/client/clientset_generated/${clientset_name}/typed/generated/${GROUP}/${VERSION}/`

## Released clientsets

Expand Down
4 changes: 2 additions & 2 deletions pkg/client/clientset_generated/internalclientset/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ package internalclientset

import (
"github.com/golang/glog"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
unversionedextensions "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/unversioned"
restclient "k8s.io/kubernetes/pkg/client/restclient"
discovery "k8s.io/kubernetes/pkg/client/typed/discovery"
unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned"
unversionedextensions "k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned"
)

type Interface interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apimachinery/registered"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
unversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
fakeunversionedcore "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned/fake"
unversionedextensions "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/unversioned"
fakeunversionedextensions "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/unversioned/fake"
"k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/client/typed/discovery"
fakediscovery "k8s.io/kubernetes/pkg/client/typed/discovery/fake"
unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned"
fakeunversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned/fake"
unversionedextensions "k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned"
fakeunversionedextensions "k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned/fake"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
Copyright 2016 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// This file is generated by client-gen with the default arguments.

package unversioned

import (
api "k8s.io/kubernetes/pkg/api"
watch "k8s.io/kubernetes/pkg/watch"
)

// ComponentStatusesGetter has a method to return a ComponentStatusInterface.
// A group's client should implement this interface.
type ComponentStatusesGetter interface {
ComponentStatuses() ComponentStatusInterface
}

// ComponentStatusInterface has methods to work with ComponentStatus resources.
type ComponentStatusInterface interface {
Create(*api.ComponentStatus) (*api.ComponentStatus, error)
Update(*api.ComponentStatus) (*api.ComponentStatus, error)
Delete(name string, options *api.DeleteOptions) error
DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error
Get(name string) (*api.ComponentStatus, error)
List(opts api.ListOptions) (*api.ComponentStatusList, error)
Watch(opts api.ListOptions) (watch.Interface, error)
ComponentStatusExpansion
}

// componentStatuses implements ComponentStatusInterface
type componentStatuses struct {
client *CoreClient
}

// newComponentStatuses returns a ComponentStatuses
func newComponentStatuses(c *CoreClient) *componentStatuses {
return &componentStatuses{
client: c,
}
}

// Create takes the representation of a componentStatus and creates it. Returns the server's representation of the componentStatus, and an error, if there is any.
func (c *componentStatuses) Create(componentStatus *api.ComponentStatus) (result *api.ComponentStatus, err error) {
result = &api.ComponentStatus{}
err = c.client.Post().
Resource("componentstatuses").
Body(componentStatus).
Do().
Into(result)
return
}

// Update takes the representation of a componentStatus and updates it. Returns the server's representation of the componentStatus, and an error, if there is any.
func (c *componentStatuses) Update(componentStatus *api.ComponentStatus) (result *api.ComponentStatus, err error) {
result = &api.ComponentStatus{}
err = c.client.Put().
Resource("componentstatuses").
Name(componentStatus.Name).
Body(componentStatus).
Do().
Into(result)
return
}

// Delete takes name of the componentStatus and deletes it. Returns an error if one occurs.
func (c *componentStatuses) Delete(name string, options *api.DeleteOptions) error {
return c.client.Delete().
Resource("componentstatuses").
Name(name).
Body(options).
Do().
Error()
}

// DeleteCollection deletes a collection of objects.
func (c *componentStatuses) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
return c.client.Delete().
Resource("componentstatuses").
VersionedParams(&listOptions, api.ParameterCodec).
Body(options).
Do().
Error()
}

// Get takes name of the componentStatus, and returns the corresponding componentStatus object, and an error if there is any.
func (c *componentStatuses) Get(name string) (result *api.ComponentStatus, err error) {
result = &api.ComponentStatus{}
err = c.client.Get().
Resource("componentstatuses").
Name(name).
Do().
Into(result)
return
}

// List takes label and field selectors, and returns the list of ComponentStatuses that match those selectors.
func (c *componentStatuses) List(opts api.ListOptions) (result *api.ComponentStatusList, err error) {
result = &api.ComponentStatusList{}
err = c.client.Get().
Resource("componentstatuses").
VersionedParams(&opts, api.ParameterCodec).
Do().
Into(result)
return
}

// Watch returns a watch.Interface that watches the requested componentStatuses.
func (c *componentStatuses) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Resource("componentstatuses").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}