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

Allow to extend generated clients with custom verbs #16019

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/deploy/apis/apps/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ const (
)

// +genclient
// +genclient:method=Instantiate,verb=create,subresource=instantiate,input=DeploymentRequest
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/kubernetes/pkg/apis/extensions/v1beta1.Scale
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/kubernetes/pkg/apis/extensions/v1beta1.Scale,result=k8s.io/kubernetes/pkg/apis/extensions/v1beta1.Scale

// DeploymentConfig represents a configuration for a single deployment (represented as a
// ReplicationController). It also contains details about changes which resulted in the current
Expand Down
3 changes: 3 additions & 0 deletions pkg/deploy/apis/apps/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
)

// +genclient
// +genclient:method=Instantiate,verb=create,subresource=instantiate,input=DeploymentRequest
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/kubernetes/pkg/apis/extensions/v1beta1.Scale
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/kubernetes/pkg/apis/extensions/v1beta1.Scale,result=k8s.io/kubernetes/pkg/apis/extensions/v1beta1.Scale

// Deployment Configs define the template for a pod and manages deploying new images or configuration changes.
// A single deployment configuration is usually analogous to a single micro-service. Can support many different
Expand Down
47 changes: 47 additions & 0 deletions pkg/deploy/generated/clientset/typed/apps/v1/deploymentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
v1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
)

// DeploymentConfigsGetter has a method to return a DeploymentConfigInterface.
Expand All @@ -26,6 +27,10 @@ type DeploymentConfigInterface interface {
List(opts meta_v1.ListOptions) (*v1.DeploymentConfigList, error)
Watch(opts meta_v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.DeploymentConfig, err error)
Instantiate(deploymentConfigName string, deploymentRequest *v1.DeploymentRequest) (*v1.DeploymentConfig, error)
GetScale(deploymentConfigName string, options meta_v1.GetOptions) (*v1beta1.Scale, error)
UpdateScale(deploymentConfigName string, scale *v1beta1.Scale) (*v1beta1.Scale, error)

DeploymentConfigExpansion
}

Expand Down Expand Up @@ -154,3 +159,45 @@ func (c *deploymentConfigs) Patch(name string, pt types.PatchType, data []byte,
Into(result)
return
}

// Instantiate takes the representation of a deploymentRequest and creates it. Returns the server's representation of the deploymentConfig, and an error, if there is any.
func (c *deploymentConfigs) Instantiate(deploymentConfigName string, deploymentRequest *v1.DeploymentRequest) (result *v1.DeploymentConfig, err error) {
result = &v1.DeploymentConfig{}
err = c.client.Post().
Namespace(c.ns).
Resource("deploymentconfigs").
Name(deploymentConfigName).
SubResource("instantiate").
Body(deploymentRequest).
Do().
Into(result)
return
}

// GetScale takes name of the deploymentConfig, and returns the corresponding v1beta1.Scale object, and an error if there is any.
func (c *deploymentConfigs) GetScale(deploymentConfigName string, options meta_v1.GetOptions) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Get().
Namespace(c.ns).
Resource("deploymentconfigs").
Name(deploymentConfigName).
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 *deploymentConfigs) UpdateScale(deploymentConfigName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Put().
Namespace(c.ns).
Resource("deploymentconfigs").
Name(deploymentConfigName).
SubResource("scale").
Body(scale).
Do().
Into(result)
return
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
)

// FakeDeploymentConfigs implements DeploymentConfigInterface
Expand Down Expand Up @@ -120,3 +121,36 @@ func (c *FakeDeploymentConfigs) Patch(name string, pt types.PatchType, data []by
}
return obj.(*apps_v1.DeploymentConfig), err
}

// Instantiate takes the representation of a deploymentRequest and creates it. Returns the server's representation of the deploymentConfig, and an error, if there is any.
func (c *FakeDeploymentConfigs) Instantiate(deploymentConfigName string, deploymentRequest *apps_v1.DeploymentRequest) (result *apps_v1.DeploymentConfig, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateSubresourceAction(deploymentconfigsResource, deploymentConfigName, "instantiate", c.ns, deploymentRequest), &apps_v1.DeploymentRequest{})

if obj == nil {
return nil, err
}
return obj.(*apps_v1.DeploymentConfig), err
}

// GetScale takes name of the deploymentConfig, and returns the corresponding deploymentConfig object, and an error if there is any.
func (c *FakeDeploymentConfigs) GetScale(deploymentConfigName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetSubresourceAction(deploymentconfigsResource, c.ns, "scale", deploymentConfigName), &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 *FakeDeploymentConfigs) UpdateScale(deploymentConfigName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(deploymentconfigsResource, "scale", c.ns, scale), &v1beta1.Scale{})

if obj == nil {
return nil, err
}
return obj.(*v1beta1.Scale), err
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
v1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
)

// DeploymentConfigsGetter has a method to return a DeploymentConfigInterface.
Expand All @@ -26,6 +27,10 @@ type DeploymentConfigInterface interface {
List(opts v1.ListOptions) (*apps.DeploymentConfigList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apps.DeploymentConfig, err error)
Instantiate(deploymentConfigName string, deploymentRequest *apps.DeploymentRequest) (*apps.DeploymentConfig, error)
GetScale(deploymentConfigName string, options v1.GetOptions) (*v1beta1.Scale, error)
UpdateScale(deploymentConfigName string, scale *v1beta1.Scale) (*v1beta1.Scale, error)

DeploymentConfigExpansion
}

Expand Down Expand Up @@ -154,3 +159,45 @@ func (c *deploymentConfigs) Patch(name string, pt types.PatchType, data []byte,
Into(result)
return
}

// Instantiate takes the representation of a deploymentRequest and creates it. Returns the server's representation of the deploymentConfig, and an error, if there is any.
func (c *deploymentConfigs) Instantiate(deploymentConfigName string, deploymentRequest *apps.DeploymentRequest) (result *apps.DeploymentConfig, err error) {
result = &apps.DeploymentConfig{}
err = c.client.Post().
Namespace(c.ns).
Resource("deploymentconfigs").
Name(deploymentConfigName).
SubResource("instantiate").
Body(deploymentRequest).
Do().
Into(result)
return
}

// GetScale takes name of the deploymentConfig, and returns the corresponding v1beta1.Scale object, and an error if there is any.
func (c *deploymentConfigs) GetScale(deploymentConfigName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Get().
Namespace(c.ns).
Resource("deploymentconfigs").
Name(deploymentConfigName).
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 *deploymentConfigs) UpdateScale(deploymentConfigName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
result = &v1beta1.Scale{}
err = c.client.Put().
Namespace(c.ns).
Resource("deploymentconfigs").
Name(deploymentConfigName).
SubResource("scale").
Body(scale).
Do().
Into(result)
return
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
)

// FakeDeploymentConfigs implements DeploymentConfigInterface
Expand Down Expand Up @@ -120,3 +121,36 @@ func (c *FakeDeploymentConfigs) Patch(name string, pt types.PatchType, data []by
}
return obj.(*apps.DeploymentConfig), err
}

// Instantiate takes the representation of a deploymentRequest and creates it. Returns the server's representation of the deploymentConfig, and an error, if there is any.
func (c *FakeDeploymentConfigs) Instantiate(deploymentConfigName string, deploymentRequest *apps.DeploymentRequest) (result *apps.DeploymentConfig, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateSubresourceAction(deploymentconfigsResource, deploymentConfigName, "instantiate", c.ns, deploymentRequest), &apps.DeploymentRequest{})

if obj == nil {
return nil, err
}
return obj.(*apps.DeploymentConfig), err
}

// GetScale takes name of the deploymentConfig, and returns the corresponding deploymentConfig object, and an error if there is any.
func (c *FakeDeploymentConfigs) GetScale(deploymentConfigName string, options v1.GetOptions) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetSubresourceAction(deploymentconfigsResource, c.ns, "scale", deploymentConfigName), &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 *FakeDeploymentConfigs) UpdateScale(deploymentConfigName string, scale *v1beta1.Scale) (result *v1beta1.Scale, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(deploymentconfigsResource, "scale", c.ns, scale), &v1beta1.Scale{})

if obj == nil {
return nil, err
}
return obj.(*v1beta1.Scale), err
}
1 change: 1 addition & 0 deletions pkg/image/apis/image/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ type ImageStreamList struct {
}

// +genclient
// +genclient:method=Secrets,verb=list,subresource=secrets,result=k8s.io/kubernetes/pkg/api.Secret

// ImageStream stores a mapping of tags to images, metadata overrides that are applied
// when images are tagged in a stream, and an optional reference to a Docker image
Expand Down
1 change: 1 addition & 0 deletions pkg/image/apis/image/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ type ImageStreamList struct {
}

// +genclient
// +genclient:method=Secrets,verb=list,subresource=secrets,result=k8s.io/kubernetes/pkg/api/v1.Secret

// ImageStream stores a mapping of tags to images, metadata overrides that are applied
// when images are tagged in a stream, and an optional reference to a Docker image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
api_v1 "k8s.io/kubernetes/pkg/api/v1"
)

// FakeImageStreams implements ImageStreamInterface
Expand Down Expand Up @@ -120,3 +121,14 @@ func (c *FakeImageStreams) Patch(name string, pt types.PatchType, data []byte, s
}
return obj.(*image_v1.ImageStream), err
}

// Secrets takes label and field selectors, and returns the list of Secrets that match those selectors.
func (c *FakeImageStreams) Secrets(imageStreamName string, opts v1.ListOptions) (result *api_v1.SecretList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListSubresourceAction(imagestreamsResource, imageStreamName, "secrets", imagestreamsKind, c.ns, opts), &api_v1.SecretList{})

if obj == nil {
return nil, err
}
return obj.(*api_v1.SecretList), err
}
17 changes: 17 additions & 0 deletions pkg/image/generated/clientset/typed/image/v1/imagestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
api_v1 "k8s.io/kubernetes/pkg/api/v1"
)

// ImageStreamsGetter has a method to return a ImageStreamInterface.
Expand All @@ -26,6 +27,8 @@ type ImageStreamInterface interface {
List(opts meta_v1.ListOptions) (*v1.ImageStreamList, error)
Watch(opts meta_v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ImageStream, err error)
Secrets(imageStreamName string, opts meta_v1.ListOptions) (*api_v1.SecretList, error)

ImageStreamExpansion
}

Expand Down Expand Up @@ -154,3 +157,17 @@ func (c *imageStreams) Patch(name string, pt types.PatchType, data []byte, subre
Into(result)
return
}

// Secrets takes v1.ImageStream name, label and field selectors, and returns the list of Secrets that match those selectors.
func (c *imageStreams) Secrets(imageStreamName string, opts meta_v1.ListOptions) (result *api_v1.SecretList, err error) {
result = &api_v1.SecretList{}
err = c.client.Get().
Namespace(c.ns).
Resource("imagestreams").
Name(imageStreamName).
SubResource("secrets").
VersionedParams(&opts, scheme.ParameterCodec).
Do().
Into(result)
return
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
api "k8s.io/kubernetes/pkg/api"
)

// FakeImageStreams implements ImageStreamInterface
Expand Down Expand Up @@ -120,3 +121,14 @@ func (c *FakeImageStreams) Patch(name string, pt types.PatchType, data []byte, s
}
return obj.(*image.ImageStream), err
}

// Secrets takes label and field selectors, and returns the list of Secrets that match those selectors.
func (c *FakeImageStreams) Secrets(imageStreamName string, opts v1.ListOptions) (result *api.SecretList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListSubresourceAction(imagestreamsResource, imageStreamName, "secrets", imagestreamsKind, c.ns, opts), &api.SecretList{})

if obj == nil {
return nil, err
}
return obj.(*api.SecretList), err
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
api "k8s.io/kubernetes/pkg/api"
)

// ImageStreamsGetter has a method to return a ImageStreamInterface.
Expand All @@ -26,6 +27,8 @@ type ImageStreamInterface interface {
List(opts v1.ListOptions) (*image.ImageStreamList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *image.ImageStream, err error)
Secrets(imageStreamName string, opts v1.ListOptions) (*api.SecretList, error)

ImageStreamExpansion
}

Expand Down Expand Up @@ -154,3 +157,17 @@ func (c *imageStreams) Patch(name string, pt types.PatchType, data []byte, subre
Into(result)
return
}

// Secrets takes image.ImageStream name, label and field selectors, and returns the list of Secrets that match those selectors.
func (c *imageStreams) Secrets(imageStreamName string, opts v1.ListOptions) (result *api.SecretList, err error) {
result = &api.SecretList{}
err = c.client.Get().
Namespace(c.ns).
Resource("imagestreams").
Name(imageStreamName).
SubResource("secrets").
VersionedParams(&opts, scheme.ParameterCodec).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sttts @deads2k we don't have this in legacy client, not sure if it is needed or just missing in legacy.

Do().
Into(result)
return
}
Loading