add override api (#103)
* add override api Signed-off-by: Kevin Wang <kevinwzf0126@gmail.com>
This commit is contained in:
parent
3785f32ef2
commit
a57a2a6ddf
|
@ -0,0 +1,260 @@
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
|
kind: CustomResourceDefinition
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
controller-gen.kubebuilder.io/version: v0.4.1
|
||||||
|
creationTimestamp: null
|
||||||
|
name: overridepolicies.propagationstrategy.karmada.io
|
||||||
|
spec:
|
||||||
|
group: propagationstrategy.karmada.io
|
||||||
|
names:
|
||||||
|
kind: OverridePolicy
|
||||||
|
listKind: OverridePolicyList
|
||||||
|
plural: overridepolicies
|
||||||
|
singular: overridepolicy
|
||||||
|
scope: Namespaced
|
||||||
|
versions:
|
||||||
|
- name: v1alpha1
|
||||||
|
schema:
|
||||||
|
openAPIV3Schema:
|
||||||
|
description: OverridePolicy represents the policy that overrides a group of
|
||||||
|
resources to one or more clusters.
|
||||||
|
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 represents the desired behavior of OverridePolicy.
|
||||||
|
properties:
|
||||||
|
overriders:
|
||||||
|
description: Overriders represents the override rules that would apply
|
||||||
|
on resources
|
||||||
|
properties:
|
||||||
|
plaintext:
|
||||||
|
description: Plaintext represents override rules defined with
|
||||||
|
plaintext overriders.
|
||||||
|
items:
|
||||||
|
description: PlaintextOverrider is a simple overrider that overrides
|
||||||
|
target fields according to path, operator and value.
|
||||||
|
properties:
|
||||||
|
operator:
|
||||||
|
description: 'Operator indicates the operation on target
|
||||||
|
field. Available operators are: Add, Update and Remove.'
|
||||||
|
type: string
|
||||||
|
path:
|
||||||
|
description: Path indicates the path of target field
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- operator
|
||||||
|
- path
|
||||||
|
type: object
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
resourceSelectors:
|
||||||
|
description: ResourceSelectors restricts resource types that this
|
||||||
|
override policy applies to.
|
||||||
|
items:
|
||||||
|
description: ResourceSelector the resources will be selected.
|
||||||
|
properties:
|
||||||
|
apiVersion:
|
||||||
|
description: APIVersion represents the API version of the target
|
||||||
|
resources.
|
||||||
|
type: string
|
||||||
|
excludeNamespaces:
|
||||||
|
description: ExcludeNamespaces is a list of namespaces that
|
||||||
|
the ResourceSelector will ignore. Default is empty, which
|
||||||
|
means don't ignore any namespace.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
kind:
|
||||||
|
description: Kind represents the Kind of the target resources.
|
||||||
|
type: string
|
||||||
|
labelSelector:
|
||||||
|
description: A label query over a set of resources.
|
||||||
|
properties:
|
||||||
|
matchExpressions:
|
||||||
|
description: matchExpressions is a list of label selector
|
||||||
|
requirements. The requirements are ANDed.
|
||||||
|
items:
|
||||||
|
description: A label selector requirement is a selector
|
||||||
|
that contains values, a key, and an operator that relates
|
||||||
|
the key and values.
|
||||||
|
properties:
|
||||||
|
key:
|
||||||
|
description: key is the label key that the selector
|
||||||
|
applies to.
|
||||||
|
type: string
|
||||||
|
operator:
|
||||||
|
description: operator represents a key's relationship
|
||||||
|
to a set of values. Valid operators are In, NotIn,
|
||||||
|
Exists and DoesNotExist.
|
||||||
|
type: string
|
||||||
|
values:
|
||||||
|
description: values is an array of string values.
|
||||||
|
If the operator is In or NotIn, the values array
|
||||||
|
must be non-empty. If the operator is Exists or
|
||||||
|
DoesNotExist, the values array must be empty. This
|
||||||
|
array is replaced during a strategic merge patch.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
required:
|
||||||
|
- key
|
||||||
|
- operator
|
||||||
|
type: object
|
||||||
|
type: array
|
||||||
|
matchLabels:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
description: matchLabels is a map of {key,value} pairs.
|
||||||
|
A single {key,value} in the matchLabels map is equivalent
|
||||||
|
to an element of matchExpressions, whose key field is
|
||||||
|
"key", the operator is "In", and the values array contains
|
||||||
|
only "value". The requirements are ANDed.
|
||||||
|
type: object
|
||||||
|
type: object
|
||||||
|
names:
|
||||||
|
description: Names restricts a list of referent names that the
|
||||||
|
ResourceSelector will only select. Default is empty, which
|
||||||
|
means selecting all resources.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
namespaces:
|
||||||
|
description: Namespaces restricts a list of namespaces that
|
||||||
|
the ResourceSelector will only select. If set, only resources
|
||||||
|
in the listed namespaces will be selected. Default is empty,
|
||||||
|
which means selecting all namespaces.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
required:
|
||||||
|
- apiVersion
|
||||||
|
- kind
|
||||||
|
type: object
|
||||||
|
type: array
|
||||||
|
targetCluster:
|
||||||
|
description: TargetCluster defines restrictions on this override policy
|
||||||
|
that only applies to resources propagated to the matching clusters
|
||||||
|
properties:
|
||||||
|
clusterNames:
|
||||||
|
description: ClusterNames is the list of clusters to be selected.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
exclude:
|
||||||
|
description: ExcludedClusters is the list of clusters to be ignored.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
fieldSelector:
|
||||||
|
description: FieldSelector is a filter to select member clusters
|
||||||
|
by fields. If non-nil and non-empty, only the clusters match
|
||||||
|
this filter will be selected.
|
||||||
|
properties:
|
||||||
|
matchExpressions:
|
||||||
|
description: A list of field selector requirements.
|
||||||
|
items:
|
||||||
|
description: A node selector requirement is a selector that
|
||||||
|
contains values, a key, and an operator that relates the
|
||||||
|
key and values.
|
||||||
|
properties:
|
||||||
|
key:
|
||||||
|
description: The label key that the selector applies
|
||||||
|
to.
|
||||||
|
type: string
|
||||||
|
operator:
|
||||||
|
description: Represents a key's relationship to a set
|
||||||
|
of values. Valid operators are In, NotIn, Exists,
|
||||||
|
DoesNotExist. Gt, and Lt.
|
||||||
|
type: string
|
||||||
|
values:
|
||||||
|
description: An array of string values. If the operator
|
||||||
|
is In or NotIn, the values array must be non-empty.
|
||||||
|
If the operator is Exists or DoesNotExist, the values
|
||||||
|
array must be empty. If the operator is Gt or Lt,
|
||||||
|
the values array must have a single element, which
|
||||||
|
will be interpreted as an integer. This array is replaced
|
||||||
|
during a strategic merge patch.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
required:
|
||||||
|
- key
|
||||||
|
- operator
|
||||||
|
type: object
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
labelSelector:
|
||||||
|
description: LabelSelector is a filter to select member clusters
|
||||||
|
by labels. If non-nil and non-empty, only the clusters match
|
||||||
|
this filter will be selected.
|
||||||
|
properties:
|
||||||
|
matchExpressions:
|
||||||
|
description: matchExpressions is a list of label selector
|
||||||
|
requirements. The requirements are ANDed.
|
||||||
|
items:
|
||||||
|
description: A label selector requirement is a selector
|
||||||
|
that contains values, a key, and an operator that relates
|
||||||
|
the key and values.
|
||||||
|
properties:
|
||||||
|
key:
|
||||||
|
description: key is the label key that the selector
|
||||||
|
applies to.
|
||||||
|
type: string
|
||||||
|
operator:
|
||||||
|
description: operator represents a key's relationship
|
||||||
|
to a set of values. Valid operators are In, NotIn,
|
||||||
|
Exists and DoesNotExist.
|
||||||
|
type: string
|
||||||
|
values:
|
||||||
|
description: values is an array of string values. If
|
||||||
|
the operator is In or NotIn, the values array must
|
||||||
|
be non-empty. If the operator is Exists or DoesNotExist,
|
||||||
|
the values array must be empty. This array is replaced
|
||||||
|
during a strategic merge patch.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
required:
|
||||||
|
- key
|
||||||
|
- operator
|
||||||
|
type: object
|
||||||
|
type: array
|
||||||
|
matchLabels:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
description: matchLabels is a map of {key,value} pairs. A
|
||||||
|
single {key,value} in the matchLabels map is equivalent
|
||||||
|
to an element of matchExpressions, whose key field is "key",
|
||||||
|
the operator is "In", and the values array contains only
|
||||||
|
"value". The requirements are ANDed.
|
||||||
|
type: object
|
||||||
|
type: object
|
||||||
|
type: object
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- spec
|
||||||
|
type: object
|
||||||
|
served: true
|
||||||
|
storage: true
|
||||||
|
subresources:
|
||||||
|
status: {}
|
||||||
|
status:
|
||||||
|
acceptedNames:
|
||||||
|
kind: ""
|
||||||
|
plural: ""
|
||||||
|
conditions: []
|
||||||
|
storedVersions: []
|
|
@ -0,0 +1,34 @@
|
||||||
|
apiVersion: propagationstrategy.karmada.io/v1alpha1
|
||||||
|
kind: OverridePolicy
|
||||||
|
metadata:
|
||||||
|
name: example-override
|
||||||
|
namespace: default
|
||||||
|
spec:
|
||||||
|
# restrict resource types that this override policy applies to
|
||||||
|
resourceSelectors:
|
||||||
|
- apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
name: # user can either select resource by name or by labelselector
|
||||||
|
labelSelector:
|
||||||
|
matchLabels:
|
||||||
|
image: nginx
|
||||||
|
# this override policy will only apply to resources propagated to the matching clusters
|
||||||
|
targetCluster:
|
||||||
|
clusterNames: # user can either select cluster by names or by labelselector
|
||||||
|
- dc-1-cluster-1
|
||||||
|
- dc-1-cluster-2
|
||||||
|
labelSelector:
|
||||||
|
matchLabels:
|
||||||
|
failuredomain.kubernetes.io/region: dc1
|
||||||
|
# all matching targetClusters would share the same set of overrides below
|
||||||
|
overriders:
|
||||||
|
plaintext:
|
||||||
|
- path: "/spec/template/spec/containers/0/image"
|
||||||
|
operator: Replace
|
||||||
|
value: "dc-1.registry.io/nginx:1.17.0-alpine"
|
||||||
|
- path: "/metadata/annotations"
|
||||||
|
operator: Add
|
||||||
|
value:
|
||||||
|
foo: bar
|
||||||
|
- path: "/metadata/annotations/foo"
|
||||||
|
operator: Remove
|
|
@ -40,6 +40,7 @@ function installCRDs() {
|
||||||
kubectl apply -f "${SCRIPT_ROOT}/artifacts/deploy/propagationstrategy.karmada.io_propagationpolicies.yaml"
|
kubectl apply -f "${SCRIPT_ROOT}/artifacts/deploy/propagationstrategy.karmada.io_propagationpolicies.yaml"
|
||||||
kubectl apply -f "${SCRIPT_ROOT}/artifacts/deploy/propagationstrategy.karmada.io_propagationbindings.yaml"
|
kubectl apply -f "${SCRIPT_ROOT}/artifacts/deploy/propagationstrategy.karmada.io_propagationbindings.yaml"
|
||||||
kubectl apply -f "${SCRIPT_ROOT}/artifacts/deploy/propagationstrategy.karmada.io_propagationworks.yaml"
|
kubectl apply -f "${SCRIPT_ROOT}/artifacts/deploy/propagationstrategy.karmada.io_propagationworks.yaml"
|
||||||
|
kubectl apply -f "${SCRIPT_ROOT}/artifacts/deploy/propagationstrategy.karmada.io_overridepolicies.yaml"
|
||||||
}
|
}
|
||||||
|
|
||||||
export KUBECONFIG="${HOST_CLUSTER_KUBECONFIG}"
|
export KUBECONFIG="${HOST_CLUSTER_KUBECONFIG}"
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// +genclient
|
||||||
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
||||||
|
// OverridePolicy represents the policy that overrides a group of resources to one or more clusters.
|
||||||
|
type OverridePolicy struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
|
// Spec represents the desired behavior of OverridePolicy.
|
||||||
|
Spec OverrideSpec `json:"spec"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OverrideSpec defines the desired behavior of OverridePolicy.
|
||||||
|
type OverrideSpec struct {
|
||||||
|
// ResourceSelectors restricts resource types that this override policy applies to.
|
||||||
|
ResourceSelectors []ResourceSelector `json:"resourceSelectors,omitempty"`
|
||||||
|
|
||||||
|
// TargetCluster defines restrictions on this override policy
|
||||||
|
// that only applies to resources propagated to the matching clusters
|
||||||
|
TargetCluster ClusterAffinity `json:"targetCluster,omitempty"`
|
||||||
|
|
||||||
|
// Overriders represents the override rules that would apply on resources
|
||||||
|
Overriders Overriders `json:"overriders,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Overriders represents the override rules that would apply on resources
|
||||||
|
type Overriders struct {
|
||||||
|
// Plaintext represents override rules defined with plaintext overriders.
|
||||||
|
Plaintext []PlaintextOverrider `json:"plaintext,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PlaintextOverrider is a simple overrider that overrides target fields
|
||||||
|
// according to path, operator and value.
|
||||||
|
type PlaintextOverrider struct {
|
||||||
|
// Path indicates the path of target field
|
||||||
|
Path string `json:"path"`
|
||||||
|
// Operator indicates the operation on target field.
|
||||||
|
// Available operators are: Add, Update and Remove.
|
||||||
|
Operator OverriderOperator `json:"operator"`
|
||||||
|
// Value to be applied to target field.
|
||||||
|
// Must be empty when operator is Remove.
|
||||||
|
// +optional
|
||||||
|
Value runtime.RawExtension `json:",inline"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OverriderOperator is the set of operators that can be used in an overrider.
|
||||||
|
type OverriderOperator string
|
||||||
|
|
||||||
|
// These are valid overrider operators.
|
||||||
|
const (
|
||||||
|
OverriderOpAdd OverriderOperator = "Add"
|
||||||
|
OverriderOpRemove OverriderOperator = "Remove"
|
||||||
|
OverriderOpReplace OverriderOperator = "Replace"
|
||||||
|
)
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
||||||
|
// OverridePolicyList is a collection of OverridePolicy.
|
||||||
|
type OverridePolicyList struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
metav1.ListMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
|
// Items holds a list of OverridePolicy.
|
||||||
|
Items []OverridePolicy `json:"items"`
|
||||||
|
}
|
|
@ -37,6 +37,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
||||||
&PropagationBindingList{},
|
&PropagationBindingList{},
|
||||||
&PropagationWork{},
|
&PropagationWork{},
|
||||||
&PropagationWorkList{},
|
&PropagationWorkList{},
|
||||||
|
&OverridePolicy{},
|
||||||
|
&OverridePolicyList{},
|
||||||
)
|
)
|
||||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -153,6 +153,114 @@ func (in *ObjectReference) DeepCopy() *ObjectReference {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *OverridePolicy) DeepCopyInto(out *OverridePolicy) {
|
||||||
|
*out = *in
|
||||||
|
out.TypeMeta = in.TypeMeta
|
||||||
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||||
|
in.Spec.DeepCopyInto(&out.Spec)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverridePolicy.
|
||||||
|
func (in *OverridePolicy) DeepCopy() *OverridePolicy {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(OverridePolicy)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||||
|
func (in *OverridePolicy) 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 *OverridePolicyList) DeepCopyInto(out *OverridePolicyList) {
|
||||||
|
*out = *in
|
||||||
|
out.TypeMeta = in.TypeMeta
|
||||||
|
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||||
|
if in.Items != nil {
|
||||||
|
in, out := &in.Items, &out.Items
|
||||||
|
*out = make([]OverridePolicy, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverridePolicyList.
|
||||||
|
func (in *OverridePolicyList) DeepCopy() *OverridePolicyList {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(OverridePolicyList)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||||
|
func (in *OverridePolicyList) 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 *OverrideSpec) DeepCopyInto(out *OverrideSpec) {
|
||||||
|
*out = *in
|
||||||
|
if in.ResourceSelectors != nil {
|
||||||
|
in, out := &in.ResourceSelectors, &out.ResourceSelectors
|
||||||
|
*out = make([]ResourceSelector, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
in.TargetCluster.DeepCopyInto(&out.TargetCluster)
|
||||||
|
in.Overriders.DeepCopyInto(&out.Overriders)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverrideSpec.
|
||||||
|
func (in *OverrideSpec) DeepCopy() *OverrideSpec {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(OverrideSpec)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *Overriders) DeepCopyInto(out *Overriders) {
|
||||||
|
*out = *in
|
||||||
|
if in.Plaintext != nil {
|
||||||
|
in, out := &in.Plaintext, &out.Plaintext
|
||||||
|
*out = make([]PlaintextOverrider, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Overriders.
|
||||||
|
func (in *Overriders) DeepCopy() *Overriders {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(Overriders)
|
||||||
|
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 *Placement) DeepCopyInto(out *Placement) {
|
func (in *Placement) DeepCopyInto(out *Placement) {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
@ -186,6 +294,23 @@ func (in *Placement) DeepCopy() *Placement {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *PlaintextOverrider) DeepCopyInto(out *PlaintextOverrider) {
|
||||||
|
*out = *in
|
||||||
|
in.Value.DeepCopyInto(&out.Value)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlaintextOverrider.
|
||||||
|
func (in *PlaintextOverrider) DeepCopy() *PlaintextOverrider {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(PlaintextOverrider)
|
||||||
|
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 *PropagationBinding) DeepCopyInto(out *PropagationBinding) {
|
func (in *PropagationBinding) DeepCopyInto(out *PropagationBinding) {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
// Code generated by client-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package fake
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/propagationstrategy/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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FakeOverridePolicies implements OverridePolicyInterface
|
||||||
|
type FakeOverridePolicies struct {
|
||||||
|
Fake *FakePropagationstrategyV1alpha1
|
||||||
|
ns string
|
||||||
|
}
|
||||||
|
|
||||||
|
var overridepoliciesResource = schema.GroupVersionResource{Group: "propagationstrategy.karmada.io", Version: "v1alpha1", Resource: "overridepolicies"}
|
||||||
|
|
||||||
|
var overridepoliciesKind = schema.GroupVersionKind{Group: "propagationstrategy.karmada.io", Version: "v1alpha1", Kind: "OverridePolicy"}
|
||||||
|
|
||||||
|
// Get takes name of the overridePolicy, and returns the corresponding overridePolicy object, and an error if there is any.
|
||||||
|
func (c *FakeOverridePolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.OverridePolicy, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewGetAction(overridepoliciesResource, c.ns, name), &v1alpha1.OverridePolicy{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.OverridePolicy), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// List takes label and field selectors, and returns the list of OverridePolicies that match those selectors.
|
||||||
|
func (c *FakeOverridePolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.OverridePolicyList, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewListAction(overridepoliciesResource, overridepoliciesKind, c.ns, opts), &v1alpha1.OverridePolicyList{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||||
|
if label == nil {
|
||||||
|
label = labels.Everything()
|
||||||
|
}
|
||||||
|
list := &v1alpha1.OverridePolicyList{ListMeta: obj.(*v1alpha1.OverridePolicyList).ListMeta}
|
||||||
|
for _, item := range obj.(*v1alpha1.OverridePolicyList).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 overridePolicies.
|
||||||
|
func (c *FakeOverridePolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
|
||||||
|
return c.Fake.
|
||||||
|
InvokesWatch(testing.NewWatchAction(overridepoliciesResource, c.ns, opts))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create takes the representation of a overridePolicy and creates it. Returns the server's representation of the overridePolicy, and an error, if there is any.
|
||||||
|
func (c *FakeOverridePolicies) Create(ctx context.Context, overridePolicy *v1alpha1.OverridePolicy, opts v1.CreateOptions) (result *v1alpha1.OverridePolicy, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewCreateAction(overridepoliciesResource, c.ns, overridePolicy), &v1alpha1.OverridePolicy{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.OverridePolicy), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update takes the representation of a overridePolicy and updates it. Returns the server's representation of the overridePolicy, and an error, if there is any.
|
||||||
|
func (c *FakeOverridePolicies) Update(ctx context.Context, overridePolicy *v1alpha1.OverridePolicy, opts v1.UpdateOptions) (result *v1alpha1.OverridePolicy, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewUpdateAction(overridepoliciesResource, c.ns, overridePolicy), &v1alpha1.OverridePolicy{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.OverridePolicy), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete takes name of the overridePolicy and deletes it. Returns an error if one occurs.
|
||||||
|
func (c *FakeOverridePolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
|
||||||
|
_, err := c.Fake.
|
||||||
|
Invokes(testing.NewDeleteAction(overridepoliciesResource, c.ns, name), &v1alpha1.OverridePolicy{})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteCollection deletes a collection of objects.
|
||||||
|
func (c *FakeOverridePolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
|
||||||
|
action := testing.NewDeleteCollectionAction(overridepoliciesResource, c.ns, listOpts)
|
||||||
|
|
||||||
|
_, err := c.Fake.Invokes(action, &v1alpha1.OverridePolicyList{})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch applies the patch and returns the patched overridePolicy.
|
||||||
|
func (c *FakeOverridePolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.OverridePolicy, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewPatchSubresourceAction(overridepoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha1.OverridePolicy{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.OverridePolicy), err
|
||||||
|
}
|
|
@ -12,6 +12,10 @@ type FakePropagationstrategyV1alpha1 struct {
|
||||||
*testing.Fake
|
*testing.Fake
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FakePropagationstrategyV1alpha1) OverridePolicies(namespace string) v1alpha1.OverridePolicyInterface {
|
||||||
|
return &FakeOverridePolicies{c, namespace}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FakePropagationstrategyV1alpha1) PropagationBindings(namespace string) v1alpha1.PropagationBindingInterface {
|
func (c *FakePropagationstrategyV1alpha1) PropagationBindings(namespace string) v1alpha1.PropagationBindingInterface {
|
||||||
return &FakePropagationBindings{c, namespace}
|
return &FakePropagationBindings{c, namespace}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package v1alpha1
|
package v1alpha1
|
||||||
|
|
||||||
|
type OverridePolicyExpansion interface{}
|
||||||
|
|
||||||
type PropagationBindingExpansion interface{}
|
type PropagationBindingExpansion interface{}
|
||||||
|
|
||||||
type PropagationPolicyExpansion interface{}
|
type PropagationPolicyExpansion interface{}
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
// Code generated by client-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/propagationstrategy/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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OverridePoliciesGetter has a method to return a OverridePolicyInterface.
|
||||||
|
// A group's client should implement this interface.
|
||||||
|
type OverridePoliciesGetter interface {
|
||||||
|
OverridePolicies(namespace string) OverridePolicyInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
// OverridePolicyInterface has methods to work with OverridePolicy resources.
|
||||||
|
type OverridePolicyInterface interface {
|
||||||
|
Create(ctx context.Context, overridePolicy *v1alpha1.OverridePolicy, opts v1.CreateOptions) (*v1alpha1.OverridePolicy, error)
|
||||||
|
Update(ctx context.Context, overridePolicy *v1alpha1.OverridePolicy, opts v1.UpdateOptions) (*v1alpha1.OverridePolicy, 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.OverridePolicy, error)
|
||||||
|
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.OverridePolicyList, 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.OverridePolicy, err error)
|
||||||
|
OverridePolicyExpansion
|
||||||
|
}
|
||||||
|
|
||||||
|
// overridePolicies implements OverridePolicyInterface
|
||||||
|
type overridePolicies struct {
|
||||||
|
client rest.Interface
|
||||||
|
ns string
|
||||||
|
}
|
||||||
|
|
||||||
|
// newOverridePolicies returns a OverridePolicies
|
||||||
|
func newOverridePolicies(c *PropagationstrategyV1alpha1Client, namespace string) *overridePolicies {
|
||||||
|
return &overridePolicies{
|
||||||
|
client: c.RESTClient(),
|
||||||
|
ns: namespace,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get takes name of the overridePolicy, and returns the corresponding overridePolicy object, and an error if there is any.
|
||||||
|
func (c *overridePolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.OverridePolicy, err error) {
|
||||||
|
result = &v1alpha1.OverridePolicy{}
|
||||||
|
err = c.client.Get().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("overridepolicies").
|
||||||
|
Name(name).
|
||||||
|
VersionedParams(&options, scheme.ParameterCodec).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// List takes label and field selectors, and returns the list of OverridePolicies that match those selectors.
|
||||||
|
func (c *overridePolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.OverridePolicyList, err error) {
|
||||||
|
var timeout time.Duration
|
||||||
|
if opts.TimeoutSeconds != nil {
|
||||||
|
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||||
|
}
|
||||||
|
result = &v1alpha1.OverridePolicyList{}
|
||||||
|
err = c.client.Get().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("overridepolicies").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Timeout(timeout).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch returns a watch.Interface that watches the requested overridePolicies.
|
||||||
|
func (c *overridePolicies) 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("overridepolicies").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Timeout(timeout).
|
||||||
|
Watch(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create takes the representation of a overridePolicy and creates it. Returns the server's representation of the overridePolicy, and an error, if there is any.
|
||||||
|
func (c *overridePolicies) Create(ctx context.Context, overridePolicy *v1alpha1.OverridePolicy, opts v1.CreateOptions) (result *v1alpha1.OverridePolicy, err error) {
|
||||||
|
result = &v1alpha1.OverridePolicy{}
|
||||||
|
err = c.client.Post().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("overridepolicies").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Body(overridePolicy).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update takes the representation of a overridePolicy and updates it. Returns the server's representation of the overridePolicy, and an error, if there is any.
|
||||||
|
func (c *overridePolicies) Update(ctx context.Context, overridePolicy *v1alpha1.OverridePolicy, opts v1.UpdateOptions) (result *v1alpha1.OverridePolicy, err error) {
|
||||||
|
result = &v1alpha1.OverridePolicy{}
|
||||||
|
err = c.client.Put().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("overridepolicies").
|
||||||
|
Name(overridePolicy.Name).
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Body(overridePolicy).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete takes name of the overridePolicy and deletes it. Returns an error if one occurs.
|
||||||
|
func (c *overridePolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
|
||||||
|
return c.client.Delete().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("overridepolicies").
|
||||||
|
Name(name).
|
||||||
|
Body(&opts).
|
||||||
|
Do(ctx).
|
||||||
|
Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteCollection deletes a collection of objects.
|
||||||
|
func (c *overridePolicies) 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("overridepolicies").
|
||||||
|
VersionedParams(&listOpts, scheme.ParameterCodec).
|
||||||
|
Timeout(timeout).
|
||||||
|
Body(&opts).
|
||||||
|
Do(ctx).
|
||||||
|
Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch applies the patch and returns the patched overridePolicy.
|
||||||
|
func (c *overridePolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.OverridePolicy, err error) {
|
||||||
|
result = &v1alpha1.OverridePolicy{}
|
||||||
|
err = c.client.Patch(pt).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("overridepolicies").
|
||||||
|
Name(name).
|
||||||
|
SubResource(subresources...).
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
type PropagationstrategyV1alpha1Interface interface {
|
type PropagationstrategyV1alpha1Interface interface {
|
||||||
RESTClient() rest.Interface
|
RESTClient() rest.Interface
|
||||||
|
OverridePoliciesGetter
|
||||||
PropagationBindingsGetter
|
PropagationBindingsGetter
|
||||||
PropagationPoliciesGetter
|
PropagationPoliciesGetter
|
||||||
PropagationWorksGetter
|
PropagationWorksGetter
|
||||||
|
@ -20,6 +21,10 @@ type PropagationstrategyV1alpha1Client struct {
|
||||||
restClient rest.Interface
|
restClient rest.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *PropagationstrategyV1alpha1Client) OverridePolicies(namespace string) OverridePolicyInterface {
|
||||||
|
return newOverridePolicies(c, namespace)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *PropagationstrategyV1alpha1Client) PropagationBindings(namespace string) PropagationBindingInterface {
|
func (c *PropagationstrategyV1alpha1Client) PropagationBindings(namespace string) PropagationBindingInterface {
|
||||||
return newPropagationBindings(c, namespace)
|
return newPropagationBindings(c, namespace)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
|
||||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Membercluster().V1alpha1().MemberClusters().Informer()}, nil
|
return &genericInformer{resource: resource.GroupResource(), informer: f.Membercluster().V1alpha1().MemberClusters().Informer()}, nil
|
||||||
|
|
||||||
// Group=propagationstrategy.karmada.io, Version=v1alpha1
|
// Group=propagationstrategy.karmada.io, Version=v1alpha1
|
||||||
|
case propagationstrategyv1alpha1.SchemeGroupVersion.WithResource("overridepolicies"):
|
||||||
|
return &genericInformer{resource: resource.GroupResource(), informer: f.Propagationstrategy().V1alpha1().OverridePolicies().Informer()}, nil
|
||||||
case propagationstrategyv1alpha1.SchemeGroupVersion.WithResource("propagationbindings"):
|
case propagationstrategyv1alpha1.SchemeGroupVersion.WithResource("propagationbindings"):
|
||||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Propagationstrategy().V1alpha1().PropagationBindings().Informer()}, nil
|
return &genericInformer{resource: resource.GroupResource(), informer: f.Propagationstrategy().V1alpha1().PropagationBindings().Informer()}, nil
|
||||||
case propagationstrategyv1alpha1.SchemeGroupVersion.WithResource("propagationpolicies"):
|
case propagationstrategyv1alpha1.SchemeGroupVersion.WithResource("propagationpolicies"):
|
||||||
|
|
|
@ -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 {
|
||||||
|
// OverridePolicies returns a OverridePolicyInformer.
|
||||||
|
OverridePolicies() OverridePolicyInformer
|
||||||
// PropagationBindings returns a PropagationBindingInformer.
|
// PropagationBindings returns a PropagationBindingInformer.
|
||||||
PropagationBindings() PropagationBindingInformer
|
PropagationBindings() PropagationBindingInformer
|
||||||
// PropagationPolicies returns a PropagationPolicyInformer.
|
// PropagationPolicies returns a PropagationPolicyInformer.
|
||||||
|
@ -27,6 +29,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}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OverridePolicies returns a OverridePolicyInformer.
|
||||||
|
func (v *version) OverridePolicies() OverridePolicyInformer {
|
||||||
|
return &overridePolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||||
|
}
|
||||||
|
|
||||||
// PropagationBindings returns a PropagationBindingInformer.
|
// PropagationBindings returns a PropagationBindingInformer.
|
||||||
func (v *version) PropagationBindings() PropagationBindingInformer {
|
func (v *version) PropagationBindings() PropagationBindingInformer {
|
||||||
return &propagationBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
return &propagationBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
// Code generated by informer-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
time "time"
|
||||||
|
|
||||||
|
propagationstrategyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/propagationstrategy/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/propagationstrategy/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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OverridePolicyInformer provides access to a shared informer and lister for
|
||||||
|
// OverridePolicies.
|
||||||
|
type OverridePolicyInformer interface {
|
||||||
|
Informer() cache.SharedIndexInformer
|
||||||
|
Lister() v1alpha1.OverridePolicyLister
|
||||||
|
}
|
||||||
|
|
||||||
|
type overridePolicyInformer struct {
|
||||||
|
factory internalinterfaces.SharedInformerFactory
|
||||||
|
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||||
|
namespace string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOverridePolicyInformer constructs a new informer for OverridePolicy 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 NewOverridePolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||||
|
return NewFilteredOverridePolicyInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewFilteredOverridePolicyInformer constructs a new informer for OverridePolicy 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 NewFilteredOverridePolicyInformer(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.PropagationstrategyV1alpha1().OverridePolicies(namespace).List(context.TODO(), options)
|
||||||
|
},
|
||||||
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
|
if tweakListOptions != nil {
|
||||||
|
tweakListOptions(&options)
|
||||||
|
}
|
||||||
|
return client.PropagationstrategyV1alpha1().OverridePolicies(namespace).Watch(context.TODO(), options)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
&propagationstrategyv1alpha1.OverridePolicy{},
|
||||||
|
resyncPeriod,
|
||||||
|
indexers,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *overridePolicyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||||
|
return NewFilteredOverridePolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *overridePolicyInformer) Informer() cache.SharedIndexInformer {
|
||||||
|
return f.factory.InformerFor(&propagationstrategyv1alpha1.OverridePolicy{}, f.defaultInformer)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *overridePolicyInformer) Lister() v1alpha1.OverridePolicyLister {
|
||||||
|
return v1alpha1.NewOverridePolicyLister(f.Informer().GetIndexer())
|
||||||
|
}
|
|
@ -2,6 +2,14 @@
|
||||||
|
|
||||||
package v1alpha1
|
package v1alpha1
|
||||||
|
|
||||||
|
// OverridePolicyListerExpansion allows custom methods to be added to
|
||||||
|
// OverridePolicyLister.
|
||||||
|
type OverridePolicyListerExpansion interface{}
|
||||||
|
|
||||||
|
// OverridePolicyNamespaceListerExpansion allows custom methods to be added to
|
||||||
|
// OverridePolicyNamespaceLister.
|
||||||
|
type OverridePolicyNamespaceListerExpansion interface{}
|
||||||
|
|
||||||
// PropagationBindingListerExpansion allows custom methods to be added to
|
// PropagationBindingListerExpansion allows custom methods to be added to
|
||||||
// PropagationBindingLister.
|
// PropagationBindingLister.
|
||||||
type PropagationBindingListerExpansion interface{}
|
type PropagationBindingListerExpansion interface{}
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
// Code generated by lister-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/propagationstrategy/v1alpha1"
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
"k8s.io/client-go/tools/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OverridePolicyLister helps list OverridePolicies.
|
||||||
|
// All objects returned here must be treated as read-only.
|
||||||
|
type OverridePolicyLister interface {
|
||||||
|
// List lists all OverridePolicies in the indexer.
|
||||||
|
// Objects returned here must be treated as read-only.
|
||||||
|
List(selector labels.Selector) (ret []*v1alpha1.OverridePolicy, err error)
|
||||||
|
// OverridePolicies returns an object that can list and get OverridePolicies.
|
||||||
|
OverridePolicies(namespace string) OverridePolicyNamespaceLister
|
||||||
|
OverridePolicyListerExpansion
|
||||||
|
}
|
||||||
|
|
||||||
|
// overridePolicyLister implements the OverridePolicyLister interface.
|
||||||
|
type overridePolicyLister struct {
|
||||||
|
indexer cache.Indexer
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOverridePolicyLister returns a new OverridePolicyLister.
|
||||||
|
func NewOverridePolicyLister(indexer cache.Indexer) OverridePolicyLister {
|
||||||
|
return &overridePolicyLister{indexer: indexer}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists all OverridePolicies in the indexer.
|
||||||
|
func (s *overridePolicyLister) List(selector labels.Selector) (ret []*v1alpha1.OverridePolicy, err error) {
|
||||||
|
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||||
|
ret = append(ret, m.(*v1alpha1.OverridePolicy))
|
||||||
|
})
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// OverridePolicies returns an object that can list and get OverridePolicies.
|
||||||
|
func (s *overridePolicyLister) OverridePolicies(namespace string) OverridePolicyNamespaceLister {
|
||||||
|
return overridePolicyNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OverridePolicyNamespaceLister helps list and get OverridePolicies.
|
||||||
|
// All objects returned here must be treated as read-only.
|
||||||
|
type OverridePolicyNamespaceLister interface {
|
||||||
|
// List lists all OverridePolicies in the indexer for a given namespace.
|
||||||
|
// Objects returned here must be treated as read-only.
|
||||||
|
List(selector labels.Selector) (ret []*v1alpha1.OverridePolicy, err error)
|
||||||
|
// Get retrieves the OverridePolicy from the indexer for a given namespace and name.
|
||||||
|
// Objects returned here must be treated as read-only.
|
||||||
|
Get(name string) (*v1alpha1.OverridePolicy, error)
|
||||||
|
OverridePolicyNamespaceListerExpansion
|
||||||
|
}
|
||||||
|
|
||||||
|
// overridePolicyNamespaceLister implements the OverridePolicyNamespaceLister
|
||||||
|
// interface.
|
||||||
|
type overridePolicyNamespaceLister struct {
|
||||||
|
indexer cache.Indexer
|
||||||
|
namespace string
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists all OverridePolicies in the indexer for a given namespace.
|
||||||
|
func (s overridePolicyNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.OverridePolicy, err error) {
|
||||||
|
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||||
|
ret = append(ret, m.(*v1alpha1.OverridePolicy))
|
||||||
|
})
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get retrieves the OverridePolicy from the indexer for a given namespace and name.
|
||||||
|
func (s overridePolicyNamespaceLister) Get(name string) (*v1alpha1.OverridePolicy, error) {
|
||||||
|
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !exists {
|
||||||
|
return nil, errors.NewNotFound(v1alpha1.Resource("overridepolicy"), name)
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.OverridePolicy), nil
|
||||||
|
}
|
Loading…
Reference in New Issue