Merge pull request #2639 from RainbowMango/pr_resourceinterpreter_customization_api

Add configurable resource interpreter API
This commit is contained in:
karmada-bot 2022-10-18 17:05:14 +08:00 committed by GitHub
commit eb0c6552df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 1125 additions and 313 deletions

View File

@ -0,0 +1,83 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: resourceinterpretercustomizations.config.karmada.io
spec:
group: config.karmada.io
names:
kind: ResourceInterpreterCustomization
listKind: ResourceInterpreterCustomizationList
plural: resourceinterpretercustomizations
singular: resourceinterpretercustomization
scope: Cluster
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ResourceInterpreterCustomization describes the configuration
of a specific resource for Karmada to get the structure. It has higher precedence
than the default interpreter and the interpreter webhook.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec describes the configuration in detail.
properties:
apiVersion:
description: APIVersion represents the API version of the target resource.
type: string
kind:
description: Kind represents the Kind of target resources.
type: string
retention:
description: Retention describes the desired behavior that karmada
should react on the changes made by member cluster components. This
avoids system running into a meaningless loop that Karmada resource
controller and the member cluster component continually applying
opposite values of a field. For example, the "replicas" of Deployment
might be changed by the HPA controller on member cluster. In this
case, Karmada should retain the "replicas" and not try to change
it.
properties:
retentionLua:
description: "RetentionLua holds the Lua script that is used to
retain runtime values to the desired specification. The script
should implement a function as follows: retentionLua: > function
Retain(desiredObj, observedObj) desiredObj.spec.fieldFoo = observedObj.spec.fieldFoo
return desiredObj end \n RetentionLua only holds the function
body part, take the `desiredObj` and `observedObj` as the function
parameters or global variables, and finally returns a retained
specification."
type: string
required:
- retentionLua
type: object
required:
- apiVersion
- kind
type: object
required:
- spec
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@ -0,0 +1,70 @@
package v1alpha1
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:storageversion
// ResourceInterpreterCustomization describes the configuration of a specific
// resource for Karmada to get the structure.
// It has higher precedence than the default interpreter and the interpreter
// webhook.
type ResourceInterpreterCustomization struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec describes the configuration in detail.
// +required
Spec ResourceInterpreterCustomizationSpec `json:"spec"`
}
// ResourceInterpreterCustomizationSpec describes the configuration in detail.
type ResourceInterpreterCustomizationSpec struct {
// APIVersion represents the API version of the target resource.
// +required
APIVersion string `json:"apiVersion"`
// Kind represents the Kind of target resources.
// +required
Kind string `json:"kind"`
// Retention describes the desired behavior that karmada should react on
// the changes made by member cluster components. This avoids system
// running into a meaningless loop that Karmada resource controller and
// the member cluster component continually applying opposite values of a field.
// For example, the "replicas" of Deployment might be changed by the HPA
// controller on member cluster. In this case, Karmada should retain the "replicas"
// and not try to change it.
// +optional
Retention LocalValueRetention `json:"retention,omitempty"`
}
// LocalValueRetention holds the scripts for retention.
// Now only supports Lua.
type LocalValueRetention struct {
// RetentionLua holds the Lua script that is used to retain runtime values to the desired specification.
// The script should implement a function as follows:
// retentionLua: >
// function Retain(desiredObj, observedObj)
// desiredObj.spec.fieldFoo = observedObj.spec.fieldFoo
// return desiredObj
// end
//
// RetentionLua only holds the function body part, take the `desiredObj` and `observedObj` as the function
// parameters or global variables, and finally returns a retained specification.
// +required
RetentionLua string `json:"retentionLua"`
}
// +kubebuilder:resource:scope="Cluster"
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ResourceInterpreterCustomizationList contains a list of ResourceInterpreterCustomization.
type ResourceInterpreterCustomizationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ResourceInterpreterCustomization `json:"items"`
}

View File

@ -26,6 +26,22 @@ func (in *DependentObjectReference) DeepCopy() *DependentObjectReference {
return out return out
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LocalValueRetention) DeepCopyInto(out *LocalValueRetention) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalValueRetention.
func (in *LocalValueRetention) DeepCopy() *LocalValueRetention {
if in == nil {
return nil
}
out := new(LocalValueRetention)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RequestStatus) DeepCopyInto(out *RequestStatus) { func (in *RequestStatus) DeepCopyInto(out *RequestStatus) {
*out = *in *out = *in
@ -77,6 +93,83 @@ func (in *ResourceInterpreterContext) DeepCopyObject() runtime.Object {
return nil return nil
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceInterpreterCustomization) DeepCopyInto(out *ResourceInterpreterCustomization) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceInterpreterCustomization.
func (in *ResourceInterpreterCustomization) DeepCopy() *ResourceInterpreterCustomization {
if in == nil {
return nil
}
out := new(ResourceInterpreterCustomization)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceInterpreterCustomization) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceInterpreterCustomizationList) DeepCopyInto(out *ResourceInterpreterCustomizationList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ResourceInterpreterCustomization, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceInterpreterCustomizationList.
func (in *ResourceInterpreterCustomizationList) DeepCopy() *ResourceInterpreterCustomizationList {
if in == nil {
return nil
}
out := new(ResourceInterpreterCustomizationList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceInterpreterCustomizationList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceInterpreterCustomizationSpec) DeepCopyInto(out *ResourceInterpreterCustomizationSpec) {
*out = *in
out.Retention = in.Retention
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceInterpreterCustomizationSpec.
func (in *ResourceInterpreterCustomizationSpec) DeepCopy() *ResourceInterpreterCustomizationSpec {
if in == nil {
return nil
}
out := new(ResourceInterpreterCustomizationSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceInterpreterRequest) DeepCopyInto(out *ResourceInterpreterRequest) { func (in *ResourceInterpreterRequest) DeepCopyInto(out *ResourceInterpreterRequest) {
*out = *in *out = *in

View File

@ -43,6 +43,8 @@ func init() {
func addKnownTypes(scheme *runtime.Scheme) error { func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion, scheme.AddKnownTypes(SchemeGroupVersion,
&ResourceInterpreterContext{}, &ResourceInterpreterContext{},
&ResourceInterpreterCustomization{},
&ResourceInterpreterCustomizationList{},
&ResourceInterpreterWebhookConfiguration{}, &ResourceInterpreterWebhookConfiguration{},
&ResourceInterpreterWebhookConfigurationList{}, &ResourceInterpreterWebhookConfigurationList{},
) )

View File

@ -12,6 +12,7 @@ import (
type ConfigV1alpha1Interface interface { type ConfigV1alpha1Interface interface {
RESTClient() rest.Interface RESTClient() rest.Interface
ResourceInterpreterCustomizationsGetter
ResourceInterpreterWebhookConfigurationsGetter ResourceInterpreterWebhookConfigurationsGetter
} }
@ -20,6 +21,10 @@ type ConfigV1alpha1Client struct {
restClient rest.Interface restClient rest.Interface
} }
func (c *ConfigV1alpha1Client) ResourceInterpreterCustomizations() ResourceInterpreterCustomizationInterface {
return newResourceInterpreterCustomizations(c)
}
func (c *ConfigV1alpha1Client) ResourceInterpreterWebhookConfigurations() ResourceInterpreterWebhookConfigurationInterface { func (c *ConfigV1alpha1Client) ResourceInterpreterWebhookConfigurations() ResourceInterpreterWebhookConfigurationInterface {
return newResourceInterpreterWebhookConfigurations(c) return newResourceInterpreterWebhookConfigurations(c)
} }

View File

@ -12,6 +12,10 @@ type FakeConfigV1alpha1 struct {
*testing.Fake *testing.Fake
} }
func (c *FakeConfigV1alpha1) ResourceInterpreterCustomizations() v1alpha1.ResourceInterpreterCustomizationInterface {
return &FakeResourceInterpreterCustomizations{c}
}
func (c *FakeConfigV1alpha1) ResourceInterpreterWebhookConfigurations() v1alpha1.ResourceInterpreterWebhookConfigurationInterface { func (c *FakeConfigV1alpha1) ResourceInterpreterWebhookConfigurations() v1alpha1.ResourceInterpreterWebhookConfigurationInterface {
return &FakeResourceInterpreterWebhookConfigurations{c} return &FakeResourceInterpreterWebhookConfigurations{c}
} }

View File

@ -0,0 +1,106 @@
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/config/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"
)
// FakeResourceInterpreterCustomizations implements ResourceInterpreterCustomizationInterface
type FakeResourceInterpreterCustomizations struct {
Fake *FakeConfigV1alpha1
}
var resourceinterpretercustomizationsResource = schema.GroupVersionResource{Group: "config.karmada.io", Version: "v1alpha1", Resource: "resourceinterpretercustomizations"}
var resourceinterpretercustomizationsKind = schema.GroupVersionKind{Group: "config.karmada.io", Version: "v1alpha1", Kind: "ResourceInterpreterCustomization"}
// Get takes name of the resourceInterpreterCustomization, and returns the corresponding resourceInterpreterCustomization object, and an error if there is any.
func (c *FakeResourceInterpreterCustomizations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ResourceInterpreterCustomization, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(resourceinterpretercustomizationsResource, name), &v1alpha1.ResourceInterpreterCustomization{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ResourceInterpreterCustomization), err
}
// List takes label and field selectors, and returns the list of ResourceInterpreterCustomizations that match those selectors.
func (c *FakeResourceInterpreterCustomizations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ResourceInterpreterCustomizationList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(resourceinterpretercustomizationsResource, resourceinterpretercustomizationsKind, opts), &v1alpha1.ResourceInterpreterCustomizationList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.ResourceInterpreterCustomizationList{ListMeta: obj.(*v1alpha1.ResourceInterpreterCustomizationList).ListMeta}
for _, item := range obj.(*v1alpha1.ResourceInterpreterCustomizationList).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 resourceInterpreterCustomizations.
func (c *FakeResourceInterpreterCustomizations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(resourceinterpretercustomizationsResource, opts))
}
// Create takes the representation of a resourceInterpreterCustomization and creates it. Returns the server's representation of the resourceInterpreterCustomization, and an error, if there is any.
func (c *FakeResourceInterpreterCustomizations) Create(ctx context.Context, resourceInterpreterCustomization *v1alpha1.ResourceInterpreterCustomization, opts v1.CreateOptions) (result *v1alpha1.ResourceInterpreterCustomization, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(resourceinterpretercustomizationsResource, resourceInterpreterCustomization), &v1alpha1.ResourceInterpreterCustomization{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ResourceInterpreterCustomization), err
}
// Update takes the representation of a resourceInterpreterCustomization and updates it. Returns the server's representation of the resourceInterpreterCustomization, and an error, if there is any.
func (c *FakeResourceInterpreterCustomizations) Update(ctx context.Context, resourceInterpreterCustomization *v1alpha1.ResourceInterpreterCustomization, opts v1.UpdateOptions) (result *v1alpha1.ResourceInterpreterCustomization, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(resourceinterpretercustomizationsResource, resourceInterpreterCustomization), &v1alpha1.ResourceInterpreterCustomization{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ResourceInterpreterCustomization), err
}
// Delete takes name of the resourceInterpreterCustomization and deletes it. Returns an error if one occurs.
func (c *FakeResourceInterpreterCustomizations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteActionWithOptions(resourceinterpretercustomizationsResource, name, opts), &v1alpha1.ResourceInterpreterCustomization{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeResourceInterpreterCustomizations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(resourceinterpretercustomizationsResource, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.ResourceInterpreterCustomizationList{})
return err
}
// Patch applies the patch and returns the patched resourceInterpreterCustomization.
func (c *FakeResourceInterpreterCustomizations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ResourceInterpreterCustomization, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(resourceinterpretercustomizationsResource, name, pt, data, subresources...), &v1alpha1.ResourceInterpreterCustomization{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.ResourceInterpreterCustomization), err
}

View File

@ -2,4 +2,6 @@
package v1alpha1 package v1alpha1
type ResourceInterpreterCustomizationExpansion interface{}
type ResourceInterpreterWebhookConfigurationExpansion interface{} type ResourceInterpreterWebhookConfigurationExpansion interface{}

View File

@ -0,0 +1,152 @@
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
"time"
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/config/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"
)
// ResourceInterpreterCustomizationsGetter has a method to return a ResourceInterpreterCustomizationInterface.
// A group's client should implement this interface.
type ResourceInterpreterCustomizationsGetter interface {
ResourceInterpreterCustomizations() ResourceInterpreterCustomizationInterface
}
// ResourceInterpreterCustomizationInterface has methods to work with ResourceInterpreterCustomization resources.
type ResourceInterpreterCustomizationInterface interface {
Create(ctx context.Context, resourceInterpreterCustomization *v1alpha1.ResourceInterpreterCustomization, opts v1.CreateOptions) (*v1alpha1.ResourceInterpreterCustomization, error)
Update(ctx context.Context, resourceInterpreterCustomization *v1alpha1.ResourceInterpreterCustomization, opts v1.UpdateOptions) (*v1alpha1.ResourceInterpreterCustomization, 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.ResourceInterpreterCustomization, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ResourceInterpreterCustomizationList, 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.ResourceInterpreterCustomization, err error)
ResourceInterpreterCustomizationExpansion
}
// resourceInterpreterCustomizations implements ResourceInterpreterCustomizationInterface
type resourceInterpreterCustomizations struct {
client rest.Interface
}
// newResourceInterpreterCustomizations returns a ResourceInterpreterCustomizations
func newResourceInterpreterCustomizations(c *ConfigV1alpha1Client) *resourceInterpreterCustomizations {
return &resourceInterpreterCustomizations{
client: c.RESTClient(),
}
}
// Get takes name of the resourceInterpreterCustomization, and returns the corresponding resourceInterpreterCustomization object, and an error if there is any.
func (c *resourceInterpreterCustomizations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ResourceInterpreterCustomization, err error) {
result = &v1alpha1.ResourceInterpreterCustomization{}
err = c.client.Get().
Resource("resourceinterpretercustomizations").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of ResourceInterpreterCustomizations that match those selectors.
func (c *resourceInterpreterCustomizations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ResourceInterpreterCustomizationList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.ResourceInterpreterCustomizationList{}
err = c.client.Get().
Resource("resourceinterpretercustomizations").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested resourceInterpreterCustomizations.
func (c *resourceInterpreterCustomizations) 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().
Resource("resourceinterpretercustomizations").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a resourceInterpreterCustomization and creates it. Returns the server's representation of the resourceInterpreterCustomization, and an error, if there is any.
func (c *resourceInterpreterCustomizations) Create(ctx context.Context, resourceInterpreterCustomization *v1alpha1.ResourceInterpreterCustomization, opts v1.CreateOptions) (result *v1alpha1.ResourceInterpreterCustomization, err error) {
result = &v1alpha1.ResourceInterpreterCustomization{}
err = c.client.Post().
Resource("resourceinterpretercustomizations").
VersionedParams(&opts, scheme.ParameterCodec).
Body(resourceInterpreterCustomization).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a resourceInterpreterCustomization and updates it. Returns the server's representation of the resourceInterpreterCustomization, and an error, if there is any.
func (c *resourceInterpreterCustomizations) Update(ctx context.Context, resourceInterpreterCustomization *v1alpha1.ResourceInterpreterCustomization, opts v1.UpdateOptions) (result *v1alpha1.ResourceInterpreterCustomization, err error) {
result = &v1alpha1.ResourceInterpreterCustomization{}
err = c.client.Put().
Resource("resourceinterpretercustomizations").
Name(resourceInterpreterCustomization.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(resourceInterpreterCustomization).
Do(ctx).
Into(result)
return
}
// Delete takes name of the resourceInterpreterCustomization and deletes it. Returns an error if one occurs.
func (c *resourceInterpreterCustomizations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Resource("resourceinterpretercustomizations").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *resourceInterpreterCustomizations) 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().
Resource("resourceinterpretercustomizations").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched resourceInterpreterCustomization.
func (c *resourceInterpreterCustomizations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ResourceInterpreterCustomization, err error) {
result = &v1alpha1.ResourceInterpreterCustomization{}
err = c.client.Patch(pt).
Resource("resourceinterpretercustomizations").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -8,6 +8,8 @@ import (
// Interface provides access to all the informers in this group version. // Interface provides access to all the informers in this group version.
type Interface interface { type Interface interface {
// ResourceInterpreterCustomizations returns a ResourceInterpreterCustomizationInformer.
ResourceInterpreterCustomizations() ResourceInterpreterCustomizationInformer
// ResourceInterpreterWebhookConfigurations returns a ResourceInterpreterWebhookConfigurationInformer. // ResourceInterpreterWebhookConfigurations returns a ResourceInterpreterWebhookConfigurationInformer.
ResourceInterpreterWebhookConfigurations() ResourceInterpreterWebhookConfigurationInformer ResourceInterpreterWebhookConfigurations() ResourceInterpreterWebhookConfigurationInformer
} }
@ -23,6 +25,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
} }
// ResourceInterpreterCustomizations returns a ResourceInterpreterCustomizationInformer.
func (v *version) ResourceInterpreterCustomizations() ResourceInterpreterCustomizationInformer {
return &resourceInterpreterCustomizationInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// ResourceInterpreterWebhookConfigurations returns a ResourceInterpreterWebhookConfigurationInformer. // ResourceInterpreterWebhookConfigurations returns a ResourceInterpreterWebhookConfigurationInformer.
func (v *version) ResourceInterpreterWebhookConfigurations() ResourceInterpreterWebhookConfigurationInformer { func (v *version) ResourceInterpreterWebhookConfigurations() ResourceInterpreterWebhookConfigurationInformer {
return &resourceInterpreterWebhookConfigurationInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} return &resourceInterpreterWebhookConfigurationInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}

View File

@ -0,0 +1,73 @@
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
time "time"
configv1alpha1 "github.com/karmada-io/karmada/pkg/apis/config/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/config/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"
)
// ResourceInterpreterCustomizationInformer provides access to a shared informer and lister for
// ResourceInterpreterCustomizations.
type ResourceInterpreterCustomizationInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.ResourceInterpreterCustomizationLister
}
type resourceInterpreterCustomizationInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// NewResourceInterpreterCustomizationInformer constructs a new informer for ResourceInterpreterCustomization 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 NewResourceInterpreterCustomizationInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredResourceInterpreterCustomizationInformer(client, resyncPeriod, indexers, nil)
}
// NewFilteredResourceInterpreterCustomizationInformer constructs a new informer for ResourceInterpreterCustomization 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 NewFilteredResourceInterpreterCustomizationInformer(client versioned.Interface, 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.ConfigV1alpha1().ResourceInterpreterCustomizations().List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ConfigV1alpha1().ResourceInterpreterCustomizations().Watch(context.TODO(), options)
},
},
&configv1alpha1.ResourceInterpreterCustomization{},
resyncPeriod,
indexers,
)
}
func (f *resourceInterpreterCustomizationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredResourceInterpreterCustomizationInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *resourceInterpreterCustomizationInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&configv1alpha1.ResourceInterpreterCustomization{}, f.defaultInformer)
}
func (f *resourceInterpreterCustomizationInformer) Lister() v1alpha1.ResourceInterpreterCustomizationLister {
return v1alpha1.NewResourceInterpreterCustomizationLister(f.Informer().GetIndexer())
}

View File

@ -47,6 +47,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().Clusters().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().Clusters().Informer()}, nil
// Group=config.karmada.io, Version=v1alpha1 // Group=config.karmada.io, Version=v1alpha1
case configv1alpha1.SchemeGroupVersion.WithResource("resourceinterpretercustomizations"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Config().V1alpha1().ResourceInterpreterCustomizations().Informer()}, nil
case configv1alpha1.SchemeGroupVersion.WithResource("resourceinterpreterwebhookconfigurations"): case configv1alpha1.SchemeGroupVersion.WithResource("resourceinterpreterwebhookconfigurations"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Config().V1alpha1().ResourceInterpreterWebhookConfigurations().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Config().V1alpha1().ResourceInterpreterWebhookConfigurations().Informer()}, nil

View File

@ -2,6 +2,10 @@
package v1alpha1 package v1alpha1
// ResourceInterpreterCustomizationListerExpansion allows custom methods to be added to
// ResourceInterpreterCustomizationLister.
type ResourceInterpreterCustomizationListerExpansion interface{}
// ResourceInterpreterWebhookConfigurationListerExpansion allows custom methods to be added to // ResourceInterpreterWebhookConfigurationListerExpansion allows custom methods to be added to
// ResourceInterpreterWebhookConfigurationLister. // ResourceInterpreterWebhookConfigurationLister.
type ResourceInterpreterWebhookConfigurationListerExpansion interface{} type ResourceInterpreterWebhookConfigurationListerExpansion interface{}

View File

@ -0,0 +1,52 @@
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ResourceInterpreterCustomizationLister helps list ResourceInterpreterCustomizations.
// All objects returned here must be treated as read-only.
type ResourceInterpreterCustomizationLister interface {
// List lists all ResourceInterpreterCustomizations in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.ResourceInterpreterCustomization, err error)
// Get retrieves the ResourceInterpreterCustomization from the index for a given name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha1.ResourceInterpreterCustomization, error)
ResourceInterpreterCustomizationListerExpansion
}
// resourceInterpreterCustomizationLister implements the ResourceInterpreterCustomizationLister interface.
type resourceInterpreterCustomizationLister struct {
indexer cache.Indexer
}
// NewResourceInterpreterCustomizationLister returns a new ResourceInterpreterCustomizationLister.
func NewResourceInterpreterCustomizationLister(indexer cache.Indexer) ResourceInterpreterCustomizationLister {
return &resourceInterpreterCustomizationLister{indexer: indexer}
}
// List lists all ResourceInterpreterCustomizations in the indexer.
func (s *resourceInterpreterCustomizationLister) List(selector labels.Selector) (ret []*v1alpha1.ResourceInterpreterCustomization, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.ResourceInterpreterCustomization))
})
return ret, err
}
// Get retrieves the ResourceInterpreterCustomization from the index for a given name.
func (s *resourceInterpreterCustomizationLister) Get(name string) (*v1alpha1.ResourceInterpreterCustomization, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("resourceinterpretercustomization"), name)
}
return obj.(*v1alpha1.ResourceInterpreterCustomization), nil
}

View File

@ -31,8 +31,12 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceModelRange": schema_pkg_apis_cluster_v1alpha1_ResourceModelRange(ref), "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceModelRange": schema_pkg_apis_cluster_v1alpha1_ResourceModelRange(ref),
"github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceSummary": schema_pkg_apis_cluster_v1alpha1_ResourceSummary(ref), "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1.ResourceSummary": schema_pkg_apis_cluster_v1alpha1_ResourceSummary(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.DependentObjectReference": schema_pkg_apis_config_v1alpha1_DependentObjectReference(ref), "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.DependentObjectReference": schema_pkg_apis_config_v1alpha1_DependentObjectReference(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.LocalValueRetention": schema_pkg_apis_config_v1alpha1_LocalValueRetention(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.RequestStatus": schema_pkg_apis_config_v1alpha1_RequestStatus(ref), "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.RequestStatus": schema_pkg_apis_config_v1alpha1_RequestStatus(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterContext": schema_pkg_apis_config_v1alpha1_ResourceInterpreterContext(ref), "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterContext": schema_pkg_apis_config_v1alpha1_ResourceInterpreterContext(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterCustomization": schema_pkg_apis_config_v1alpha1_ResourceInterpreterCustomization(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterCustomizationList": schema_pkg_apis_config_v1alpha1_ResourceInterpreterCustomizationList(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterCustomizationSpec": schema_pkg_apis_config_v1alpha1_ResourceInterpreterCustomizationSpec(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterRequest": schema_pkg_apis_config_v1alpha1_ResourceInterpreterRequest(ref), "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterRequest": schema_pkg_apis_config_v1alpha1_ResourceInterpreterRequest(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterResponse": schema_pkg_apis_config_v1alpha1_ResourceInterpreterResponse(ref), "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterResponse": schema_pkg_apis_config_v1alpha1_ResourceInterpreterResponse(ref),
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterWebhook": schema_pkg_apis_config_v1alpha1_ResourceInterpreterWebhook(ref), "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterWebhook": schema_pkg_apis_config_v1alpha1_ResourceInterpreterWebhook(ref),
@ -1114,6 +1118,28 @@ func schema_pkg_apis_config_v1alpha1_DependentObjectReference(ref common.Referen
} }
} }
func schema_pkg_apis_config_v1alpha1_LocalValueRetention(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "LocalValueRetention holds the scripts for retention. Now only supports Lua.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"retentionLua": {
SchemaProps: spec.SchemaProps{
Description: "RetentionLua holds the Lua script that is used to retain runtime values to the desired specification. The script should implement a function as follows:\n retentionLua: >\n function Retain(desiredObj, observedObj)\n desiredObj.spec.fieldFoo = observedObj.spec.fieldFoo\n return desiredObj\n end\n\nRetentionLua only holds the function body part, take the `desiredObj` and `observedObj` as the function parameters or global variables, and finally returns a retained specification.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"retentionLua"},
},
},
}
}
func schema_pkg_apis_config_v1alpha1_RequestStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { func schema_pkg_apis_config_v1alpha1_RequestStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{ return common.OpenAPIDefinition{
Schema: spec.Schema{ Schema: spec.Schema{
@ -1182,6 +1208,137 @@ func schema_pkg_apis_config_v1alpha1_ResourceInterpreterContext(ref common.Refer
} }
} }
func schema_pkg_apis_config_v1alpha1_ResourceInterpreterCustomization(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceInterpreterCustomization describes the configuration of a specific resource for Karmada to get the structure. It has higher precedence than the default interpreter and the interpreter webhook.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
},
},
"spec": {
SchemaProps: spec.SchemaProps{
Description: "Spec describes the configuration in detail.",
Default: map[string]interface{}{},
Ref: ref("github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterCustomizationSpec"),
},
},
},
Required: []string{"spec"},
},
},
Dependencies: []string{
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterCustomizationSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_pkg_apis_config_v1alpha1_ResourceInterpreterCustomizationList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceInterpreterCustomizationList contains a list of ResourceInterpreterCustomization.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
},
},
"items": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterCustomization"),
},
},
},
},
},
},
Required: []string{"items"},
},
},
Dependencies: []string{
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.ResourceInterpreterCustomization", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_pkg_apis_config_v1alpha1_ResourceInterpreterCustomizationSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceInterpreterCustomizationSpec describes the configuration in detail.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion represents the API version of the target resource.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind represents the Kind of target resources.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"retention": {
SchemaProps: spec.SchemaProps{
Description: "Retention describes the desired behavior that karmada should react on the changes made by member cluster components. This avoids system running into a meaningless loop that Karmada resource controller and the member cluster component continually applying opposite values of a field. For example, the \"replicas\" of Deployment might be changed by the HPA controller on member cluster. In this case, Karmada should retain the \"replicas\" and not try to change it.",
Default: map[string]interface{}{},
Ref: ref("github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.LocalValueRetention"),
},
},
},
Required: []string{"apiVersion", "kind"},
},
},
Dependencies: []string{
"github.com/karmada-io/karmada/pkg/apis/config/v1alpha1.LocalValueRetention"},
}
}
func schema_pkg_apis_config_v1alpha1_ResourceInterpreterRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { func schema_pkg_apis_config_v1alpha1_ResourceInterpreterRequest(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{ return common.OpenAPIDefinition{
Schema: spec.Schema{ Schema: spec.Schema{