From c61378d98e43d090b62feeb1b6aa40aa3ee0b928 Mon Sep 17 00:00:00 2001 From: Calum Murray Date: Fri, 10 Jan 2025 05:48:17 -0500 Subject: [PATCH] feat: add updatescale method to generated clients for consumergroups (#4207) Signed-off-by: Cali0707 --- .../v1alpha1/consumer_group_types.go | 2 ++ .../v1alpha1/consumergroup.go | 16 ++++++++++++++++ .../v1alpha1/fake/fake_consumergroup.go | 11 +++++++++++ 3 files changed, 29 insertions(+) diff --git a/control-plane/pkg/apis/internalskafkaeventing/v1alpha1/consumer_group_types.go b/control-plane/pkg/apis/internalskafkaeventing/v1alpha1/consumer_group_types.go index 2e0632e3d0..33d7ad73d4 100644 --- a/control-plane/pkg/apis/internalskafkaeventing/v1alpha1/consumer_group_types.go +++ b/control-plane/pkg/apis/internalskafkaeventing/v1alpha1/consumer_group_types.go @@ -32,6 +32,8 @@ import ( // +genclient // +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/api/autoscaling/v1.Scale +// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale +// +genclient:method=ApplyScale,verb=apply,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale // +genreconciler // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/control-plane/pkg/client/clientset/versioned/typed/internalskafkaeventing/v1alpha1/consumergroup.go b/control-plane/pkg/client/clientset/versioned/typed/internalskafkaeventing/v1alpha1/consumergroup.go index 3c5023cf31..28356d49ed 100644 --- a/control-plane/pkg/client/clientset/versioned/typed/internalskafkaeventing/v1alpha1/consumergroup.go +++ b/control-plane/pkg/client/clientset/versioned/typed/internalskafkaeventing/v1alpha1/consumergroup.go @@ -49,6 +49,7 @@ type ConsumerGroupInterface interface { Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ConsumerGroup, err error) GetScale(ctx context.Context, consumerGroupName string, options v1.GetOptions) (*autoscalingv1.Scale, error) + UpdateScale(ctx context.Context, consumerGroupName string, scale *autoscalingv1.Scale, opts v1.UpdateOptions) (*autoscalingv1.Scale, error) ConsumerGroupExpansion } @@ -210,3 +211,18 @@ func (c *consumerGroups) GetScale(ctx context.Context, consumerGroupName string, 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 *consumerGroups) UpdateScale(ctx context.Context, consumerGroupName string, scale *autoscalingv1.Scale, opts v1.UpdateOptions) (result *autoscalingv1.Scale, err error) { + result = &autoscalingv1.Scale{} + err = c.client.Put(). + Namespace(c.ns). + Resource("consumergroups"). + Name(consumerGroupName). + SubResource("scale"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(scale). + Do(ctx). + Into(result) + return +} diff --git a/control-plane/pkg/client/clientset/versioned/typed/internalskafkaeventing/v1alpha1/fake/fake_consumergroup.go b/control-plane/pkg/client/clientset/versioned/typed/internalskafkaeventing/v1alpha1/fake/fake_consumergroup.go index 4bb56e24e7..493118e429 100644 --- a/control-plane/pkg/client/clientset/versioned/typed/internalskafkaeventing/v1alpha1/fake/fake_consumergroup.go +++ b/control-plane/pkg/client/clientset/versioned/typed/internalskafkaeventing/v1alpha1/fake/fake_consumergroup.go @@ -151,3 +151,14 @@ func (c *FakeConsumerGroups) GetScale(ctx context.Context, consumerGroupName str } return obj.(*autoscalingv1.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 *FakeConsumerGroups) UpdateScale(ctx context.Context, consumerGroupName string, scale *autoscalingv1.Scale, opts v1.UpdateOptions) (result *autoscalingv1.Scale, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(consumergroupsResource, "scale", c.ns, scale), &autoscalingv1.Scale{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingv1.Scale), err +}