Merge pull request #3595 from jwcesign/centralized-hpa-api

cleanup: genertate the necessary code for federatedhpa and fix typo
This commit is contained in:
karmada-bot 2023-05-29 15:55:16 +08:00 committed by GitHub
commit 66275b1c9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 716 additions and 26 deletions

View File

@ -42,7 +42,7 @@ spec:
metadata:
type: object
spec:
description: Spec is the specification of the HPAAggregator.
description: Spec is the specification of the FederatedHPASpec.
properties:
behavior:
description: Behavior configures the scaling behavior of the target
@ -668,7 +668,7 @@ spec:
- scaleTargetRef
type: object
status:
description: Status is the current status of the HPAAggregator.
description: Status is the current status of the FederatedHPA.
properties:
conditions:
description: conditions is the set of conditions required for this

View File

@ -155,17 +155,12 @@ conversion-gen \
--input-dirs=github.com/karmada-io/karmada/pkg/apis/search/v1alpha1 \
--output-package=github.com/karmada-io/karmada/pkg/apis/search/v1alpha1 \
--output-file-base=zz_generated.conversion
conversion-gen \
--go-header-file hack/boilerplate/boilerplate.go.txt \
--input-dirs=github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1 \
--output-package=github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1 \
--output-file-base=zz_generated.conversion
echo "Generating with client-gen"
client-gen \
--go-header-file hack/boilerplate/boilerplate.go.txt \
--input-base="" \
--input=github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1,github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha2,github.com/karmada-io/karmada/pkg/apis/config/v1alpha1,github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1,github.com/karmada-io/karmada/pkg/apis/search/v1alpha1 \
--input=github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1,github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha2,github.com/karmada-io/karmada/pkg/apis/config/v1alpha1,github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1,github.com/karmada-io/karmada/pkg/apis/search/v1alpha1,github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1 \
--output-package=github.com/karmada-io/karmada/pkg/generated/clientset \
--clientset-name=versioned
client-gen \
@ -178,7 +173,7 @@ client-gen \
echo "Generating with lister-gen"
lister-gen \
--go-header-file hack/boilerplate/boilerplate.go.txt \
--input-dirs=github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1,github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha2,github.com/karmada-io/karmada/pkg/apis/config/v1alpha1,github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1,github.com/karmada-io/karmada/pkg/apis/search/v1alpha1 \
--input-dirs=github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1,github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha2,github.com/karmada-io/karmada/pkg/apis/config/v1alpha1,github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1,github.com/karmada-io/karmada/pkg/apis/search/v1alpha1,github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1 \
--output-package=github.com/karmada-io/karmada/pkg/generated/listers
lister-gen \
--go-header-file hack/boilerplate/boilerplate.go.txt \
@ -188,7 +183,7 @@ lister-gen \
echo "Generating with informer-gen"
informer-gen \
--go-header-file hack/boilerplate/boilerplate.go.txt \
--input-dirs=github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1,github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha2,github.com/karmada-io/karmada/pkg/apis/config/v1alpha1,github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1,github.com/karmada-io/karmada/pkg/apis/search/v1alpha1 \
--input-dirs=github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1,github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha1,github.com/karmada-io/karmada/pkg/apis/work/v1alpha2,github.com/karmada-io/karmada/pkg/apis/config/v1alpha1,github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1,github.com/karmada-io/karmada/pkg/apis/search/v1alpha1,github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1 \
--versioned-clientset-package=github.com/karmada-io/karmada/pkg/generated/clientset/versioned \
--listers-package=github.com/karmada-io/karmada/pkg/generated/listers \
--output-package=github.com/karmada-io/karmada/pkg/generated/informers

View File

@ -17,16 +17,16 @@ type FederatedHPA struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec is the specification of the HPAAggregator.
// Spec is the specification of the FederatedHPASpec.
// +required
Spec FederatedHPASpec `json:"spec"`
// Status is the current status of the HPAAggregator.
// Status is the current status of the FederatedHPA.
// +optional
Status autoscalingv2.HorizontalPodAutoscalerStatus `json:"status"`
}
// FederatedHPASpec describes the desired functionality of the HPAAggregator.
// FederatedHPASpec describes the desired functionality of the FederatedHPA.
type FederatedHPASpec struct {
// ScaleTargetRef points to the target resource to scale, and is used to
// the pods for which metrics should be collected, as well as to actually

View File

@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
autoscalingv1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/autoscaling/v1alpha1"
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/cluster/v1alpha1"
configv1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/config/v1alpha1"
networkingv1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/networking/v1alpha1"
@ -20,6 +21,7 @@ import (
type Interface interface {
Discovery() discovery.DiscoveryInterface
AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface
ClusterV1alpha1() clusterv1alpha1.ClusterV1alpha1Interface
ConfigV1alpha1() configv1alpha1.ConfigV1alpha1Interface
NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface
@ -32,13 +34,19 @@ type Interface interface {
// Clientset contains the clients for groups.
type Clientset struct {
*discovery.DiscoveryClient
clusterV1alpha1 *clusterv1alpha1.ClusterV1alpha1Client
configV1alpha1 *configv1alpha1.ConfigV1alpha1Client
networkingV1alpha1 *networkingv1alpha1.NetworkingV1alpha1Client
policyV1alpha1 *policyv1alpha1.PolicyV1alpha1Client
searchV1alpha1 *searchv1alpha1.SearchV1alpha1Client
workV1alpha1 *workv1alpha1.WorkV1alpha1Client
workV1alpha2 *workv1alpha2.WorkV1alpha2Client
autoscalingV1alpha1 *autoscalingv1alpha1.AutoscalingV1alpha1Client
clusterV1alpha1 *clusterv1alpha1.ClusterV1alpha1Client
configV1alpha1 *configv1alpha1.ConfigV1alpha1Client
networkingV1alpha1 *networkingv1alpha1.NetworkingV1alpha1Client
policyV1alpha1 *policyv1alpha1.PolicyV1alpha1Client
searchV1alpha1 *searchv1alpha1.SearchV1alpha1Client
workV1alpha1 *workv1alpha1.WorkV1alpha1Client
workV1alpha2 *workv1alpha2.WorkV1alpha2Client
}
// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client
func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface {
return c.autoscalingV1alpha1
}
// ClusterV1alpha1 retrieves the ClusterV1alpha1Client
@ -120,6 +128,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset,
var cs Clientset
var err error
cs.autoscalingV1alpha1, err = autoscalingv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
cs.clusterV1alpha1, err = clusterv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
@ -169,6 +181,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
// New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.autoscalingV1alpha1 = autoscalingv1alpha1.New(c)
cs.clusterV1alpha1 = clusterv1alpha1.New(c)
cs.configV1alpha1 = configv1alpha1.New(c)
cs.networkingV1alpha1 = networkingv1alpha1.New(c)

View File

@ -4,6 +4,8 @@ package fake
import (
clientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned"
autoscalingv1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/autoscaling/v1alpha1"
fakeautoscalingv1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/autoscaling/v1alpha1/fake"
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/cluster/v1alpha1"
fakeclusterv1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/cluster/v1alpha1/fake"
configv1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/config/v1alpha1"
@ -75,6 +77,11 @@ var (
_ testing.FakeClient = &Clientset{}
)
// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client
func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface {
return &fakeautoscalingv1alpha1.FakeAutoscalingV1alpha1{Fake: &c.Fake}
}
// ClusterV1alpha1 retrieves the ClusterV1alpha1Client
func (c *Clientset) ClusterV1alpha1() clusterv1alpha1.ClusterV1alpha1Interface {
return &fakeclusterv1alpha1.FakeClusterV1alpha1{Fake: &c.Fake}

View File

@ -3,6 +3,7 @@
package fake
import (
autoscalingv1alpha1 "github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1"
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
configv1alpha1 "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1"
networkingv1alpha1 "github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1"
@ -21,6 +22,7 @@ var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
autoscalingv1alpha1.AddToScheme,
clusterv1alpha1.AddToScheme,
configv1alpha1.AddToScheme,
networkingv1alpha1.AddToScheme,

View File

@ -3,6 +3,7 @@
package scheme
import (
autoscalingv1alpha1 "github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1"
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
configv1alpha1 "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1"
networkingv1alpha1 "github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1"
@ -21,6 +22,7 @@ var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
autoscalingv1alpha1.AddToScheme,
clusterv1alpha1.AddToScheme,
configv1alpha1.AddToScheme,
networkingv1alpha1.AddToScheme,

View File

@ -0,0 +1,91 @@
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"net/http"
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1"
"github.com/karmada-io/karmada/pkg/generated/clientset/versioned/scheme"
rest "k8s.io/client-go/rest"
)
type AutoscalingV1alpha1Interface interface {
RESTClient() rest.Interface
FederatedHPAsGetter
}
// AutoscalingV1alpha1Client is used to interact with features provided by the autoscaling.karmada.io group.
type AutoscalingV1alpha1Client struct {
restClient rest.Interface
}
func (c *AutoscalingV1alpha1Client) FederatedHPAs(namespace string) FederatedHPAInterface {
return newFederatedHPAs(c, namespace)
}
// NewForConfig creates a new AutoscalingV1alpha1Client for the given config.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).
func NewForConfig(c *rest.Config) (*AutoscalingV1alpha1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
httpClient, err := rest.HTTPClientFor(&config)
if err != nil {
return nil, err
}
return NewForConfigAndClient(&config, httpClient)
}
// NewForConfigAndClient creates a new AutoscalingV1alpha1Client for the given config and http client.
// Note the http client provided takes precedence over the configured transport values.
func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AutoscalingV1alpha1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientForConfigAndClient(&config, h)
if err != nil {
return nil, err
}
return &AutoscalingV1alpha1Client{client}, nil
}
// NewForConfigOrDie creates a new AutoscalingV1alpha1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *AutoscalingV1alpha1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new AutoscalingV1alpha1Client for the given RESTClient.
func New(c rest.Interface) *AutoscalingV1alpha1Client {
return &AutoscalingV1alpha1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1alpha1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *AutoscalingV1alpha1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@ -0,0 +1,4 @@
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v1alpha1

View File

@ -0,0 +1,4 @@
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake

View File

@ -0,0 +1,24 @@
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1alpha1 "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/typed/autoscaling/v1alpha1"
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
)
type FakeAutoscalingV1alpha1 struct {
*testing.Fake
}
func (c *FakeAutoscalingV1alpha1) FederatedHPAs(namespace string) v1alpha1.FederatedHPAInterface {
return &FakeFederatedHPAs{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeAutoscalingV1alpha1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@ -0,0 +1,126 @@
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeFederatedHPAs implements FederatedHPAInterface
type FakeFederatedHPAs struct {
Fake *FakeAutoscalingV1alpha1
ns string
}
var federatedhpasResource = schema.GroupVersionResource{Group: "autoscaling.karmada.io", Version: "v1alpha1", Resource: "federatedhpas"}
var federatedhpasKind = schema.GroupVersionKind{Group: "autoscaling.karmada.io", Version: "v1alpha1", Kind: "FederatedHPA"}
// Get takes name of the federatedHPA, and returns the corresponding federatedHPA object, and an error if there is any.
func (c *FakeFederatedHPAs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.FederatedHPA, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(federatedhpasResource, c.ns, name), &v1alpha1.FederatedHPA{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.FederatedHPA), err
}
// List takes label and field selectors, and returns the list of FederatedHPAs that match those selectors.
func (c *FakeFederatedHPAs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FederatedHPAList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(federatedhpasResource, federatedhpasKind, c.ns, opts), &v1alpha1.FederatedHPAList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.FederatedHPAList{ListMeta: obj.(*v1alpha1.FederatedHPAList).ListMeta}
for _, item := range obj.(*v1alpha1.FederatedHPAList).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 federatedHPAs.
func (c *FakeFederatedHPAs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(federatedhpasResource, c.ns, opts))
}
// Create takes the representation of a federatedHPA and creates it. Returns the server's representation of the federatedHPA, and an error, if there is any.
func (c *FakeFederatedHPAs) Create(ctx context.Context, federatedHPA *v1alpha1.FederatedHPA, opts v1.CreateOptions) (result *v1alpha1.FederatedHPA, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(federatedhpasResource, c.ns, federatedHPA), &v1alpha1.FederatedHPA{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.FederatedHPA), err
}
// Update takes the representation of a federatedHPA and updates it. Returns the server's representation of the federatedHPA, and an error, if there is any.
func (c *FakeFederatedHPAs) Update(ctx context.Context, federatedHPA *v1alpha1.FederatedHPA, opts v1.UpdateOptions) (result *v1alpha1.FederatedHPA, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(federatedhpasResource, c.ns, federatedHPA), &v1alpha1.FederatedHPA{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.FederatedHPA), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeFederatedHPAs) UpdateStatus(ctx context.Context, federatedHPA *v1alpha1.FederatedHPA, opts v1.UpdateOptions) (*v1alpha1.FederatedHPA, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(federatedhpasResource, "status", c.ns, federatedHPA), &v1alpha1.FederatedHPA{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.FederatedHPA), err
}
// Delete takes name of the federatedHPA and deletes it. Returns an error if one occurs.
func (c *FakeFederatedHPAs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteActionWithOptions(federatedhpasResource, c.ns, name, opts), &v1alpha1.FederatedHPA{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeFederatedHPAs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(federatedhpasResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.FederatedHPAList{})
return err
}
// Patch applies the patch and returns the patched federatedHPA.
func (c *FakeFederatedHPAs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.FederatedHPA, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(federatedhpasResource, c.ns, name, pt, data, subresources...), &v1alpha1.FederatedHPA{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.FederatedHPA), err
}

View File

@ -0,0 +1,179 @@
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
"time"
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1"
scheme "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/scheme"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// FederatedHPAsGetter has a method to return a FederatedHPAInterface.
// A group's client should implement this interface.
type FederatedHPAsGetter interface {
FederatedHPAs(namespace string) FederatedHPAInterface
}
// FederatedHPAInterface has methods to work with FederatedHPA resources.
type FederatedHPAInterface interface {
Create(ctx context.Context, federatedHPA *v1alpha1.FederatedHPA, opts v1.CreateOptions) (*v1alpha1.FederatedHPA, error)
Update(ctx context.Context, federatedHPA *v1alpha1.FederatedHPA, opts v1.UpdateOptions) (*v1alpha1.FederatedHPA, error)
UpdateStatus(ctx context.Context, federatedHPA *v1alpha1.FederatedHPA, opts v1.UpdateOptions) (*v1alpha1.FederatedHPA, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.FederatedHPA, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.FederatedHPAList, error)
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.FederatedHPA, err error)
FederatedHPAExpansion
}
// federatedHPAs implements FederatedHPAInterface
type federatedHPAs struct {
client rest.Interface
ns string
}
// newFederatedHPAs returns a FederatedHPAs
func newFederatedHPAs(c *AutoscalingV1alpha1Client, namespace string) *federatedHPAs {
return &federatedHPAs{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the federatedHPA, and returns the corresponding federatedHPA object, and an error if there is any.
func (c *federatedHPAs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.FederatedHPA, err error) {
result = &v1alpha1.FederatedHPA{}
err = c.client.Get().
Namespace(c.ns).
Resource("federatedhpas").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of FederatedHPAs that match those selectors.
func (c *federatedHPAs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FederatedHPAList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.FederatedHPAList{}
err = c.client.Get().
Namespace(c.ns).
Resource("federatedhpas").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested federatedHPAs.
func (c *federatedHPAs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("federatedhpas").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a federatedHPA and creates it. Returns the server's representation of the federatedHPA, and an error, if there is any.
func (c *federatedHPAs) Create(ctx context.Context, federatedHPA *v1alpha1.FederatedHPA, opts v1.CreateOptions) (result *v1alpha1.FederatedHPA, err error) {
result = &v1alpha1.FederatedHPA{}
err = c.client.Post().
Namespace(c.ns).
Resource("federatedhpas").
VersionedParams(&opts, scheme.ParameterCodec).
Body(federatedHPA).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a federatedHPA and updates it. Returns the server's representation of the federatedHPA, and an error, if there is any.
func (c *federatedHPAs) Update(ctx context.Context, federatedHPA *v1alpha1.FederatedHPA, opts v1.UpdateOptions) (result *v1alpha1.FederatedHPA, err error) {
result = &v1alpha1.FederatedHPA{}
err = c.client.Put().
Namespace(c.ns).
Resource("federatedhpas").
Name(federatedHPA.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(federatedHPA).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *federatedHPAs) UpdateStatus(ctx context.Context, federatedHPA *v1alpha1.FederatedHPA, opts v1.UpdateOptions) (result *v1alpha1.FederatedHPA, err error) {
result = &v1alpha1.FederatedHPA{}
err = c.client.Put().
Namespace(c.ns).
Resource("federatedhpas").
Name(federatedHPA.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(federatedHPA).
Do(ctx).
Into(result)
return
}
// Delete takes name of the federatedHPA and deletes it. Returns an error if one occurs.
func (c *federatedHPAs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("federatedhpas").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *federatedHPAs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("federatedhpas").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched federatedHPA.
func (c *federatedHPAs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.FederatedHPA, err error) {
result = &v1alpha1.FederatedHPA{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("federatedhpas").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -0,0 +1,5 @@
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
type FederatedHPAExpansion interface{}

View File

@ -0,0 +1,30 @@
// Code generated by informer-gen. DO NOT EDIT.
package autoscaling
import (
v1alpha1 "github.com/karmada-io/karmada/pkg/generated/informers/externalversions/autoscaling/v1alpha1"
internalinterfaces "github.com/karmada-io/karmada/pkg/generated/informers/externalversions/internalinterfaces"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// V1alpha1 provides access to shared informers for resources in V1alpha1.
V1alpha1() v1alpha1.Interface
}
type group struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// V1alpha1 returns a new v1alpha1.Interface.
func (g *group) V1alpha1() v1alpha1.Interface {
return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions)
}

View File

@ -0,0 +1,74 @@
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
time "time"
autoscalingv1alpha1 "github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1"
versioned "github.com/karmada-io/karmada/pkg/generated/clientset/versioned"
internalinterfaces "github.com/karmada-io/karmada/pkg/generated/informers/externalversions/internalinterfaces"
v1alpha1 "github.com/karmada-io/karmada/pkg/generated/listers/autoscaling/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// FederatedHPAInformer provides access to a shared informer and lister for
// FederatedHPAs.
type FederatedHPAInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.FederatedHPALister
}
type federatedHPAInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewFederatedHPAInformer constructs a new informer for FederatedHPA type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFederatedHPAInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredFederatedHPAInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredFederatedHPAInformer constructs a new informer for FederatedHPA type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredFederatedHPAInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AutoscalingV1alpha1().FederatedHPAs(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AutoscalingV1alpha1().FederatedHPAs(namespace).Watch(context.TODO(), options)
},
},
&autoscalingv1alpha1.FederatedHPA{},
resyncPeriod,
indexers,
)
}
func (f *federatedHPAInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredFederatedHPAInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *federatedHPAInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&autoscalingv1alpha1.FederatedHPA{}, f.defaultInformer)
}
func (f *federatedHPAInformer) Lister() v1alpha1.FederatedHPALister {
return v1alpha1.NewFederatedHPALister(f.Informer().GetIndexer())
}

View File

@ -0,0 +1,29 @@
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
internalinterfaces "github.com/karmada-io/karmada/pkg/generated/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// FederatedHPAs returns a FederatedHPAInformer.
FederatedHPAs() FederatedHPAInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// FederatedHPAs returns a FederatedHPAInformer.
func (v *version) FederatedHPAs() FederatedHPAInformer {
return &federatedHPAInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View File

@ -8,6 +8,7 @@ import (
time "time"
versioned "github.com/karmada-io/karmada/pkg/generated/clientset/versioned"
autoscaling "github.com/karmada-io/karmada/pkg/generated/informers/externalversions/autoscaling"
cluster "github.com/karmada-io/karmada/pkg/generated/informers/externalversions/cluster"
config "github.com/karmada-io/karmada/pkg/generated/informers/externalversions/config"
internalinterfaces "github.com/karmada-io/karmada/pkg/generated/informers/externalversions/internalinterfaces"
@ -232,6 +233,7 @@ type SharedInformerFactory interface {
// client.
InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer
Autoscaling() autoscaling.Interface
Cluster() cluster.Interface
Config() config.Interface
Networking() networking.Interface
@ -240,6 +242,10 @@ type SharedInformerFactory interface {
Work() work.Interface
}
func (f *sharedInformerFactory) Autoscaling() autoscaling.Interface {
return autoscaling.New(f, f.namespace, f.tweakListOptions)
}
func (f *sharedInformerFactory) Cluster() cluster.Interface {
return cluster.New(f, f.namespace, f.tweakListOptions)
}

View File

@ -5,7 +5,8 @@ package externalversions
import (
"fmt"
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1"
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
configv1alpha1 "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1"
networkingv1alpha1 "github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1"
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
@ -42,8 +43,12 @@ func (f *genericInformer) Lister() cache.GenericLister {
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=cluster.karmada.io, Version=v1alpha1
case v1alpha1.SchemeGroupVersion.WithResource("clusters"):
// Group=autoscaling.karmada.io, Version=v1alpha1
case v1alpha1.SchemeGroupVersion.WithResource("federatedhpas"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().FederatedHPAs().Informer()}, nil
// Group=cluster.karmada.io, Version=v1alpha1
case clusterv1alpha1.SchemeGroupVersion.WithResource("clusters"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().Clusters().Informer()}, nil
// Group=config.karmada.io, Version=v1alpha1

View File

@ -0,0 +1,11 @@
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
// FederatedHPAListerExpansion allows custom methods to be added to
// FederatedHPALister.
type FederatedHPAListerExpansion interface{}
// FederatedHPANamespaceListerExpansion allows custom methods to be added to
// FederatedHPANamespaceLister.
type FederatedHPANamespaceListerExpansion interface{}

View File

@ -0,0 +1,83 @@
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// FederatedHPALister helps list FederatedHPAs.
// All objects returned here must be treated as read-only.
type FederatedHPALister interface {
// List lists all FederatedHPAs in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.FederatedHPA, err error)
// FederatedHPAs returns an object that can list and get FederatedHPAs.
FederatedHPAs(namespace string) FederatedHPANamespaceLister
FederatedHPAListerExpansion
}
// federatedHPALister implements the FederatedHPALister interface.
type federatedHPALister struct {
indexer cache.Indexer
}
// NewFederatedHPALister returns a new FederatedHPALister.
func NewFederatedHPALister(indexer cache.Indexer) FederatedHPALister {
return &federatedHPALister{indexer: indexer}
}
// List lists all FederatedHPAs in the indexer.
func (s *federatedHPALister) List(selector labels.Selector) (ret []*v1alpha1.FederatedHPA, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.FederatedHPA))
})
return ret, err
}
// FederatedHPAs returns an object that can list and get FederatedHPAs.
func (s *federatedHPALister) FederatedHPAs(namespace string) FederatedHPANamespaceLister {
return federatedHPANamespaceLister{indexer: s.indexer, namespace: namespace}
}
// FederatedHPANamespaceLister helps list and get FederatedHPAs.
// All objects returned here must be treated as read-only.
type FederatedHPANamespaceLister interface {
// List lists all FederatedHPAs in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.FederatedHPA, err error)
// Get retrieves the FederatedHPA from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha1.FederatedHPA, error)
FederatedHPANamespaceListerExpansion
}
// federatedHPANamespaceLister implements the FederatedHPANamespaceLister
// interface.
type federatedHPANamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all FederatedHPAs in the indexer for a given namespace.
func (s federatedHPANamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.FederatedHPA, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.FederatedHPA))
})
return ret, err
}
// Get retrieves the FederatedHPA from the indexer for a given namespace and name.
func (s federatedHPANamespaceLister) Get(name string) (*v1alpha1.FederatedHPA, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("federatedhpa"), name)
}
return obj.(*v1alpha1.FederatedHPA), nil
}

View File

@ -510,14 +510,14 @@ func schema_pkg_apis_autoscaling_v1alpha1_FederatedHPA(ref common.ReferenceCallb
},
"spec": {
SchemaProps: spec.SchemaProps{
Description: "Spec is the specification of the HPAAggregator.",
Description: "Spec is the specification of the FederatedHPASpec.",
Default: map[string]interface{}{},
Ref: ref("github.com/karmada-io/karmada/pkg/apis/autoscaling/v1alpha1.FederatedHPASpec"),
},
},
"status": {
SchemaProps: spec.SchemaProps{
Description: "Status is the current status of the HPAAggregator.",
Description: "Status is the current status of the FederatedHPA.",
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/autoscaling/v2.HorizontalPodAutoscalerStatus"),
},
@ -584,7 +584,7 @@ func schema_pkg_apis_autoscaling_v1alpha1_FederatedHPASpec(ref common.ReferenceC
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "FederatedHPASpec describes the desired functionality of the HPAAggregator.",
Description: "FederatedHPASpec describes the desired functionality of the FederatedHPA.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"scaleTargetRef": {