From abf69ea418263bddaea95c20ef3e3a51ff241f95 Mon Sep 17 00:00:00 2001 From: renxiangyu Date: Mon, 29 Jan 2024 09:04:36 +0800 Subject: [PATCH] feature: syncleaf CRD and informer init Signed-off-by: renxiangyu --- .../cluster-manager/app/manager.go | 7 + deploy/crds/kosmos.io_promotepolicies.yaml | 125 ++++++++ examples/promote_policy_demo.yaml | 18 ++ .../kosmos/v1alpha1/promotepolicy_types.go | 153 ++++++++++ .../kosmos/v1alpha1/zz_generated.deepcopy.go | 147 ++++++++++ .../kosmos/v1alpha1/zz_generated.register.go | 2 + .../controllers/promote_policy_controller.go | 35 +++ .../v1alpha1/fake/fake_kosmos_client.go | 4 + .../v1alpha1/fake/fake_promotepolicy.go | 126 ++++++++ .../kosmos/v1alpha1/generated_expansion.go | 2 + .../typed/kosmos/v1alpha1/kosmos_client.go | 5 + .../typed/kosmos/v1alpha1/promotepolicy.go | 179 ++++++++++++ .../informers/externalversions/generic.go | 2 + .../kosmos/v1alpha1/interface.go | 7 + .../kosmos/v1alpha1/promotepolicy.go | 74 +++++ .../kosmos/v1alpha1/expansion_generated.go | 8 + .../listers/kosmos/v1alpha1/promotepolicy.go | 83 ++++++ pkg/generated/openapi/zz_generated.openapi.go | 270 ++++++++++++++++++ pkg/kosmosctl/manifest/manifest_crds.go | 1 - 19 files changed, 1247 insertions(+), 1 deletion(-) create mode 100644 deploy/crds/kosmos.io_promotepolicies.yaml create mode 100644 examples/promote_policy_demo.yaml create mode 100644 pkg/apis/kosmos/v1alpha1/promotepolicy_types.go create mode 100644 pkg/clustertree/cluster-manager/controllers/promote_policy_controller.go create mode 100644 pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_promotepolicy.go create mode 100644 pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/promotepolicy.go create mode 100644 pkg/generated/informers/externalversions/kosmos/v1alpha1/promotepolicy.go create mode 100644 pkg/generated/listers/kosmos/v1alpha1/promotepolicy.go diff --git a/cmd/clustertree/cluster-manager/app/manager.go b/cmd/clustertree/cluster-manager/app/manager.go index 1ad98cda5..10fb82613 100644 --- a/cmd/clustertree/cluster-manager/app/manager.go +++ b/cmd/clustertree/cluster-manager/app/manager.go @@ -234,6 +234,13 @@ func run(ctx context.Context, opts *options.Options) error { return fmt.Errorf("error starting root pvc controller %v", err) } + promotePolicyController := controllers.PromotePolicyController{ + Client: mgr.GetClient(), + } + if err := promotePolicyController.SetupWithManager(mgr); err != nil { + return fmt.Errorf("error starting promotePolicyController %s: %v", controllers.PromotePolicyControllerName, err) + } + rootPVController := pv.RootPVController{ RootClient: mgr.GetClient(), GlobalLeafManager: globalleafManager, diff --git a/deploy/crds/kosmos.io_promotepolicies.yaml b/deploy/crds/kosmos.io_promotepolicies.yaml new file mode 100644 index 000000000..f2e0ecd38 --- /dev/null +++ b/deploy/crds/kosmos.io_promotepolicies.yaml @@ -0,0 +1,125 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.11.0 + creationTimestamp: null + name: promotepolicies.kosmos.io +spec: + group: kosmos.io + names: + kind: PromotePolicy + listKind: PromotePolicyList + plural: promotepolicies + singular: promotepolicy + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: PromotePolicy is custom resource that represents the capture + of sync leaf cluster + 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: PromotePolicySpec defines the desired state of promotePolicy + properties: + clusterName: + description: Cluster is a cluster that needs to be migrated + type: string + excludedNamespaceScopedResources: + description: ExcludedNamespaceScopedResources is a slice of namespace-scoped + resource type names to exclude from the backup. If set to "*", all + namespace-scoped resource types are excluded. The default value + is empty. + items: + type: string + nullable: true + type: array + excludedNamespaces: + description: ExcludedNamespaces contains a list of namespaces that + are not included in the backup. + items: + type: string + nullable: true + type: array + includedNamespaceScopedResources: + description: IncludedNamespaceScopedResources is a slice of namespace-scoped + resource type names to include in the backup. The default value + is "*". + items: + type: string + nullable: true + type: array + includedNamespaces: + description: IncludedNamespaces is a slice of namespace names to include + objects from. If empty, all namespaces are included. + items: + type: string + nullable: true + type: array + type: object + status: + description: PromotePolicyStatus defines the observed state of promotePolicy + properties: + completionTimestamp: + description: CompletionTimestamp records the time a sync was completed. + Completion time is recorded even on failed sync. The server's time + is used for CompletionTimestamps + format: date-time + nullable: true + type: string + failureReason: + description: FailureReason is an error that caused the entire sync + to fail. + type: string + phase: + description: Phase is the current state of the Backup. + type: string + precheckErrors: + description: PrecheckErrors is a slice of all precheck errors (if + applicable). + items: + type: string + nullable: true + type: array + progress: + description: Progress contains information about the sync's execution + progress. Note that this information is best-effort only -- if fails + to update it for any reason, it may be inaccurate/stale. + nullable: true + properties: + itemsBackedUp: + description: ItemsBackedUp is the number of items that have actually + been written to the backup tarball so far. + type: integer + totalItems: + description: TotalItems is the total number of items to be backed + up. This number may change throughout the execution of the backup + due to plugins that return additional related items to back + up, the velero.io/exclude-from-backup label, and various other + filters that happen as items are processed. + type: integer + type: object + startTimestamp: + description: StartTimestamp records the time a sync was started. The + server's time is used for StartTimestamps + format: date-time + nullable: true + type: string + type: object + type: object + served: true + storage: true diff --git a/examples/promote_policy_demo.yaml b/examples/promote_policy_demo.yaml new file mode 100644 index 000000000..2440fced4 --- /dev/null +++ b/examples/promote_policy_demo.yaml @@ -0,0 +1,18 @@ +apiVersion: kosmos.io/v1alpha1 +kind: PromotePolicy +metadata: + name: promote-pilicy-sample +spec: + includedNamespaces: + - namespace1 + - namespace2 + excludedNamespaces: + - namespace3 + includedNamespaceScopedResources: + - deployment + - service + excludedNamespaceScopedResources: + - pod + clusterName: + cluster + diff --git a/pkg/apis/kosmos/v1alpha1/promotepolicy_types.go b/pkg/apis/kosmos/v1alpha1/promotepolicy_types.go new file mode 100644 index 000000000..384ee2af8 --- /dev/null +++ b/pkg/apis/kosmos/v1alpha1/promotepolicy_types.go @@ -0,0 +1,153 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// PromotePolicySpec defines the desired state of promotePolicy +type PromotePolicySpec struct { + // Cluster is a cluster that needs to be migrated + ClusterName string `json:"clusterName,omitempty"` + + // IncludedNamespaces is a slice of namespace names to include objects + // from. If empty, all namespaces are included. + // +optional + // +nullable + IncludedNamespaces []string `json:"includedNamespaces,omitempty"` + + // ExcludedNamespaces contains a list of namespaces that are not + // included in the backup. + // +optional + // +nullable + ExcludedNamespaces []string `json:"excludedNamespaces,omitempty"` + + // IncludedNamespaceScopedResources is a slice of namespace-scoped + // resource type names to include in the backup. + // The default value is "*". + // +optional + // +nullable + IncludedNamespaceScopedResources []string `json:"includedNamespaceScopedResources,omitempty"` + + // ExcludedNamespaceScopedResources is a slice of namespace-scoped + // resource type names to exclude from the backup. + // If set to "*", all namespace-scoped resource types are excluded. + // The default value is empty. + // +optional + // +nullable + ExcludedNamespaceScopedResources []string `json:"excludedNamespaceScopedResources,omitempty"` +} + +// PromotePolicyPhase is a string representation of the lifecycle phase +type PromotePolicyPhase string + +const ( + // PromotePolicyPhasePrecheck means in precheck progess + PromotePolicyPhasePrecheck PromotePolicyPhase = "Prechecking" + + // PromotePolicyPhaseFailedPrecheck means precheck has failed + PromotePolicyPhaseFailedPrecheck PromotePolicyPhase = "FailedPrecheck" + + // PromotePolicyPhaseBackup means in backup progess + PromotePolicyPhaseBackup PromotePolicyPhase = "Backuping" + + // PromotePolicyPhaseFailedBackup means backup has failed + PromotePolicyPhaseFailedBackup PromotePolicyPhase = "FailedBackup" + + // PromotePolicyPhaseDetach means in detach progess + PromotePolicyPhaseDetach PromotePolicyPhase = "Detaching" + + // PromotePolicyPhaseFailedDetach means detach has failed + PromotePolicyPhaseFailedDetach PromotePolicyPhase = "FailedDetach" + + // PromotePolicyPhaseRestore means in restore progess + PromotePolicyPhaseRestore PromotePolicyPhase = "Restoring" + + // PromotePolicyPhaseFailedRestore means restore has failed + PromotePolicyPhaseFailedRestore PromotePolicyPhase = "FailedRestore" + + // PromotePolicyPhaseCompleted means the sync has run successfully + PromotePolicyPhaseCompleted PromotePolicyPhase = "Completed" +) + +// BackupProgress stores information about the progress of a Backup's execution. +type PromotePolicyProgress struct { + // TotalItems is the total number of items to be backed up. This number may change + // throughout the execution of the backup due to plugins that return additional related + // items to back up, the velero.io/exclude-from-backup label, and various other + // filters that happen as items are processed. + // +optional + TotalItems int `json:"totalItems,omitempty"` + + // ItemsBackedUp is the number of items that have actually been written to the + // backup tarball so far. + // +optional + ItemsBackedUp int `json:"itemsBackedUp,omitempty"` +} + +// PromotePolicyStatus defines the observed state of promotePolicy +type PromotePolicyStatus struct { + // Phase is the current state of the Backup. + // +optional + Phase PromotePolicyPhase `json:"phase,omitempty"` + + // PrecheckErrors is a slice of all precheck errors (if + // applicable). + // +optional + // +nullable + PrecheckErrors []string `json:"precheckErrors,omitempty"` + + // StartTimestamp records the time a sync was started. + // The server's time is used for StartTimestamps + // +optional + // +nullable + StartTimestamp *metav1.Time `json:"startTimestamp,omitempty"` + + // CompletionTimestamp records the time a sync was completed. + // Completion time is recorded even on failed sync. + // The server's time is used for CompletionTimestamps + // +optional + // +nullable + CompletionTimestamp *metav1.Time `json:"completionTimestamp,omitempty"` + + // FailureReason is an error that caused the entire sync to fail. + // +optional + FailureReason string `json:"failureReason,omitempty"` + + // Progress contains information about the sync's execution progress. Note + // that this information is best-effort only -- if fails to update it for any reason, it may be inaccurate/stale. + // +optional + // +nullable + Progress *PromotePolicyProgress `json:"progress,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:object:generate=true +// +kubebuilder:storageversion +// +kubebuilder:rbac:groups=velero.io,resources=backups,verbs=create;delete;get;list;patch;update;watch +// +kubebuilder:rbac:groups=velero.io,resources=backups/status,verbs=get;update;patch + +// PromotePolicy is custom resource that represents the capture of sync leaf cluster +type PromotePolicy struct { + metav1.TypeMeta `json:",inline"` + + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec PromotePolicySpec `json:"spec,omitempty"` + + Status PromotePolicyStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BackupList is a list of promotePolicys. +type PromotePolicyList struct { + metav1.TypeMeta `json:",inline"` + + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + Items []PromotePolicy `json:"items"` +} diff --git a/pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go index 6ba746a20..919d14ebb 100644 --- a/pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go @@ -1015,6 +1015,153 @@ func (in *PodConvertPolicySpec) DeepCopy() *PodConvertPolicySpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromotePolicy) DeepCopyInto(out *PromotePolicy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromotePolicy. +func (in *PromotePolicy) DeepCopy() *PromotePolicy { + if in == nil { + return nil + } + out := new(PromotePolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PromotePolicy) 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 *PromotePolicyList) DeepCopyInto(out *PromotePolicyList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PromotePolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromotePolicyList. +func (in *PromotePolicyList) DeepCopy() *PromotePolicyList { + if in == nil { + return nil + } + out := new(PromotePolicyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PromotePolicyList) 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 *PromotePolicyProgress) DeepCopyInto(out *PromotePolicyProgress) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromotePolicyProgress. +func (in *PromotePolicyProgress) DeepCopy() *PromotePolicyProgress { + if in == nil { + return nil + } + out := new(PromotePolicyProgress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromotePolicySpec) DeepCopyInto(out *PromotePolicySpec) { + *out = *in + if in.IncludedNamespaces != nil { + in, out := &in.IncludedNamespaces, &out.IncludedNamespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ExcludedNamespaces != nil { + in, out := &in.ExcludedNamespaces, &out.ExcludedNamespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.IncludedNamespaceScopedResources != nil { + in, out := &in.IncludedNamespaceScopedResources, &out.IncludedNamespaceScopedResources + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ExcludedNamespaceScopedResources != nil { + in, out := &in.ExcludedNamespaceScopedResources, &out.ExcludedNamespaceScopedResources + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromotePolicySpec. +func (in *PromotePolicySpec) DeepCopy() *PromotePolicySpec { + if in == nil { + return nil + } + out := new(PromotePolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromotePolicyStatus) DeepCopyInto(out *PromotePolicyStatus) { + *out = *in + if in.PrecheckErrors != nil { + in, out := &in.PrecheckErrors, &out.PrecheckErrors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.StartTimestamp != nil { + in, out := &in.StartTimestamp, &out.StartTimestamp + *out = (*in).DeepCopy() + } + if in.CompletionTimestamp != nil { + in, out := &in.CompletionTimestamp, &out.CompletionTimestamp + *out = (*in).DeepCopy() + } + if in.Progress != nil { + in, out := &in.Progress, &out.Progress + *out = new(PromotePolicyProgress) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromotePolicyStatus. +func (in *PromotePolicyStatus) DeepCopy() *PromotePolicyStatus { + if in == nil { + return nil + } + out := new(PromotePolicyStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Proxy) DeepCopyInto(out *Proxy) { *out = *in diff --git a/pkg/apis/kosmos/v1alpha1/zz_generated.register.go b/pkg/apis/kosmos/v1alpha1/zz_generated.register.go index 42af84880..49da0ece2 100644 --- a/pkg/apis/kosmos/v1alpha1/zz_generated.register.go +++ b/pkg/apis/kosmos/v1alpha1/zz_generated.register.go @@ -54,6 +54,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &NodeConfigList{}, &PodConvertPolicy{}, &PodConvertPolicyList{}, + &PromotePolicy{}, + &PromotePolicyList{}, &Proxy{}, &ShadowDaemonSet{}, &ShadowDaemonSetList{}, diff --git a/pkg/clustertree/cluster-manager/controllers/promote_policy_controller.go b/pkg/clustertree/cluster-manager/controllers/promote_policy_controller.go new file mode 100644 index 000000000..77404751c --- /dev/null +++ b/pkg/clustertree/cluster-manager/controllers/promote_policy_controller.go @@ -0,0 +1,35 @@ +package controllers + +import ( + "context" + "time" + + "k8s.io/klog" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + + kosmosv1alpha1 "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1" +) + +const ( + PromotePolicyControllerName = "sync-leaf-controller" + PromotePolicyRequeueTime = 10 * time.Second +) + +// PromotePolicyReconciler reconciles a promotePolicy object +type PromotePolicyController struct { + client.Client +} + +func (r *PromotePolicyController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + // todo + klog.Info("Reconcile") + return ctrl.Result{}, nil +} + +// SetupWithManager sets up the controller with the Manager. +func (r *PromotePolicyController) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&kosmosv1alpha1.PromotePolicy{}). + Complete(r) +} diff --git a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_kosmos_client.go b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_kosmos_client.go index c74de6468..60fc1c882 100644 --- a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_kosmos_client.go +++ b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_kosmos_client.go @@ -36,6 +36,10 @@ func (c *FakeKosmosV1alpha1) PodConvertPolicies(namespace string) v1alpha1.PodCo return &FakePodConvertPolicies{c, namespace} } +func (c *FakeKosmosV1alpha1) PromotePolicies(namespace string) v1alpha1.PromotePolicyInterface { + return &FakePromotePolicies{c, namespace} +} + func (c *FakeKosmosV1alpha1) ShadowDaemonSets(namespace string) v1alpha1.ShadowDaemonSetInterface { return &FakeShadowDaemonSets{c, namespace} } diff --git a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_promotepolicy.go b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_promotepolicy.go new file mode 100644 index 000000000..5949310ef --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_promotepolicy.go @@ -0,0 +1,126 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/kosmos.io/kosmos/pkg/apis/kosmos/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" +) + +// FakePromotePolicies implements PromotePolicyInterface +type FakePromotePolicies struct { + Fake *FakeKosmosV1alpha1 + ns string +} + +var promotepoliciesResource = schema.GroupVersionResource{Group: "kosmos.io", Version: "v1alpha1", Resource: "promotepolicies"} + +var promotepoliciesKind = schema.GroupVersionKind{Group: "kosmos.io", Version: "v1alpha1", Kind: "PromotePolicy"} + +// Get takes name of the promotePolicy, and returns the corresponding promotePolicy object, and an error if there is any. +func (c *FakePromotePolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PromotePolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(promotepoliciesResource, c.ns, name), &v1alpha1.PromotePolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PromotePolicy), err +} + +// List takes label and field selectors, and returns the list of PromotePolicies that match those selectors. +func (c *FakePromotePolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PromotePolicyList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(promotepoliciesResource, promotepoliciesKind, c.ns, opts), &v1alpha1.PromotePolicyList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PromotePolicyList{ListMeta: obj.(*v1alpha1.PromotePolicyList).ListMeta} + for _, item := range obj.(*v1alpha1.PromotePolicyList).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 promotePolicies. +func (c *FakePromotePolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(promotepoliciesResource, c.ns, opts)) + +} + +// Create takes the representation of a promotePolicy and creates it. Returns the server's representation of the promotePolicy, and an error, if there is any. +func (c *FakePromotePolicies) Create(ctx context.Context, promotePolicy *v1alpha1.PromotePolicy, opts v1.CreateOptions) (result *v1alpha1.PromotePolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(promotepoliciesResource, c.ns, promotePolicy), &v1alpha1.PromotePolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PromotePolicy), err +} + +// Update takes the representation of a promotePolicy and updates it. Returns the server's representation of the promotePolicy, and an error, if there is any. +func (c *FakePromotePolicies) Update(ctx context.Context, promotePolicy *v1alpha1.PromotePolicy, opts v1.UpdateOptions) (result *v1alpha1.PromotePolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(promotepoliciesResource, c.ns, promotePolicy), &v1alpha1.PromotePolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PromotePolicy), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakePromotePolicies) UpdateStatus(ctx context.Context, promotePolicy *v1alpha1.PromotePolicy, opts v1.UpdateOptions) (*v1alpha1.PromotePolicy, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(promotepoliciesResource, "status", c.ns, promotePolicy), &v1alpha1.PromotePolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PromotePolicy), err +} + +// Delete takes name of the promotePolicy and deletes it. Returns an error if one occurs. +func (c *FakePromotePolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(promotepoliciesResource, c.ns, name, opts), &v1alpha1.PromotePolicy{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePromotePolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(promotepoliciesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.PromotePolicyList{}) + return err +} + +// Patch applies the patch and returns the patched promotePolicy. +func (c *FakePromotePolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PromotePolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(promotepoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha1.PromotePolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PromotePolicy), err +} diff --git a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/generated_expansion.go index 49973005a..e4ec53c73 100644 --- a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/generated_expansion.go @@ -14,4 +14,6 @@ type NodeConfigExpansion interface{} type PodConvertPolicyExpansion interface{} +type PromotePolicyExpansion interface{} + type ShadowDaemonSetExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/kosmos_client.go b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/kosmos_client.go index 6340661cb..de3d9add7 100644 --- a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/kosmos_client.go +++ b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/kosmos_client.go @@ -18,6 +18,7 @@ type KosmosV1alpha1Interface interface { KnodesGetter NodeConfigsGetter PodConvertPoliciesGetter + PromotePoliciesGetter ShadowDaemonSetsGetter } @@ -50,6 +51,10 @@ func (c *KosmosV1alpha1Client) PodConvertPolicies(namespace string) PodConvertPo return newPodConvertPolicies(c, namespace) } +func (c *KosmosV1alpha1Client) PromotePolicies(namespace string) PromotePolicyInterface { + return newPromotePolicies(c, namespace) +} + func (c *KosmosV1alpha1Client) ShadowDaemonSets(namespace string) ShadowDaemonSetInterface { return newShadowDaemonSets(c, namespace) } diff --git a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/promotepolicy.go b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/promotepolicy.go new file mode 100644 index 000000000..69cc4829b --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/promotepolicy.go @@ -0,0 +1,179 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1" + scheme "github.com/kosmos.io/kosmos/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" +) + +// PromotePoliciesGetter has a method to return a PromotePolicyInterface. +// A group's client should implement this interface. +type PromotePoliciesGetter interface { + PromotePolicies(namespace string) PromotePolicyInterface +} + +// PromotePolicyInterface has methods to work with PromotePolicy resources. +type PromotePolicyInterface interface { + Create(ctx context.Context, promotePolicy *v1alpha1.PromotePolicy, opts v1.CreateOptions) (*v1alpha1.PromotePolicy, error) + Update(ctx context.Context, promotePolicy *v1alpha1.PromotePolicy, opts v1.UpdateOptions) (*v1alpha1.PromotePolicy, error) + UpdateStatus(ctx context.Context, promotePolicy *v1alpha1.PromotePolicy, opts v1.UpdateOptions) (*v1alpha1.PromotePolicy, 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.PromotePolicy, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PromotePolicyList, 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.PromotePolicy, err error) + PromotePolicyExpansion +} + +// promotePolicies implements PromotePolicyInterface +type promotePolicies struct { + client rest.Interface + ns string +} + +// newPromotePolicies returns a PromotePolicies +func newPromotePolicies(c *KosmosV1alpha1Client, namespace string) *promotePolicies { + return &promotePolicies{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the promotePolicy, and returns the corresponding promotePolicy object, and an error if there is any. +func (c *promotePolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PromotePolicy, err error) { + result = &v1alpha1.PromotePolicy{} + err = c.client.Get(). + Namespace(c.ns). + Resource("promotepolicies"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PromotePolicies that match those selectors. +func (c *promotePolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PromotePolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PromotePolicyList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("promotepolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested promotePolicies. +func (c *promotePolicies) 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("promotepolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a promotePolicy and creates it. Returns the server's representation of the promotePolicy, and an error, if there is any. +func (c *promotePolicies) Create(ctx context.Context, promotePolicy *v1alpha1.PromotePolicy, opts v1.CreateOptions) (result *v1alpha1.PromotePolicy, err error) { + result = &v1alpha1.PromotePolicy{} + err = c.client.Post(). + Namespace(c.ns). + Resource("promotepolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(promotePolicy). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a promotePolicy and updates it. Returns the server's representation of the promotePolicy, and an error, if there is any. +func (c *promotePolicies) Update(ctx context.Context, promotePolicy *v1alpha1.PromotePolicy, opts v1.UpdateOptions) (result *v1alpha1.PromotePolicy, err error) { + result = &v1alpha1.PromotePolicy{} + err = c.client.Put(). + Namespace(c.ns). + Resource("promotepolicies"). + Name(promotePolicy.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(promotePolicy). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *promotePolicies) UpdateStatus(ctx context.Context, promotePolicy *v1alpha1.PromotePolicy, opts v1.UpdateOptions) (result *v1alpha1.PromotePolicy, err error) { + result = &v1alpha1.PromotePolicy{} + err = c.client.Put(). + Namespace(c.ns). + Resource("promotepolicies"). + Name(promotePolicy.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(promotePolicy). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the promotePolicy and deletes it. Returns an error if one occurs. +func (c *promotePolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("promotepolicies"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *promotePolicies) 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("promotepolicies"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched promotePolicy. +func (c *promotePolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PromotePolicy, err error) { + result = &v1alpha1.PromotePolicy{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("promotepolicies"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index b24e17f81..64eebd78e 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -50,6 +50,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Kosmos().V1alpha1().NodeConfigs().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("podconvertpolicies"): return &genericInformer{resource: resource.GroupResource(), informer: f.Kosmos().V1alpha1().PodConvertPolicies().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("promotepolicies"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Kosmos().V1alpha1().PromotePolicies().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("shadowdaemonsets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Kosmos().V1alpha1().ShadowDaemonSets().Informer()}, nil diff --git a/pkg/generated/informers/externalversions/kosmos/v1alpha1/interface.go b/pkg/generated/informers/externalversions/kosmos/v1alpha1/interface.go index 4768655ab..e2d4c7341 100644 --- a/pkg/generated/informers/externalversions/kosmos/v1alpha1/interface.go +++ b/pkg/generated/informers/externalversions/kosmos/v1alpha1/interface.go @@ -20,6 +20,8 @@ type Interface interface { NodeConfigs() NodeConfigInformer // PodConvertPolicies returns a PodConvertPolicyInformer. PodConvertPolicies() PodConvertPolicyInformer + // PromotePolicies returns a PromotePolicyInformer. + PromotePolicies() PromotePolicyInformer // ShadowDaemonSets returns a ShadowDaemonSetInformer. ShadowDaemonSets() ShadowDaemonSetInformer } @@ -65,6 +67,11 @@ func (v *version) PodConvertPolicies() PodConvertPolicyInformer { return &podConvertPolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// PromotePolicies returns a PromotePolicyInformer. +func (v *version) PromotePolicies() PromotePolicyInformer { + return &promotePolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // ShadowDaemonSets returns a ShadowDaemonSetInformer. func (v *version) ShadowDaemonSets() ShadowDaemonSetInformer { return &shadowDaemonSetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/generated/informers/externalversions/kosmos/v1alpha1/promotepolicy.go b/pkg/generated/informers/externalversions/kosmos/v1alpha1/promotepolicy.go new file mode 100644 index 000000000..c174f4516 --- /dev/null +++ b/pkg/generated/informers/externalversions/kosmos/v1alpha1/promotepolicy.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + kosmosv1alpha1 "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1" + versioned "github.com/kosmos.io/kosmos/pkg/generated/clientset/versioned" + internalinterfaces "github.com/kosmos.io/kosmos/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kosmos.io/kosmos/pkg/generated/listers/kosmos/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" +) + +// PromotePolicyInformer provides access to a shared informer and lister for +// PromotePolicies. +type PromotePolicyInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PromotePolicyLister +} + +type promotePolicyInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPromotePolicyInformer constructs a new informer for PromotePolicy 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 NewPromotePolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPromotePolicyInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPromotePolicyInformer constructs a new informer for PromotePolicy 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 NewFilteredPromotePolicyInformer(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.KosmosV1alpha1().PromotePolicies(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KosmosV1alpha1().PromotePolicies(namespace).Watch(context.TODO(), options) + }, + }, + &kosmosv1alpha1.PromotePolicy{}, + resyncPeriod, + indexers, + ) +} + +func (f *promotePolicyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPromotePolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *promotePolicyInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kosmosv1alpha1.PromotePolicy{}, f.defaultInformer) +} + +func (f *promotePolicyInformer) Lister() v1alpha1.PromotePolicyLister { + return v1alpha1.NewPromotePolicyLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/listers/kosmos/v1alpha1/expansion_generated.go b/pkg/generated/listers/kosmos/v1alpha1/expansion_generated.go index e588209cc..b2dc1c5eb 100644 --- a/pkg/generated/listers/kosmos/v1alpha1/expansion_generated.go +++ b/pkg/generated/listers/kosmos/v1alpha1/expansion_generated.go @@ -34,6 +34,14 @@ type PodConvertPolicyListerExpansion interface{} // PodConvertPolicyNamespaceLister. type PodConvertPolicyNamespaceListerExpansion interface{} +// PromotePolicyListerExpansion allows custom methods to be added to +// PromotePolicyLister. +type PromotePolicyListerExpansion interface{} + +// PromotePolicyNamespaceListerExpansion allows custom methods to be added to +// PromotePolicyNamespaceLister. +type PromotePolicyNamespaceListerExpansion interface{} + // ShadowDaemonSetListerExpansion allows custom methods to be added to // ShadowDaemonSetLister. type ShadowDaemonSetListerExpansion interface{} diff --git a/pkg/generated/listers/kosmos/v1alpha1/promotepolicy.go b/pkg/generated/listers/kosmos/v1alpha1/promotepolicy.go new file mode 100644 index 000000000..43598e615 --- /dev/null +++ b/pkg/generated/listers/kosmos/v1alpha1/promotepolicy.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PromotePolicyLister helps list PromotePolicies. +// All objects returned here must be treated as read-only. +type PromotePolicyLister interface { + // List lists all PromotePolicies in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.PromotePolicy, err error) + // PromotePolicies returns an object that can list and get PromotePolicies. + PromotePolicies(namespace string) PromotePolicyNamespaceLister + PromotePolicyListerExpansion +} + +// promotePolicyLister implements the PromotePolicyLister interface. +type promotePolicyLister struct { + indexer cache.Indexer +} + +// NewPromotePolicyLister returns a new PromotePolicyLister. +func NewPromotePolicyLister(indexer cache.Indexer) PromotePolicyLister { + return &promotePolicyLister{indexer: indexer} +} + +// List lists all PromotePolicies in the indexer. +func (s *promotePolicyLister) List(selector labels.Selector) (ret []*v1alpha1.PromotePolicy, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PromotePolicy)) + }) + return ret, err +} + +// PromotePolicies returns an object that can list and get PromotePolicies. +func (s *promotePolicyLister) PromotePolicies(namespace string) PromotePolicyNamespaceLister { + return promotePolicyNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PromotePolicyNamespaceLister helps list and get PromotePolicies. +// All objects returned here must be treated as read-only. +type PromotePolicyNamespaceLister interface { + // List lists all PromotePolicies in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.PromotePolicy, err error) + // Get retrieves the PromotePolicy from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.PromotePolicy, error) + PromotePolicyNamespaceListerExpansion +} + +// promotePolicyNamespaceLister implements the PromotePolicyNamespaceLister +// interface. +type promotePolicyNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PromotePolicies in the indexer for a given namespace. +func (s promotePolicyNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PromotePolicy, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PromotePolicy)) + }) + return ret, err +} + +// Get retrieves the PromotePolicy from the indexer for a given namespace and name. +func (s promotePolicyNamespaceLister) Get(name string) (*v1alpha1.PromotePolicy, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("promotepolicy"), name) + } + return obj.(*v1alpha1.PromotePolicy), nil +} diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 8872dc8ca..e4d28250f 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -54,6 +54,11 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PodConvertPolicy": schema_pkg_apis_kosmos_v1alpha1_PodConvertPolicy(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PodConvertPolicyList": schema_pkg_apis_kosmos_v1alpha1_PodConvertPolicyList(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PodConvertPolicySpec": schema_pkg_apis_kosmos_v1alpha1_PodConvertPolicySpec(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicy": schema_pkg_apis_kosmos_v1alpha1_PromotePolicy(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicyList": schema_pkg_apis_kosmos_v1alpha1_PromotePolicyList(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicyProgress": schema_pkg_apis_kosmos_v1alpha1_PromotePolicyProgress(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicySpec": schema_pkg_apis_kosmos_v1alpha1_PromotePolicySpec(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicyStatus": schema_pkg_apis_kosmos_v1alpha1_PromotePolicyStatus(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.Proxy": schema_pkg_apis_kosmos_v1alpha1_Proxy(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.Route": schema_pkg_apis_kosmos_v1alpha1_Route(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SchedulerNameConverter": schema_pkg_apis_kosmos_v1alpha1_SchedulerNameConverter(ref), @@ -1857,6 +1862,271 @@ func schema_pkg_apis_kosmos_v1alpha1_PodConvertPolicySpec(ref common.ReferenceCa } } +func schema_pkg_apis_kosmos_v1alpha1_PromotePolicy(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PromotePolicy is custom resource that represents the capture of sync leaf cluster", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicySpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicyStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicySpec", "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicyStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_pkg_apis_kosmos_v1alpha1_PromotePolicyList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "BackupList is a list of promotePolicys.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicy"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicy", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_pkg_apis_kosmos_v1alpha1_PromotePolicyProgress(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "BackupProgress stores information about the progress of a Backup's execution.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "totalItems": { + SchemaProps: spec.SchemaProps{ + Description: "TotalItems is the total number of items to be backed up. This number may change throughout the execution of the backup due to plugins that return additional related items to back up, the velero.io/exclude-from-backup label, and various other filters that happen as items are processed.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "itemsBackedUp": { + SchemaProps: spec.SchemaProps{ + Description: "ItemsBackedUp is the number of items that have actually been written to the backup tarball so far.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_kosmos_v1alpha1_PromotePolicySpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PromotePolicySpec defines the desired state of promotePolicy", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "clusterName": { + SchemaProps: spec.SchemaProps{ + Description: "Cluster is a cluster that needs to be migrated", + Type: []string{"string"}, + Format: "", + }, + }, + "includedNamespaces": { + SchemaProps: spec.SchemaProps{ + Description: "IncludedNamespaces is a slice of namespace names to include objects from. If empty, all namespaces are included.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "excludedNamespaces": { + SchemaProps: spec.SchemaProps{ + Description: "ExcludedNamespaces contains a list of namespaces that are not included in the backup.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "includedNamespaceScopedResources": { + SchemaProps: spec.SchemaProps{ + Description: "IncludedNamespaceScopedResources is a slice of namespace-scoped resource type names to include in the backup. The default value is \"*\".", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "excludedNamespaceScopedResources": { + SchemaProps: spec.SchemaProps{ + Description: "ExcludedNamespaceScopedResources is a slice of namespace-scoped resource type names to exclude from the backup. If set to \"*\", all namespace-scoped resource types are excluded. The default value is empty.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_kosmos_v1alpha1_PromotePolicyStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PromotePolicyStatus defines the observed state of promotePolicy", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "phase": { + SchemaProps: spec.SchemaProps{ + Description: "Phase is the current state of the Backup.", + Type: []string{"string"}, + Format: "", + }, + }, + "precheckErrors": { + SchemaProps: spec.SchemaProps{ + Description: "PrecheckErrors is a slice of all precheck errors (if applicable).", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "startTimestamp": { + SchemaProps: spec.SchemaProps{ + Description: "StartTimestamp records the time a sync was started. The server's time is used for StartTimestamps", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "completionTimestamp": { + SchemaProps: spec.SchemaProps{ + Description: "CompletionTimestamp records the time a sync was completed. Completion time is recorded even on failed sync. The server's time is used for CompletionTimestamps", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "failureReason": { + SchemaProps: spec.SchemaProps{ + Description: "FailureReason is an error that caused the entire sync to fail.", + Type: []string{"string"}, + Format: "", + }, + }, + "progress": { + SchemaProps: spec.SchemaProps{ + Description: "Progress contains information about the sync's execution progress. Note that this information is best-effort only -- if fails to update it for any reason, it may be inaccurate/stale.", + Ref: ref("github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicyProgress"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.PromotePolicyProgress", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + func schema_pkg_apis_kosmos_v1alpha1_Proxy(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/pkg/kosmosctl/manifest/manifest_crds.go b/pkg/kosmosctl/manifest/manifest_crds.go index 1174c1550..5400e1f8f 100644 --- a/pkg/kosmosctl/manifest/manifest_crds.go +++ b/pkg/kosmosctl/manifest/manifest_crds.go @@ -652,7 +652,6 @@ spec: storage: true subresources: {} ` - const NodeConfig = `--- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition