generate client for replicaset

This commit is contained in:
Chao Xu 2016-01-31 12:44:19 -08:00
parent c72d234bbf
commit 7722a50647
7 changed files with 276 additions and 11 deletions

View File

@ -830,6 +830,8 @@ const (
LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist"
)
// +genclient=true
// ReplicaSet represents the configuration of a replica set.
type ReplicaSet struct {
unversioned.TypeMeta `json:",inline"`

View File

@ -28,6 +28,7 @@ type ExtensionsInterface interface {
HorizontalPodAutoscalersGetter
IngressesGetter
JobsGetter
ReplicaSetsGetter
ScalesGetter
ThirdPartyResourcesGetter
}
@ -57,6 +58,10 @@ func (c *ExtensionsClient) Jobs(namespace string) JobInterface {
return newJobs(c, namespace)
}
func (c *ExtensionsClient) ReplicaSets(namespace string) ReplicaSetInterface {
return newReplicaSets(c, namespace)
}
func (c *ExtensionsClient) Scales(namespace string) ScaleInterface {
return newScales(c, namespace)
}

View File

@ -111,14 +111,3 @@ func (c *FakeDeployments) Watch(opts api.ListOptions) (watch.Interface, error) {
InvokesWatch(core.NewWatchAction("deployments", c.ns, opts))
}
func (c *FakeDeployments) Rollback(deploymentRollback *extensions.DeploymentRollback) error {
action := core.CreateActionImpl{}
action.Verb = "create"
action.Resource = "deployments"
action.Subresource = "rollback"
action.Object = deploymentRollback
_, err := c.Fake.Invokes(action, deploymentRollback)
return err
}

View File

@ -45,6 +45,10 @@ func (c *FakeExtensions) Jobs(namespace string) unversioned.JobInterface {
return &FakeJobs{c, namespace}
}
func (c *FakeExtensions) ReplicaSets(namespace string) unversioned.ReplicaSetInterface {
return &FakeReplicaSets{c, namespace}
}
func (c *FakeExtensions) Scales(namespace string) unversioned.ScaleInterface {
return &FakeScales{c, namespace}
}

View File

@ -0,0 +1,113 @@
/*
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.
*/
package fake
import (
api "k8s.io/kubernetes/pkg/api"
extensions "k8s.io/kubernetes/pkg/apis/extensions"
core "k8s.io/kubernetes/pkg/client/testing/core"
labels "k8s.io/kubernetes/pkg/labels"
watch "k8s.io/kubernetes/pkg/watch"
)
// FakeReplicaSets implements ReplicaSetInterface
type FakeReplicaSets struct {
Fake *FakeExtensions
ns string
}
func (c *FakeReplicaSets) Create(replicaSet *extensions.ReplicaSet) (result *extensions.ReplicaSet, err error) {
obj, err := c.Fake.
Invokes(core.NewCreateAction("replicasets", c.ns, replicaSet), &extensions.ReplicaSet{})
if obj == nil {
return nil, err
}
return obj.(*extensions.ReplicaSet), err
}
func (c *FakeReplicaSets) Update(replicaSet *extensions.ReplicaSet) (result *extensions.ReplicaSet, err error) {
obj, err := c.Fake.
Invokes(core.NewUpdateAction("replicasets", c.ns, replicaSet), &extensions.ReplicaSet{})
if obj == nil {
return nil, err
}
return obj.(*extensions.ReplicaSet), err
}
func (c *FakeReplicaSets) UpdateStatus(replicaSet *extensions.ReplicaSet) (*extensions.ReplicaSet, error) {
obj, err := c.Fake.
Invokes(core.NewUpdateSubresourceAction("replicasets", "status", c.ns, replicaSet), &extensions.ReplicaSet{})
if obj == nil {
return nil, err
}
return obj.(*extensions.ReplicaSet), err
}
func (c *FakeReplicaSets) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction("replicasets", c.ns, name), &extensions.ReplicaSet{})
return err
}
func (c *FakeReplicaSets) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
action := core.NewDeleteCollectionAction("events", c.ns, listOptions)
_, err := c.Fake.Invokes(action, &extensions.ReplicaSetList{})
return err
}
func (c *FakeReplicaSets) Get(name string) (result *extensions.ReplicaSet, err error) {
obj, err := c.Fake.
Invokes(core.NewGetAction("replicasets", c.ns, name), &extensions.ReplicaSet{})
if obj == nil {
return nil, err
}
return obj.(*extensions.ReplicaSet), err
}
func (c *FakeReplicaSets) List(opts api.ListOptions) (result *extensions.ReplicaSetList, err error) {
obj, err := c.Fake.
Invokes(core.NewListAction("replicasets", c.ns, opts), &extensions.ReplicaSetList{})
if obj == nil {
return nil, err
}
label := opts.LabelSelector
if label == nil {
label = labels.Everything()
}
list := &extensions.ReplicaSetList{}
for _, item := range obj.(*extensions.ReplicaSetList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested replicaSets.
func (c *FakeReplicaSets) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(core.NewWatchAction("replicasets", c.ns, opts))
}

View File

@ -27,3 +27,5 @@ type JobExpansion interface{}
type ScaleExpansion interface{}
type ThirdPartyResourceExpansion interface{}
type ReplicaSetExpansion interface{}

View File

@ -0,0 +1,150 @@
/*
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.
*/
package unversioned
import (
api "k8s.io/kubernetes/pkg/api"
extensions "k8s.io/kubernetes/pkg/apis/extensions"
watch "k8s.io/kubernetes/pkg/watch"
)
// ReplicaSetsGetter has a method to return a ReplicaSetInterface.
// A group's client should implement this interface.
type ReplicaSetsGetter interface {
ReplicaSets(namespace string) ReplicaSetInterface
}
// ReplicaSetInterface has methods to work with ReplicaSet resources.
type ReplicaSetInterface interface {
Create(*extensions.ReplicaSet) (*extensions.ReplicaSet, error)
Update(*extensions.ReplicaSet) (*extensions.ReplicaSet, error)
UpdateStatus(*extensions.ReplicaSet) (*extensions.ReplicaSet, error)
Delete(name string, options *api.DeleteOptions) error
DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error
Get(name string) (*extensions.ReplicaSet, error)
List(opts api.ListOptions) (*extensions.ReplicaSetList, error)
Watch(opts api.ListOptions) (watch.Interface, error)
ReplicaSetExpansion
}
// replicaSets implements ReplicaSetInterface
type replicaSets struct {
client *ExtensionsClient
ns string
}
// newReplicaSets returns a ReplicaSets
func newReplicaSets(c *ExtensionsClient, namespace string) *replicaSets {
return &replicaSets{
client: c,
ns: namespace,
}
}
// Create takes the representation of a replicaSet and creates it. Returns the server's representation of the replicaSet, and an error, if there is any.
func (c *replicaSets) Create(replicaSet *extensions.ReplicaSet) (result *extensions.ReplicaSet, err error) {
result = &extensions.ReplicaSet{}
err = c.client.Post().
Namespace(c.ns).
Resource("replicasets").
Body(replicaSet).
Do().
Into(result)
return
}
// Update takes the representation of a replicaSet and updates it. Returns the server's representation of the replicaSet, and an error, if there is any.
func (c *replicaSets) Update(replicaSet *extensions.ReplicaSet) (result *extensions.ReplicaSet, err error) {
result = &extensions.ReplicaSet{}
err = c.client.Put().
Namespace(c.ns).
Resource("replicasets").
Name(replicaSet.Name).
Body(replicaSet).
Do().
Into(result)
return
}
func (c *replicaSets) UpdateStatus(replicaSet *extensions.ReplicaSet) (result *extensions.ReplicaSet, err error) {
result = &extensions.ReplicaSet{}
err = c.client.Put().
Namespace(c.ns).
Resource("replicasets").
Name(replicaSet.Name).
SubResource("status").
Body(replicaSet).
Do().
Into(result)
return
}
// Delete takes name of the replicaSet and deletes it. Returns an error if one occurs.
func (c *replicaSets) Delete(name string, options *api.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("replicasets").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *replicaSets) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("replicasets").
VersionedParams(&listOptions, api.ParameterCodec).
Body(options).
Do().
Error()
}
// Get takes name of the replicaSet, and returns the corresponding replicaSet object, and an error if there is any.
func (c *replicaSets) Get(name string) (result *extensions.ReplicaSet, err error) {
result = &extensions.ReplicaSet{}
err = c.client.Get().
Namespace(c.ns).
Resource("replicasets").
Name(name).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of ReplicaSets that match those selectors.
func (c *replicaSets) List(opts api.ListOptions) (result *extensions.ReplicaSetList, err error) {
result = &extensions.ReplicaSetList{}
err = c.client.Get().
Namespace(c.ns).
Resource("replicasets").
VersionedParams(&opts, api.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested replicaSets.
func (c *replicaSets) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Resource("replicasets").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}