Add ReplicaSchedulingPolicy API. (#267)
Signed-off-by: RainbowMango <renhongcai@huawei.com>
This commit is contained in:
parent
fd5aeb8cf5
commit
9d7f6d4b0c
|
@ -0,0 +1,260 @@
|
|||
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.4.1
|
||||
creationTimestamp: null
|
||||
name: replicaschedulingpolicies.policy.karmada.io
|
||||
spec:
|
||||
group: policy.karmada.io
|
||||
names:
|
||||
kind: ReplicaSchedulingPolicy
|
||||
listKind: ReplicaSchedulingPolicyList
|
||||
plural: replicaschedulingpolicies
|
||||
singular: replicaschedulingpolicy
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1alpha1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: ReplicaSchedulingPolicy represents the policy that propagates
|
||||
total number of replicas for deployment.
|
||||
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 ReplicaSchedulingPolicy.
|
||||
properties:
|
||||
preferences:
|
||||
description: Preferences describes weight for each cluster or for
|
||||
each group of cluster.
|
||||
properties:
|
||||
staticWeightList:
|
||||
description: StaticWeightList defines the static cluster weight.
|
||||
items:
|
||||
description: StaticClusterWeight defines the static cluster
|
||||
weight.
|
||||
properties:
|
||||
targetCluster:
|
||||
description: TargetCluster describes the filter to select
|
||||
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
|
||||
weight:
|
||||
description: Weight expressing the preference to the cluster(s)
|
||||
specified by 'TargetCluster'.
|
||||
format: int64
|
||||
type: integer
|
||||
required:
|
||||
- targetCluster
|
||||
- weight
|
||||
type: object
|
||||
type: array
|
||||
required:
|
||||
- staticWeightList
|
||||
type: object
|
||||
resourceSelectors:
|
||||
description: ResourceSelectors used to select resources.
|
||||
items:
|
||||
description: ResourceSelector the resources will be selected.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: APIVersion represents the API version of the target
|
||||
resources.
|
||||
type: string
|
||||
kind:
|
||||
description: Kind represents the Kind of the target resources.
|
||||
type: string
|
||||
labelSelector:
|
||||
description: A label query over a set of resources. If name
|
||||
is not empty, labelSelector will be ignored.
|
||||
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
|
||||
name:
|
||||
description: Name of the target resource. Default is empty,
|
||||
which means selecting all resources.
|
||||
type: string
|
||||
namespace:
|
||||
description: Namespace of the target resource. Default is empty,
|
||||
which means inherit from the parent object scope.
|
||||
type: string
|
||||
required:
|
||||
- apiVersion
|
||||
- kind
|
||||
type: object
|
||||
type: array
|
||||
totalReplicas:
|
||||
description: TotalReplicas represents the total number of replicas
|
||||
across member clusters. The replicas(spec.replicas) specified for
|
||||
deployment template will be discarded.
|
||||
format: int32
|
||||
type: integer
|
||||
required:
|
||||
- preferences
|
||||
- resourceSelectors
|
||||
- totalReplicas
|
||||
type: object
|
||||
required:
|
||||
- spec
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
status:
|
||||
acceptedNames:
|
||||
kind: ""
|
||||
plural: ""
|
||||
conditions: []
|
||||
storedVersions: []
|
|
@ -0,0 +1,24 @@
|
|||
apiVersion: policy.karmada.io/v1alpha1
|
||||
kind: ReplicaSchedulingPolicy
|
||||
metadata:
|
||||
name: foo
|
||||
namespace: foons
|
||||
spec:
|
||||
resourceSelectors:
|
||||
- apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
namespace: foons
|
||||
name: deployment-1
|
||||
totalReplicas: 100
|
||||
preferences:
|
||||
staticWeightList:
|
||||
- targetCluster:
|
||||
labelSelector:
|
||||
matchLabels:
|
||||
location: us
|
||||
weight: 1
|
||||
- targetCluster:
|
||||
labelSelector:
|
||||
matchLabels:
|
||||
location: cn
|
||||
weight: 2
|
|
@ -0,0 +1,20 @@
|
|||
apiVersion: policy.karmada.io/v1alpha1
|
||||
kind: ReplicaSchedulingPolicy
|
||||
metadata:
|
||||
name: foo
|
||||
namespace: foons
|
||||
spec:
|
||||
resourceSelectors:
|
||||
- apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
namespace: foons
|
||||
name: deployment-1
|
||||
totalReplicas: 100
|
||||
preferences:
|
||||
staticWeightList:
|
||||
- targetCluster:
|
||||
clusterNames: [cluster1]
|
||||
weight: 1
|
||||
- targetCluster:
|
||||
clusterNames: [cluster2]
|
||||
weight: 2
|
|
@ -0,0 +1,58 @@
|
|||
package v1alpha1
|
||||
|
||||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ReplicaSchedulingPolicy represents the policy that propagates total number of replicas for deployment.
|
||||
type ReplicaSchedulingPolicy struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Spec represents the desired behavior of ReplicaSchedulingPolicy.
|
||||
Spec ReplicaSchedulingSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// ReplicaSchedulingSpec represents the desired behavior of ReplicaSchedulingPolicy.
|
||||
type ReplicaSchedulingSpec struct {
|
||||
// ResourceSelectors used to select resources.
|
||||
// +required
|
||||
ResourceSelectors []ResourceSelector `json:"resourceSelectors"`
|
||||
|
||||
// TotalReplicas represents the total number of replicas across member clusters.
|
||||
// The replicas(spec.replicas) specified for deployment template will be discarded.
|
||||
// +required
|
||||
TotalReplicas int32 `json:"totalReplicas"`
|
||||
|
||||
// Preferences describes weight for each cluster or for each group of cluster.
|
||||
// +required
|
||||
Preferences ClusterPreferences `json:"preferences"`
|
||||
}
|
||||
|
||||
// ClusterPreferences describes weight for each cluster or for each group of cluster.
|
||||
type ClusterPreferences struct {
|
||||
// StaticWeightList defines the static cluster weight.
|
||||
// +required
|
||||
StaticWeightList []StaticClusterWeight `json:"staticWeightList"`
|
||||
}
|
||||
|
||||
// StaticClusterWeight defines the static cluster weight.
|
||||
type StaticClusterWeight struct {
|
||||
// TargetCluster describes the filter to select clusters.
|
||||
// +required
|
||||
TargetCluster ClusterAffinity `json:"targetCluster"`
|
||||
|
||||
// Weight expressing the preference to the cluster(s) specified by 'TargetCluster'.
|
||||
// +required
|
||||
Weight int64 `json:"weight"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ReplicaSchedulingPolicyList contains a list of ReplicaSchedulingPolicy.
|
||||
type ReplicaSchedulingPolicyList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []ReplicaSchedulingPolicy `json:"items"`
|
||||
}
|
|
@ -106,6 +106,29 @@ func (in *ClusterOverridePolicyList) DeepCopyObject() runtime.Object {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterPreferences) DeepCopyInto(out *ClusterPreferences) {
|
||||
*out = *in
|
||||
if in.StaticWeightList != nil {
|
||||
in, out := &in.StaticWeightList, &out.StaticWeightList
|
||||
*out = make([]StaticClusterWeight, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPreferences.
|
||||
func (in *ClusterPreferences) DeepCopy() *ClusterPreferences {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterPreferences)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterPropagationPolicy) DeepCopyInto(out *ClusterPropagationPolicy) {
|
||||
*out = *in
|
||||
|
@ -436,6 +459,90 @@ func (in *PropagationSpec) DeepCopy() *PropagationSpec {
|
|||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ReplicaSchedulingPolicy) DeepCopyInto(out *ReplicaSchedulingPolicy) {
|
||||
*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 ReplicaSchedulingPolicy.
|
||||
func (in *ReplicaSchedulingPolicy) DeepCopy() *ReplicaSchedulingPolicy {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ReplicaSchedulingPolicy)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ReplicaSchedulingPolicy) 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 *ReplicaSchedulingPolicyList) DeepCopyInto(out *ReplicaSchedulingPolicyList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]ReplicaSchedulingPolicy, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReplicaSchedulingPolicyList.
|
||||
func (in *ReplicaSchedulingPolicyList) DeepCopy() *ReplicaSchedulingPolicyList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ReplicaSchedulingPolicyList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ReplicaSchedulingPolicyList) 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 *ReplicaSchedulingSpec) DeepCopyInto(out *ReplicaSchedulingSpec) {
|
||||
*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.Preferences.DeepCopyInto(&out.Preferences)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReplicaSchedulingSpec.
|
||||
func (in *ReplicaSchedulingSpec) DeepCopy() *ReplicaSchedulingSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ReplicaSchedulingSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ResourceSelector) DeepCopyInto(out *ResourceSelector) {
|
||||
*out = *in
|
||||
|
@ -472,3 +579,20 @@ func (in *SpreadConstraint) DeepCopy() *SpreadConstraint {
|
|||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *StaticClusterWeight) DeepCopyInto(out *StaticClusterWeight) {
|
||||
*out = *in
|
||||
in.TargetCluster.DeepCopyInto(&out.TargetCluster)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StaticClusterWeight.
|
||||
func (in *StaticClusterWeight) DeepCopy() *StaticClusterWeight {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(StaticClusterWeight)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
|||
&OverridePolicyList{},
|
||||
&PropagationPolicy{},
|
||||
&PropagationPolicyList{},
|
||||
&ReplicaSchedulingPolicy{},
|
||||
&ReplicaSchedulingPolicyList{},
|
||||
)
|
||||
// AddToGroupVersion allows the serialization of client types like ListOptions.
|
||||
v1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
|
|
|
@ -28,6 +28,10 @@ func (c *FakePolicyV1alpha1) PropagationPolicies(namespace string) v1alpha1.Prop
|
|||
return &FakePropagationPolicies{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakePolicyV1alpha1) ReplicaSchedulingPolicies(namespace string) v1alpha1.ReplicaSchedulingPolicyInterface {
|
||||
return &FakeReplicaSchedulingPolicies{c, namespace}
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakePolicyV1alpha1) RESTClient() rest.Interface {
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/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"
|
||||
)
|
||||
|
||||
// FakeReplicaSchedulingPolicies implements ReplicaSchedulingPolicyInterface
|
||||
type FakeReplicaSchedulingPolicies struct {
|
||||
Fake *FakePolicyV1alpha1
|
||||
ns string
|
||||
}
|
||||
|
||||
var replicaschedulingpoliciesResource = schema.GroupVersionResource{Group: "policy.karmada.io", Version: "v1alpha1", Resource: "replicaschedulingpolicies"}
|
||||
|
||||
var replicaschedulingpoliciesKind = schema.GroupVersionKind{Group: "policy.karmada.io", Version: "v1alpha1", Kind: "ReplicaSchedulingPolicy"}
|
||||
|
||||
// Get takes name of the replicaSchedulingPolicy, and returns the corresponding replicaSchedulingPolicy object, and an error if there is any.
|
||||
func (c *FakeReplicaSchedulingPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(replicaschedulingpoliciesResource, c.ns, name), &v1alpha1.ReplicaSchedulingPolicy{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.ReplicaSchedulingPolicy), err
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of ReplicaSchedulingPolicies that match those selectors.
|
||||
func (c *FakeReplicaSchedulingPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ReplicaSchedulingPolicyList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(replicaschedulingpoliciesResource, replicaschedulingpoliciesKind, c.ns, opts), &v1alpha1.ReplicaSchedulingPolicyList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1alpha1.ReplicaSchedulingPolicyList{ListMeta: obj.(*v1alpha1.ReplicaSchedulingPolicyList).ListMeta}
|
||||
for _, item := range obj.(*v1alpha1.ReplicaSchedulingPolicyList).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 replicaSchedulingPolicies.
|
||||
func (c *FakeReplicaSchedulingPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(replicaschedulingpoliciesResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Create takes the representation of a replicaSchedulingPolicy and creates it. Returns the server's representation of the replicaSchedulingPolicy, and an error, if there is any.
|
||||
func (c *FakeReplicaSchedulingPolicies) Create(ctx context.Context, replicaSchedulingPolicy *v1alpha1.ReplicaSchedulingPolicy, opts v1.CreateOptions) (result *v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(replicaschedulingpoliciesResource, c.ns, replicaSchedulingPolicy), &v1alpha1.ReplicaSchedulingPolicy{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.ReplicaSchedulingPolicy), err
|
||||
}
|
||||
|
||||
// Update takes the representation of a replicaSchedulingPolicy and updates it. Returns the server's representation of the replicaSchedulingPolicy, and an error, if there is any.
|
||||
func (c *FakeReplicaSchedulingPolicies) Update(ctx context.Context, replicaSchedulingPolicy *v1alpha1.ReplicaSchedulingPolicy, opts v1.UpdateOptions) (result *v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(replicaschedulingpoliciesResource, c.ns, replicaSchedulingPolicy), &v1alpha1.ReplicaSchedulingPolicy{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.ReplicaSchedulingPolicy), err
|
||||
}
|
||||
|
||||
// Delete takes name of the replicaSchedulingPolicy and deletes it. Returns an error if one occurs.
|
||||
func (c *FakeReplicaSchedulingPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(replicaschedulingpoliciesResource, c.ns, name), &v1alpha1.ReplicaSchedulingPolicy{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *FakeReplicaSchedulingPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(replicaschedulingpoliciesResource, c.ns, listOpts)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1alpha1.ReplicaSchedulingPolicyList{})
|
||||
return err
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched replicaSchedulingPolicy.
|
||||
func (c *FakeReplicaSchedulingPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(replicaschedulingpoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha1.ReplicaSchedulingPolicy{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.ReplicaSchedulingPolicy), err
|
||||
}
|
|
@ -9,3 +9,5 @@ type ClusterPropagationPolicyExpansion interface{}
|
|||
type OverridePolicyExpansion interface{}
|
||||
|
||||
type PropagationPolicyExpansion interface{}
|
||||
|
||||
type ReplicaSchedulingPolicyExpansion interface{}
|
||||
|
|
|
@ -14,6 +14,7 @@ type PolicyV1alpha1Interface interface {
|
|||
ClusterPropagationPoliciesGetter
|
||||
OverridePoliciesGetter
|
||||
PropagationPoliciesGetter
|
||||
ReplicaSchedulingPoliciesGetter
|
||||
}
|
||||
|
||||
// PolicyV1alpha1Client is used to interact with features provided by the policy.karmada.io group.
|
||||
|
@ -37,6 +38,10 @@ func (c *PolicyV1alpha1Client) PropagationPolicies(namespace string) Propagation
|
|||
return newPropagationPolicies(c, namespace)
|
||||
}
|
||||
|
||||
func (c *PolicyV1alpha1Client) ReplicaSchedulingPolicies(namespace string) ReplicaSchedulingPolicyInterface {
|
||||
return newReplicaSchedulingPolicies(c, namespace)
|
||||
}
|
||||
|
||||
// NewForConfig creates a new PolicyV1alpha1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*PolicyV1alpha1Client, error) {
|
||||
config := *c
|
||||
|
|
|
@ -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/policy/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"
|
||||
)
|
||||
|
||||
// ReplicaSchedulingPoliciesGetter has a method to return a ReplicaSchedulingPolicyInterface.
|
||||
// A group's client should implement this interface.
|
||||
type ReplicaSchedulingPoliciesGetter interface {
|
||||
ReplicaSchedulingPolicies(namespace string) ReplicaSchedulingPolicyInterface
|
||||
}
|
||||
|
||||
// ReplicaSchedulingPolicyInterface has methods to work with ReplicaSchedulingPolicy resources.
|
||||
type ReplicaSchedulingPolicyInterface interface {
|
||||
Create(ctx context.Context, replicaSchedulingPolicy *v1alpha1.ReplicaSchedulingPolicy, opts v1.CreateOptions) (*v1alpha1.ReplicaSchedulingPolicy, error)
|
||||
Update(ctx context.Context, replicaSchedulingPolicy *v1alpha1.ReplicaSchedulingPolicy, opts v1.UpdateOptions) (*v1alpha1.ReplicaSchedulingPolicy, 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.ReplicaSchedulingPolicy, error)
|
||||
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ReplicaSchedulingPolicyList, 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.ReplicaSchedulingPolicy, err error)
|
||||
ReplicaSchedulingPolicyExpansion
|
||||
}
|
||||
|
||||
// replicaSchedulingPolicies implements ReplicaSchedulingPolicyInterface
|
||||
type replicaSchedulingPolicies struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
}
|
||||
|
||||
// newReplicaSchedulingPolicies returns a ReplicaSchedulingPolicies
|
||||
func newReplicaSchedulingPolicies(c *PolicyV1alpha1Client, namespace string) *replicaSchedulingPolicies {
|
||||
return &replicaSchedulingPolicies{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the replicaSchedulingPolicy, and returns the corresponding replicaSchedulingPolicy object, and an error if there is any.
|
||||
func (c *replicaSchedulingPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
result = &v1alpha1.ReplicaSchedulingPolicy{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("replicaschedulingpolicies").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of ReplicaSchedulingPolicies that match those selectors.
|
||||
func (c *replicaSchedulingPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ReplicaSchedulingPolicyList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1alpha1.ReplicaSchedulingPolicyList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("replicaschedulingpolicies").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested replicaSchedulingPolicies.
|
||||
func (c *replicaSchedulingPolicies) 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("replicaschedulingpolicies").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch(ctx)
|
||||
}
|
||||
|
||||
// Create takes the representation of a replicaSchedulingPolicy and creates it. Returns the server's representation of the replicaSchedulingPolicy, and an error, if there is any.
|
||||
func (c *replicaSchedulingPolicies) Create(ctx context.Context, replicaSchedulingPolicy *v1alpha1.ReplicaSchedulingPolicy, opts v1.CreateOptions) (result *v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
result = &v1alpha1.ReplicaSchedulingPolicy{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("replicaschedulingpolicies").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(replicaSchedulingPolicy).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a replicaSchedulingPolicy and updates it. Returns the server's representation of the replicaSchedulingPolicy, and an error, if there is any.
|
||||
func (c *replicaSchedulingPolicies) Update(ctx context.Context, replicaSchedulingPolicy *v1alpha1.ReplicaSchedulingPolicy, opts v1.UpdateOptions) (result *v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
result = &v1alpha1.ReplicaSchedulingPolicy{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("replicaschedulingpolicies").
|
||||
Name(replicaSchedulingPolicy.Name).
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(replicaSchedulingPolicy).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the replicaSchedulingPolicy and deletes it. Returns an error if one occurs.
|
||||
func (c *replicaSchedulingPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("replicaschedulingpolicies").
|
||||
Name(name).
|
||||
Body(&opts).
|
||||
Do(ctx).
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *replicaSchedulingPolicies) 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("replicaschedulingpolicies").
|
||||
VersionedParams(&listOpts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(&opts).
|
||||
Do(ctx).
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched replicaSchedulingPolicy.
|
||||
func (c *replicaSchedulingPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
result = &v1alpha1.ReplicaSchedulingPolicy{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("replicaschedulingpolicies").
|
||||
Name(name).
|
||||
SubResource(subresources...).
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
|
@ -51,6 +51,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
|
|||
return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1alpha1().OverridePolicies().Informer()}, nil
|
||||
case policyv1alpha1.SchemeGroupVersion.WithResource("propagationpolicies"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1alpha1().PropagationPolicies().Informer()}, nil
|
||||
case policyv1alpha1.SchemeGroupVersion.WithResource("replicaschedulingpolicies"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1alpha1().ReplicaSchedulingPolicies().Informer()}, nil
|
||||
|
||||
// Group=work.karmada.io, Version=v1alpha1
|
||||
case workv1alpha1.SchemeGroupVersion.WithResource("clusterresourcebindings"):
|
||||
|
|
|
@ -16,6 +16,8 @@ type Interface interface {
|
|||
OverridePolicies() OverridePolicyInformer
|
||||
// PropagationPolicies returns a PropagationPolicyInformer.
|
||||
PropagationPolicies() PropagationPolicyInformer
|
||||
// ReplicaSchedulingPolicies returns a ReplicaSchedulingPolicyInformer.
|
||||
ReplicaSchedulingPolicies() ReplicaSchedulingPolicyInformer
|
||||
}
|
||||
|
||||
type version struct {
|
||||
|
@ -48,3 +50,8 @@ func (v *version) OverridePolicies() OverridePolicyInformer {
|
|||
func (v *version) PropagationPolicies() PropagationPolicyInformer {
|
||||
return &propagationPolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
|
||||
// ReplicaSchedulingPolicies returns a ReplicaSchedulingPolicyInformer.
|
||||
func (v *version) ReplicaSchedulingPolicies() ReplicaSchedulingPolicyInformer {
|
||||
return &replicaSchedulingPolicyInformer{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"
|
||||
|
||||
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/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/policy/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"
|
||||
)
|
||||
|
||||
// ReplicaSchedulingPolicyInformer provides access to a shared informer and lister for
|
||||
// ReplicaSchedulingPolicies.
|
||||
type ReplicaSchedulingPolicyInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1alpha1.ReplicaSchedulingPolicyLister
|
||||
}
|
||||
|
||||
type replicaSchedulingPolicyInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewReplicaSchedulingPolicyInformer constructs a new informer for ReplicaSchedulingPolicy 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 NewReplicaSchedulingPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredReplicaSchedulingPolicyInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredReplicaSchedulingPolicyInformer constructs a new informer for ReplicaSchedulingPolicy 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 NewFilteredReplicaSchedulingPolicyInformer(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.PolicyV1alpha1().ReplicaSchedulingPolicies(namespace).List(context.TODO(), options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.PolicyV1alpha1().ReplicaSchedulingPolicies(namespace).Watch(context.TODO(), options)
|
||||
},
|
||||
},
|
||||
&policyv1alpha1.ReplicaSchedulingPolicy{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *replicaSchedulingPolicyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredReplicaSchedulingPolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *replicaSchedulingPolicyInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&policyv1alpha1.ReplicaSchedulingPolicy{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *replicaSchedulingPolicyInformer) Lister() v1alpha1.ReplicaSchedulingPolicyLister {
|
||||
return v1alpha1.NewReplicaSchedulingPolicyLister(f.Informer().GetIndexer())
|
||||
}
|
|
@ -25,3 +25,11 @@ type PropagationPolicyListerExpansion interface{}
|
|||
// PropagationPolicyNamespaceListerExpansion allows custom methods to be added to
|
||||
// PropagationPolicyNamespaceLister.
|
||||
type PropagationPolicyNamespaceListerExpansion interface{}
|
||||
|
||||
// ReplicaSchedulingPolicyListerExpansion allows custom methods to be added to
|
||||
// ReplicaSchedulingPolicyLister.
|
||||
type ReplicaSchedulingPolicyListerExpansion interface{}
|
||||
|
||||
// ReplicaSchedulingPolicyNamespaceListerExpansion allows custom methods to be added to
|
||||
// ReplicaSchedulingPolicyNamespaceLister.
|
||||
type ReplicaSchedulingPolicyNamespaceListerExpansion interface{}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
// Code generated by lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// ReplicaSchedulingPolicyLister helps list ReplicaSchedulingPolicies.
|
||||
// All objects returned here must be treated as read-only.
|
||||
type ReplicaSchedulingPolicyLister interface {
|
||||
// List lists all ReplicaSchedulingPolicies in the indexer.
|
||||
// Objects returned here must be treated as read-only.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.ReplicaSchedulingPolicy, err error)
|
||||
// ReplicaSchedulingPolicies returns an object that can list and get ReplicaSchedulingPolicies.
|
||||
ReplicaSchedulingPolicies(namespace string) ReplicaSchedulingPolicyNamespaceLister
|
||||
ReplicaSchedulingPolicyListerExpansion
|
||||
}
|
||||
|
||||
// replicaSchedulingPolicyLister implements the ReplicaSchedulingPolicyLister interface.
|
||||
type replicaSchedulingPolicyLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewReplicaSchedulingPolicyLister returns a new ReplicaSchedulingPolicyLister.
|
||||
func NewReplicaSchedulingPolicyLister(indexer cache.Indexer) ReplicaSchedulingPolicyLister {
|
||||
return &replicaSchedulingPolicyLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all ReplicaSchedulingPolicies in the indexer.
|
||||
func (s *replicaSchedulingPolicyLister) List(selector labels.Selector) (ret []*v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.ReplicaSchedulingPolicy))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// ReplicaSchedulingPolicies returns an object that can list and get ReplicaSchedulingPolicies.
|
||||
func (s *replicaSchedulingPolicyLister) ReplicaSchedulingPolicies(namespace string) ReplicaSchedulingPolicyNamespaceLister {
|
||||
return replicaSchedulingPolicyNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
}
|
||||
|
||||
// ReplicaSchedulingPolicyNamespaceLister helps list and get ReplicaSchedulingPolicies.
|
||||
// All objects returned here must be treated as read-only.
|
||||
type ReplicaSchedulingPolicyNamespaceLister interface {
|
||||
// List lists all ReplicaSchedulingPolicies in the indexer for a given namespace.
|
||||
// Objects returned here must be treated as read-only.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.ReplicaSchedulingPolicy, err error)
|
||||
// Get retrieves the ReplicaSchedulingPolicy from the indexer for a given namespace and name.
|
||||
// Objects returned here must be treated as read-only.
|
||||
Get(name string) (*v1alpha1.ReplicaSchedulingPolicy, error)
|
||||
ReplicaSchedulingPolicyNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// replicaSchedulingPolicyNamespaceLister implements the ReplicaSchedulingPolicyNamespaceLister
|
||||
// interface.
|
||||
type replicaSchedulingPolicyNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all ReplicaSchedulingPolicies in the indexer for a given namespace.
|
||||
func (s replicaSchedulingPolicyNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ReplicaSchedulingPolicy, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.ReplicaSchedulingPolicy))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the ReplicaSchedulingPolicy from the indexer for a given namespace and name.
|
||||
func (s replicaSchedulingPolicyNamespaceLister) Get(name string) (*v1alpha1.ReplicaSchedulingPolicy, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1alpha1.Resource("replicaschedulingpolicy"), name)
|
||||
}
|
||||
return obj.(*v1alpha1.ReplicaSchedulingPolicy), nil
|
||||
}
|
Loading…
Reference in New Issue