Merge pull request #51638 from mfojtik/client-gen-custom-methods

Automatic merge from submit-queue (batch tested with PRs 51805, 51725, 50925, 51474, 51638)

Allow custom client verbs to be generated using client-gen

This change will allow to define custom verbs for resources using the following new tag:

```
// +genclient:method=Foo,verb=create,subresource=foo,input=Bar,output=k8s.io/pkg/api.Blah
```

This will generate client method `Foo(bar *Bar) (*api.Blah, error)` (format depends on the particular verb type)

With this change we can add `UpdateScale()` and `GetScale()` into all scalable resources. Note that intention of this PR is not to fix the Scale(), but that is used as an example of this new capability.
Additionally this will also allow us to get rid of `// +genclient:noStatus` and fix guessing of the "updateStatus" subresource presence based on the existence of '.Status' field.
Basically you will have to add following into all types you want to generate `UpdateStatus()` for:

```
// +genclient:method=UpdateStatus,verb=update,subresource=status
```

This allows further extension of the client without writing an expansion (which proved to be pain to maintain and copy...). Also allows to customize native CRUD methods if needed (input/output types).

```release-note
NONE
```

Kubernetes-commit: bee221cca98f1ebf0d46e18d58ecd309bf4f6199
This commit is contained in:
Kubernetes Publisher 2017-09-03 11:10:09 -07:00
commit 4d791e3272
12 changed files with 329 additions and 74 deletions

148
Godeps/Godeps.json generated
View File

@ -372,299 +372,299 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2alpha1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "429a9e49c4fef512e68dc11e3ce5da5e79d88ffd"
"Rev": "b4c1dde74617eb5b4db9a7db95b75ecb8bf2b54f"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "f65a69e51385565c76e8ccb7730f96d4c4dd96a6"
"Rev": "f16ee4db044a21569fc95031aba96d08c5f28e7e"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/common",

View File

@ -136,3 +136,25 @@ func (c *FakeStatefulSets) Patch(name string, pt types.PatchType, data []byte, s
}
return obj.(*v1beta2.StatefulSet), err
}
// GetScale takes name of the statefulSet, and returns the corresponding scale object, and an error if there is any.
func (c *FakeStatefulSets) GetScale(statefulSetName string, options v1.GetOptions) (result *v1beta2.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetSubresourceAction(statefulsetsResource, c.ns, "scale", statefulSetName), &v1beta2.Scale{})
if obj == nil {
return nil, err
}
return obj.(*v1beta2.Scale), err
}
// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *FakeStatefulSets) UpdateScale(statefulSetName string, scale *v1beta2.Scale) (result *v1beta2.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(statefulsetsResource, "scale", c.ns, scale), &v1beta2.Scale{})
if obj == nil {
return nil, err
}
return obj.(*v1beta2.Scale), err
}

View File

@ -42,6 +42,9 @@ type StatefulSetInterface interface {
List(opts v1.ListOptions) (*v1beta2.StatefulSetList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta2.StatefulSet, err error)
GetScale(statefulSetName string, options v1.GetOptions) (*v1beta2.Scale, error)
UpdateScale(statefulSetName string, scale *v1beta2.Scale) (*v1beta2.Scale, error)
StatefulSetExpansion
}
@ -170,3 +173,31 @@ func (c *statefulSets) Patch(name string, pt types.PatchType, data []byte, subre
Into(result)
return
}
// GetScale takes name of the statefulSet, and returns the corresponding v1beta2.Scale object, and an error if there is any.
func (c *statefulSets) GetScale(statefulSetName string, options v1.GetOptions) (result *v1beta2.Scale, err error) {
result = &v1beta2.Scale{}
err = c.client.Get().
Namespace(c.ns).
Resource("statefulsets").
Name(statefulSetName).
SubResource("scale").
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// UpdateScale takes the top resource name and the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *statefulSets) UpdateScale(statefulSetName string, scale *v1beta2.Scale) (result *v1beta2.Scale, err error) {
result = &v1beta2.Scale{}
err = c.client.Put().
Namespace(c.ns).
Resource("statefulsets").
Name(statefulSetName).
SubResource("scale").
Body(scale).
Do().
Into(result)
return
}

View File

@ -35,6 +35,7 @@ go_library(
],
deps = [
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
"//vendor/k8s.io/api/policy/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",

View File

@ -34,6 +34,7 @@ go_library(
],
deps = [
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
"//vendor/k8s.io/api/policy/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",

View File

@ -18,6 +18,7 @@ package fake
import (
core_v1 "k8s.io/api/core/v1"
v1beta1 "k8s.io/api/extensions/v1beta1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
@ -136,3 +137,25 @@ func (c *FakeReplicationControllers) Patch(name string, pt types.PatchType, data
}
return obj.(*core_v1.ReplicationController), err
}
// GetScale takes name of the replicationController, and returns the corresponding scale object, and an error if there is any.
func (c *FakeReplicationControllers) GetScale(replicationControllerName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetSubresourceAction(replicationcontrollersResource, c.ns, "scale", replicationControllerName), &v1beta1.Scale{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Scale), err
}
// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *FakeReplicationControllers) UpdateScale(replicationControllerName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(replicationcontrollersResource, "scale", c.ns, scale), &v1beta1.Scale{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Scale), err
}

View File

@ -18,6 +18,7 @@ package v1
import (
v1 "k8s.io/api/core/v1"
v1beta1 "k8s.io/api/extensions/v1beta1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
@ -42,6 +43,9 @@ type ReplicationControllerInterface interface {
List(opts meta_v1.ListOptions) (*v1.ReplicationControllerList, error)
Watch(opts meta_v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ReplicationController, err error)
GetScale(replicationControllerName string, options meta_v1.GetOptions) (*v1beta1.Scale, error)
UpdateScale(replicationControllerName string, scale *v1beta1.Scale) (*v1beta1.Scale, error)
ReplicationControllerExpansion
}
@ -170,3 +174,31 @@ func (c *replicationControllers) Patch(name string, pt types.PatchType, data []b
Into(result)
return
}
// GetScale takes name of the replicationController, and returns the corresponding v1beta1.Scale object, and an error if there is any.
func (c *replicationControllers) GetScale(replicationControllerName string, options meta_v1.GetOptions) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Get().
Namespace(c.ns).
Resource("replicationcontrollers").
Name(replicationControllerName).
SubResource("scale").
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// UpdateScale takes the top resource name and the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *replicationControllers) UpdateScale(replicationControllerName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Put().
Namespace(c.ns).
Resource("replicationcontrollers").
Name(replicationControllerName).
SubResource("scale").
Body(scale).
Do().
Into(result)
return
}

View File

@ -42,6 +42,9 @@ type DeploymentInterface interface {
List(opts v1.ListOptions) (*v1beta1.DeploymentList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error)
GetScale(deploymentName string, options v1.GetOptions) (*v1beta1.Scale, error)
UpdateScale(deploymentName string, scale *v1beta1.Scale) (*v1beta1.Scale, error)
DeploymentExpansion
}
@ -170,3 +173,31 @@ func (c *deployments) Patch(name string, pt types.PatchType, data []byte, subres
Into(result)
return
}
// GetScale takes name of the deployment, and returns the corresponding v1beta1.Scale object, and an error if there is any.
func (c *deployments) GetScale(deploymentName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Get().
Namespace(c.ns).
Resource("deployments").
Name(deploymentName).
SubResource("scale").
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// UpdateScale takes the top resource name and the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *deployments) UpdateScale(deploymentName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Put().
Namespace(c.ns).
Resource("deployments").
Name(deploymentName).
SubResource("scale").
Body(scale).
Do().
Into(result)
return
}

View File

@ -136,3 +136,25 @@ func (c *FakeDeployments) Patch(name string, pt types.PatchType, data []byte, su
}
return obj.(*v1beta1.Deployment), err
}
// GetScale takes name of the deployment, and returns the corresponding scale object, and an error if there is any.
func (c *FakeDeployments) GetScale(deploymentName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetSubresourceAction(deploymentsResource, c.ns, "scale", deploymentName), &v1beta1.Scale{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Scale), err
}
// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *FakeDeployments) UpdateScale(deploymentName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(deploymentsResource, "scale", c.ns, scale), &v1beta1.Scale{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Scale), err
}

View File

@ -136,3 +136,25 @@ func (c *FakeReplicaSets) Patch(name string, pt types.PatchType, data []byte, su
}
return obj.(*v1beta1.ReplicaSet), err
}
// GetScale takes name of the replicaSet, and returns the corresponding scale object, and an error if there is any.
func (c *FakeReplicaSets) GetScale(replicaSetName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetSubresourceAction(replicasetsResource, c.ns, "scale", replicaSetName), &v1beta1.Scale{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Scale), err
}
// UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *FakeReplicaSets) UpdateScale(replicaSetName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(replicasetsResource, "scale", c.ns, scale), &v1beta1.Scale{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.Scale), err
}

View File

@ -42,6 +42,9 @@ type ReplicaSetInterface interface {
List(opts v1.ListOptions) (*v1beta1.ReplicaSetList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.ReplicaSet, err error)
GetScale(replicaSetName string, options v1.GetOptions) (*v1beta1.Scale, error)
UpdateScale(replicaSetName string, scale *v1beta1.Scale) (*v1beta1.Scale, error)
ReplicaSetExpansion
}
@ -170,3 +173,31 @@ func (c *replicaSets) Patch(name string, pt types.PatchType, data []byte, subres
Into(result)
return
}
// GetScale takes name of the replicaSet, and returns the corresponding v1beta1.Scale object, and an error if there is any.
func (c *replicaSets) GetScale(replicaSetName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Get().
Namespace(c.ns).
Resource("replicasets").
Name(replicaSetName).
SubResource("scale").
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// UpdateScale takes the top resource name and the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
func (c *replicaSets) UpdateScale(replicaSetName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Put().
Namespace(c.ns).
Resource("replicasets").
Name(replicaSetName).
SubResource("scale").
Body(scale).
Do().
Into(result)
return
}

View File

@ -47,6 +47,17 @@ func NewGetAction(resource schema.GroupVersionResource, namespace, name string)
return action
}
func NewGetSubresourceAction(resource schema.GroupVersionResource, namespace, subresource, name string) GetActionImpl {
action := GetActionImpl{}
action.Verb = "get"
action.Resource = resource
action.Subresource = subresource
action.Namespace = namespace
action.Name = name
return action
}
func NewRootListAction(resource schema.GroupVersionResource, kind schema.GroupVersionKind, opts interface{}) ListActionImpl {
action := ListActionImpl{}
action.Verb = "list"
@ -70,6 +81,20 @@ func NewListAction(resource schema.GroupVersionResource, kind schema.GroupVersio
return action
}
func NewListSubresourceAction(resource schema.GroupVersionResource, name, subresource string, kind schema.GroupVersionKind, namespace string, opts interface{}) ListActionImpl {
action := ListActionImpl{}
action.Verb = "list"
action.Resource = resource
action.Subresource = subresource
action.Kind = kind
action.Namespace = namespace
action.Name = name
labelSelector, fieldSelector, _ := ExtractFromListOptions(opts)
action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector}
return action
}
func NewRootCreateAction(resource schema.GroupVersionResource, object runtime.Object) CreateActionImpl {
action := CreateActionImpl{}
action.Verb = "create"
@ -89,6 +114,18 @@ func NewCreateAction(resource schema.GroupVersionResource, namespace string, obj
return action
}
func NewCreateSubresourceAction(resource schema.GroupVersionResource, name, subresource string, namespace string, object runtime.Object) CreateActionImpl {
action := CreateActionImpl{}
action.Verb = "create"
action.Resource = resource
action.Subresource = subresource
action.Namespace = namespace
action.Name = name
action.Object = object
return action
}
func NewRootUpdateAction(resource schema.GroupVersionResource, object runtime.Object) UpdateActionImpl {
action := UpdateActionImpl{}
action.Verb = "update"
@ -389,6 +426,7 @@ func (a GetActionImpl) GetName() string {
type ListActionImpl struct {
ActionImpl
Kind schema.GroupVersionKind
Name string
ListRestrictions ListRestrictions
}
@ -402,6 +440,7 @@ func (a ListActionImpl) GetListRestrictions() ListRestrictions {
type CreateActionImpl struct {
ActionImpl
Name string
Object runtime.Object
}