From f3b7c5d50899eac5088ea763bb129da7a6e30671 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_syncleaf.yaml | 121 ++++++++ pkg/apis/kosmos/v1alpha1/syncleaf_types.go | 166 +++++++++++ .../kosmos/v1alpha1/zz_generated.deepcopy.go | 147 ++++++++++ .../kosmos/v1alpha1/zz_generated.register.go | 2 + .../controllers/syncleaf_controller.go | 44 +++ .../v1alpha1/fake/fake_kosmos_client.go | 4 + .../kosmos/v1alpha1/fake/fake_syncleaf.go | 126 +++++++++ .../kosmos/v1alpha1/generated_expansion.go | 2 + .../typed/kosmos/v1alpha1/kosmos_client.go | 5 + .../typed/kosmos/v1alpha1/syncleaf.go | 179 ++++++++++++ .../informers/externalversions/generic.go | 2 + .../kosmos/v1alpha1/interface.go | 7 + .../kosmos/v1alpha1/syncleaf.go | 74 +++++ .../kosmos/v1alpha1/expansion_generated.go | 8 + .../listers/kosmos/v1alpha1/syncleaf.go | 83 ++++++ pkg/generated/openapi/zz_generated.openapi.go | 263 ++++++++++++++++++ pkg/kosmosctl/manifest/manifest_crds.go | 126 ++++++++- 18 files changed, 1365 insertions(+), 1 deletion(-) create mode 100644 deploy/crds/kosmos.io_syncleaf.yaml create mode 100644 pkg/apis/kosmos/v1alpha1/syncleaf_types.go create mode 100644 pkg/clustertree/cluster-manager/controllers/syncleaf_controller.go create mode 100644 pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_syncleaf.go create mode 100644 pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/syncleaf.go create mode 100644 pkg/generated/informers/externalversions/kosmos/v1alpha1/syncleaf.go create mode 100644 pkg/generated/listers/kosmos/v1alpha1/syncleaf.go diff --git a/cmd/clustertree/cluster-manager/app/manager.go b/cmd/clustertree/cluster-manager/app/manager.go index 5a77d7f4a..fac25de7e 100644 --- a/cmd/clustertree/cluster-manager/app/manager.go +++ b/cmd/clustertree/cluster-manager/app/manager.go @@ -225,6 +225,13 @@ func run(ctx context.Context, opts *options.Options) error { if err := rootPodReconciler.SetupWithManager(mgr); err != nil { return fmt.Errorf("error starting rootPodReconciler %s: %v", podcontrollers.RootPodControllerName, err) } + // + //syncLeafReconciler := controllers.SyncLeafReconciler{ + // Client: mgr.GetClient(), + //} + //if err := syncLeafReconciler.SetupWithManager(mgr); err != nil { + // return fmt.Errorf("error starting rootPodReconciler %s: %v", podcontrollers.RootPodControllerName, err) + //} if !opts.OnewayStorageControllers { rootPVCController := pvc.RootPVCController{ diff --git a/deploy/crds/kosmos.io_syncleaf.yaml b/deploy/crds/kosmos.io_syncleaf.yaml new file mode 100644 index 000000000..e330b0ccd --- /dev/null +++ b/deploy/crds/kosmos.io_syncleaf.yaml @@ -0,0 +1,121 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.13.0 + name: syncleaves.kosmos.io +spec: + group: kosmos.io + names: + kind: SyncLeaf + listKind: SyncLeafList + plural: syncleaves + singular: syncleaf + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: SyncLeaf 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: SyncLeafSpec defines the desired state of SyncLeaf + properties: + 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 + 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 + includedResources: + 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 + type: object + status: + description: SyncLeafStatus defines the observed state of SyncLeaf + 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/pkg/apis/kosmos/v1alpha1/syncleaf_types.go b/pkg/apis/kosmos/v1alpha1/syncleaf_types.go new file mode 100644 index 000000000..69c175cd9 --- /dev/null +++ b/pkg/apis/kosmos/v1alpha1/syncleaf_types.go @@ -0,0 +1,166 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// SyncLeafSpec defines the desired state of SyncLeaf +type SyncLeafSpec struct { + // 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:"includedResources,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"` +} + +// SyncLeafPhase is a string representation of the lifecycle phase +type SyncLeafPhase string + +const ( + // SyncLeafPhasePrecheck means in precheck progess + SyncLeafPhasePrecheck SyncLeafPhase = "Prechecking" + + // SyncLeafPhaseFailedPrecheck means precheck has failed + SyncLeafPhaseFailedPrecheck SyncLeafPhase = "FailedPrecheck" + + // SyncLeafPhaseBackup means in backup progess + SyncLeafPhaseBackup SyncLeafPhase = "Backuping" + + // SyncLeafPhaseFailedBackup means backup has failed + SyncLeafPhaseFailedBackup SyncLeafPhase = "FailedBackup" + + // SyncLeafPhaseDetach means in detach progess + SyncLeafPhaseDetach SyncLeafPhase = "Detaching" + + // SyncLeafPhaseFailedDetach means detach has failed + SyncLeafPhaseFailedDetach SyncLeafPhase = "FailedDetach" + + // SyncLeafPhaseRestore means in restore progess + SyncLeafPhaseRestore SyncLeafPhase = "Restoring" + + // SyncLeafPhaseFailedRestore means restore has failed + SyncLeafPhaseFailedRestore SyncLeafPhase = "FailedRestore" + + // SyncLeafPhaseCompleted means the sync has run successfully + SyncLeafPhaseCompleted SyncLeafPhase = "Completed" +) + +// BackupProgress stores information about the progress of a Backup's execution. +type SyncLeafProgress 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"` +} + +// SyncLeafStatus defines the observed state of SyncLeaf +type SyncLeafStatus struct { + // Phase is the current state of the Backup. + // +optional + Phase SyncLeafPhase `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 *SyncLeafProgress `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 + +// SyncLeaf is custom resource that represents the capture of sync leaf cluster +type SyncLeaf struct { + metav1.TypeMeta `json:",inline"` + + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SyncLeafSpec `json:"spec,omitempty"` + + Status SyncLeafStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BackupList is a list of SyncLeafs. +type SyncLeafList struct { + metav1.TypeMeta `json:",inline"` + + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + Items []SyncLeaf `json:"items"` +} diff --git a/pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go index 6ba746a20..d96d5935a 100644 --- a/pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go @@ -1133,6 +1133,153 @@ func (in *ShadowDaemonSetList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SyncLeaf) DeepCopyInto(out *SyncLeaf) { + *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 SyncLeaf. +func (in *SyncLeaf) DeepCopy() *SyncLeaf { + if in == nil { + return nil + } + out := new(SyncLeaf) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SyncLeaf) 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 *SyncLeafList) DeepCopyInto(out *SyncLeafList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SyncLeaf, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncLeafList. +func (in *SyncLeafList) DeepCopy() *SyncLeafList { + if in == nil { + return nil + } + out := new(SyncLeafList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SyncLeafList) 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 *SyncLeafProgress) DeepCopyInto(out *SyncLeafProgress) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncLeafProgress. +func (in *SyncLeafProgress) DeepCopy() *SyncLeafProgress { + if in == nil { + return nil + } + out := new(SyncLeafProgress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SyncLeafSpec) DeepCopyInto(out *SyncLeafSpec) { + *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 SyncLeafSpec. +func (in *SyncLeafSpec) DeepCopy() *SyncLeafSpec { + if in == nil { + return nil + } + out := new(SyncLeafSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SyncLeafStatus) DeepCopyInto(out *SyncLeafStatus) { + *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(SyncLeafProgress) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncLeafStatus. +func (in *SyncLeafStatus) DeepCopy() *SyncLeafStatus { + if in == nil { + return nil + } + out := new(SyncLeafStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TolerationConverter) DeepCopyInto(out *TolerationConverter) { *out = *in diff --git a/pkg/apis/kosmos/v1alpha1/zz_generated.register.go b/pkg/apis/kosmos/v1alpha1/zz_generated.register.go index 42af84880..7802414e8 100644 --- a/pkg/apis/kosmos/v1alpha1/zz_generated.register.go +++ b/pkg/apis/kosmos/v1alpha1/zz_generated.register.go @@ -57,6 +57,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &Proxy{}, &ShadowDaemonSet{}, &ShadowDaemonSetList{}, + &SyncLeaf{}, + &SyncLeafList{}, ) // AddToGroupVersion allows the serialization of client types like ListOptions. v1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/pkg/clustertree/cluster-manager/controllers/syncleaf_controller.go b/pkg/clustertree/cluster-manager/controllers/syncleaf_controller.go new file mode 100644 index 000000000..77965e711 --- /dev/null +++ b/pkg/clustertree/cluster-manager/controllers/syncleaf_controller.go @@ -0,0 +1,44 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controllers + +import ( + "context" + "k8s.io/klog" + + kosmosv1alpha1 "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// SyncLeafReconciler reconciles a SyncLeaf object +type SyncLeafReconciler struct { + client.Client +} + +func (r *SyncLeafReconciler) 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 *SyncLeafReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&kosmosv1alpha1.SyncLeaf{}). + 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..04ff31ddc 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 @@ -40,6 +40,10 @@ func (c *FakeKosmosV1alpha1) ShadowDaemonSets(namespace string) v1alpha1.ShadowD return &FakeShadowDaemonSets{c, namespace} } +func (c *FakeKosmosV1alpha1) SyncLeaves(namespace string) v1alpha1.SyncLeafInterface { + return &FakeSyncLeaves{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeKosmosV1alpha1) RESTClient() rest.Interface { diff --git a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_syncleaf.go b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_syncleaf.go new file mode 100644 index 000000000..9034ebbbf --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/fake/fake_syncleaf.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" +) + +// FakeSyncLeaves implements SyncLeafInterface +type FakeSyncLeaves struct { + Fake *FakeKosmosV1alpha1 + ns string +} + +var syncleavesResource = schema.GroupVersionResource{Group: "kosmos.io", Version: "v1alpha1", Resource: "syncleaves"} + +var syncleavesKind = schema.GroupVersionKind{Group: "kosmos.io", Version: "v1alpha1", Kind: "SyncLeaf"} + +// Get takes name of the syncLeaf, and returns the corresponding syncLeaf object, and an error if there is any. +func (c *FakeSyncLeaves) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SyncLeaf, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(syncleavesResource, c.ns, name), &v1alpha1.SyncLeaf{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SyncLeaf), err +} + +// List takes label and field selectors, and returns the list of SyncLeaves that match those selectors. +func (c *FakeSyncLeaves) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SyncLeafList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(syncleavesResource, syncleavesKind, c.ns, opts), &v1alpha1.SyncLeafList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.SyncLeafList{ListMeta: obj.(*v1alpha1.SyncLeafList).ListMeta} + for _, item := range obj.(*v1alpha1.SyncLeafList).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 syncLeaves. +func (c *FakeSyncLeaves) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(syncleavesResource, c.ns, opts)) + +} + +// Create takes the representation of a syncLeaf and creates it. Returns the server's representation of the syncLeaf, and an error, if there is any. +func (c *FakeSyncLeaves) Create(ctx context.Context, syncLeaf *v1alpha1.SyncLeaf, opts v1.CreateOptions) (result *v1alpha1.SyncLeaf, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(syncleavesResource, c.ns, syncLeaf), &v1alpha1.SyncLeaf{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SyncLeaf), err +} + +// Update takes the representation of a syncLeaf and updates it. Returns the server's representation of the syncLeaf, and an error, if there is any. +func (c *FakeSyncLeaves) Update(ctx context.Context, syncLeaf *v1alpha1.SyncLeaf, opts v1.UpdateOptions) (result *v1alpha1.SyncLeaf, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(syncleavesResource, c.ns, syncLeaf), &v1alpha1.SyncLeaf{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SyncLeaf), 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 *FakeSyncLeaves) UpdateStatus(ctx context.Context, syncLeaf *v1alpha1.SyncLeaf, opts v1.UpdateOptions) (*v1alpha1.SyncLeaf, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(syncleavesResource, "status", c.ns, syncLeaf), &v1alpha1.SyncLeaf{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SyncLeaf), err +} + +// Delete takes name of the syncLeaf and deletes it. Returns an error if one occurs. +func (c *FakeSyncLeaves) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(syncleavesResource, c.ns, name, opts), &v1alpha1.SyncLeaf{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSyncLeaves) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(syncleavesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.SyncLeafList{}) + return err +} + +// Patch applies the patch and returns the patched syncLeaf. +func (c *FakeSyncLeaves) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SyncLeaf, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(syncleavesResource, c.ns, name, pt, data, subresources...), &v1alpha1.SyncLeaf{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SyncLeaf), 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..4f5a2af9d 100644 --- a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/generated_expansion.go @@ -15,3 +15,5 @@ type NodeConfigExpansion interface{} type PodConvertPolicyExpansion interface{} type ShadowDaemonSetExpansion interface{} + +type SyncLeafExpansion 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..425f7f3b9 100644 --- a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/kosmos_client.go +++ b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/kosmos_client.go @@ -19,6 +19,7 @@ type KosmosV1alpha1Interface interface { NodeConfigsGetter PodConvertPoliciesGetter ShadowDaemonSetsGetter + SyncLeavesGetter } // KosmosV1alpha1Client is used to interact with features provided by the kosmos.io group. @@ -54,6 +55,10 @@ func (c *KosmosV1alpha1Client) ShadowDaemonSets(namespace string) ShadowDaemonSe return newShadowDaemonSets(c, namespace) } +func (c *KosmosV1alpha1Client) SyncLeaves(namespace string) SyncLeafInterface { + return newSyncLeaves(c, namespace) +} + // NewForConfig creates a new KosmosV1alpha1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). diff --git a/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/syncleaf.go b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/syncleaf.go new file mode 100644 index 000000000..3eb77aab7 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/kosmos/v1alpha1/syncleaf.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" +) + +// SyncLeavesGetter has a method to return a SyncLeafInterface. +// A group's client should implement this interface. +type SyncLeavesGetter interface { + SyncLeaves(namespace string) SyncLeafInterface +} + +// SyncLeafInterface has methods to work with SyncLeaf resources. +type SyncLeafInterface interface { + Create(ctx context.Context, syncLeaf *v1alpha1.SyncLeaf, opts v1.CreateOptions) (*v1alpha1.SyncLeaf, error) + Update(ctx context.Context, syncLeaf *v1alpha1.SyncLeaf, opts v1.UpdateOptions) (*v1alpha1.SyncLeaf, error) + UpdateStatus(ctx context.Context, syncLeaf *v1alpha1.SyncLeaf, opts v1.UpdateOptions) (*v1alpha1.SyncLeaf, 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.SyncLeaf, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SyncLeafList, 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.SyncLeaf, err error) + SyncLeafExpansion +} + +// syncLeaves implements SyncLeafInterface +type syncLeaves struct { + client rest.Interface + ns string +} + +// newSyncLeaves returns a SyncLeaves +func newSyncLeaves(c *KosmosV1alpha1Client, namespace string) *syncLeaves { + return &syncLeaves{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the syncLeaf, and returns the corresponding syncLeaf object, and an error if there is any. +func (c *syncLeaves) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SyncLeaf, err error) { + result = &v1alpha1.SyncLeaf{} + err = c.client.Get(). + Namespace(c.ns). + Resource("syncleaves"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SyncLeaves that match those selectors. +func (c *syncLeaves) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SyncLeafList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.SyncLeafList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("syncleaves"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested syncLeaves. +func (c *syncLeaves) 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("syncleaves"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a syncLeaf and creates it. Returns the server's representation of the syncLeaf, and an error, if there is any. +func (c *syncLeaves) Create(ctx context.Context, syncLeaf *v1alpha1.SyncLeaf, opts v1.CreateOptions) (result *v1alpha1.SyncLeaf, err error) { + result = &v1alpha1.SyncLeaf{} + err = c.client.Post(). + Namespace(c.ns). + Resource("syncleaves"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(syncLeaf). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a syncLeaf and updates it. Returns the server's representation of the syncLeaf, and an error, if there is any. +func (c *syncLeaves) Update(ctx context.Context, syncLeaf *v1alpha1.SyncLeaf, opts v1.UpdateOptions) (result *v1alpha1.SyncLeaf, err error) { + result = &v1alpha1.SyncLeaf{} + err = c.client.Put(). + Namespace(c.ns). + Resource("syncleaves"). + Name(syncLeaf.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(syncLeaf). + 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 *syncLeaves) UpdateStatus(ctx context.Context, syncLeaf *v1alpha1.SyncLeaf, opts v1.UpdateOptions) (result *v1alpha1.SyncLeaf, err error) { + result = &v1alpha1.SyncLeaf{} + err = c.client.Put(). + Namespace(c.ns). + Resource("syncleaves"). + Name(syncLeaf.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(syncLeaf). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the syncLeaf and deletes it. Returns an error if one occurs. +func (c *syncLeaves) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("syncleaves"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *syncLeaves) 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("syncleaves"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched syncLeaf. +func (c *syncLeaves) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SyncLeaf, err error) { + result = &v1alpha1.SyncLeaf{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("syncleaves"). + 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..9772a9053 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -52,6 +52,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Kosmos().V1alpha1().PodConvertPolicies().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("shadowdaemonsets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Kosmos().V1alpha1().ShadowDaemonSets().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("syncleaves"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Kosmos().V1alpha1().SyncLeaves().Informer()}, nil // Group=multicluster.x-k8s.io, Version=v1alpha1 case apisv1alpha1.SchemeGroupVersion.WithResource("serviceexports"): diff --git a/pkg/generated/informers/externalversions/kosmos/v1alpha1/interface.go b/pkg/generated/informers/externalversions/kosmos/v1alpha1/interface.go index 4768655ab..f2d9b1ade 100644 --- a/pkg/generated/informers/externalversions/kosmos/v1alpha1/interface.go +++ b/pkg/generated/informers/externalversions/kosmos/v1alpha1/interface.go @@ -22,6 +22,8 @@ type Interface interface { PodConvertPolicies() PodConvertPolicyInformer // ShadowDaemonSets returns a ShadowDaemonSetInformer. ShadowDaemonSets() ShadowDaemonSetInformer + // SyncLeaves returns a SyncLeafInformer. + SyncLeaves() SyncLeafInformer } type version struct { @@ -69,3 +71,8 @@ func (v *version) PodConvertPolicies() PodConvertPolicyInformer { func (v *version) ShadowDaemonSets() ShadowDaemonSetInformer { return &shadowDaemonSetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } + +// SyncLeaves returns a SyncLeafInformer. +func (v *version) SyncLeaves() SyncLeafInformer { + return &syncLeafInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/generated/informers/externalversions/kosmos/v1alpha1/syncleaf.go b/pkg/generated/informers/externalversions/kosmos/v1alpha1/syncleaf.go new file mode 100644 index 000000000..fbd3651e8 --- /dev/null +++ b/pkg/generated/informers/externalversions/kosmos/v1alpha1/syncleaf.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" +) + +// SyncLeafInformer provides access to a shared informer and lister for +// SyncLeaves. +type SyncLeafInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.SyncLeafLister +} + +type syncLeafInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewSyncLeafInformer constructs a new informer for SyncLeaf 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 NewSyncLeafInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSyncLeafInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredSyncLeafInformer constructs a new informer for SyncLeaf 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 NewFilteredSyncLeafInformer(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().SyncLeaves(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KosmosV1alpha1().SyncLeaves(namespace).Watch(context.TODO(), options) + }, + }, + &kosmosv1alpha1.SyncLeaf{}, + resyncPeriod, + indexers, + ) +} + +func (f *syncLeafInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSyncLeafInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *syncLeafInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kosmosv1alpha1.SyncLeaf{}, f.defaultInformer) +} + +func (f *syncLeafInformer) Lister() v1alpha1.SyncLeafLister { + return v1alpha1.NewSyncLeafLister(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..bfa79bdfe 100644 --- a/pkg/generated/listers/kosmos/v1alpha1/expansion_generated.go +++ b/pkg/generated/listers/kosmos/v1alpha1/expansion_generated.go @@ -41,3 +41,11 @@ type ShadowDaemonSetListerExpansion interface{} // ShadowDaemonSetNamespaceListerExpansion allows custom methods to be added to // ShadowDaemonSetNamespaceLister. type ShadowDaemonSetNamespaceListerExpansion interface{} + +// SyncLeafListerExpansion allows custom methods to be added to +// SyncLeafLister. +type SyncLeafListerExpansion interface{} + +// SyncLeafNamespaceListerExpansion allows custom methods to be added to +// SyncLeafNamespaceLister. +type SyncLeafNamespaceListerExpansion interface{} diff --git a/pkg/generated/listers/kosmos/v1alpha1/syncleaf.go b/pkg/generated/listers/kosmos/v1alpha1/syncleaf.go new file mode 100644 index 000000000..f53857af3 --- /dev/null +++ b/pkg/generated/listers/kosmos/v1alpha1/syncleaf.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" +) + +// SyncLeafLister helps list SyncLeaves. +// All objects returned here must be treated as read-only. +type SyncLeafLister interface { + // List lists all SyncLeaves in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.SyncLeaf, err error) + // SyncLeaves returns an object that can list and get SyncLeaves. + SyncLeaves(namespace string) SyncLeafNamespaceLister + SyncLeafListerExpansion +} + +// syncLeafLister implements the SyncLeafLister interface. +type syncLeafLister struct { + indexer cache.Indexer +} + +// NewSyncLeafLister returns a new SyncLeafLister. +func NewSyncLeafLister(indexer cache.Indexer) SyncLeafLister { + return &syncLeafLister{indexer: indexer} +} + +// List lists all SyncLeaves in the indexer. +func (s *syncLeafLister) List(selector labels.Selector) (ret []*v1alpha1.SyncLeaf, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.SyncLeaf)) + }) + return ret, err +} + +// SyncLeaves returns an object that can list and get SyncLeaves. +func (s *syncLeafLister) SyncLeaves(namespace string) SyncLeafNamespaceLister { + return syncLeafNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// SyncLeafNamespaceLister helps list and get SyncLeaves. +// All objects returned here must be treated as read-only. +type SyncLeafNamespaceLister interface { + // List lists all SyncLeaves in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.SyncLeaf, err error) + // Get retrieves the SyncLeaf from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.SyncLeaf, error) + SyncLeafNamespaceListerExpansion +} + +// syncLeafNamespaceLister implements the SyncLeafNamespaceLister +// interface. +type syncLeafNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all SyncLeaves in the indexer for a given namespace. +func (s syncLeafNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.SyncLeaf, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.SyncLeaf)) + }) + return ret, err +} + +// Get retrieves the SyncLeaf from the indexer for a given namespace and name. +func (s syncLeafNamespaceLister) Get(name string) (*v1alpha1.SyncLeaf, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("syncleaf"), name) + } + return obj.(*v1alpha1.SyncLeaf), nil +} diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 8872dc8ca..b66f74822 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -59,6 +59,11 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SchedulerNameConverter": schema_pkg_apis_kosmos_v1alpha1_SchedulerNameConverter(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.ShadowDaemonSet": schema_pkg_apis_kosmos_v1alpha1_ShadowDaemonSet(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.ShadowDaemonSetList": schema_pkg_apis_kosmos_v1alpha1_ShadowDaemonSetList(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeaf": schema_pkg_apis_kosmos_v1alpha1_SyncLeaf(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeafList": schema_pkg_apis_kosmos_v1alpha1_SyncLeafList(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeafProgress": schema_pkg_apis_kosmos_v1alpha1_SyncLeafProgress(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeafSpec": schema_pkg_apis_kosmos_v1alpha1_SyncLeafSpec(ref), + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeafStatus": schema_pkg_apis_kosmos_v1alpha1_SyncLeafStatus(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.TolerationConverter": schema_pkg_apis_kosmos_v1alpha1_TolerationConverter(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.TopologySpreadConstraintsConverter": schema_pkg_apis_kosmos_v1alpha1_TopologySpreadConstraintsConverter(ref), "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.VxlanCIDRs": schema_pkg_apis_kosmos_v1alpha1_VxlanCIDRs(ref), @@ -2043,6 +2048,264 @@ func schema_pkg_apis_kosmos_v1alpha1_ShadowDaemonSetList(ref common.ReferenceCal } } +func schema_pkg_apis_kosmos_v1alpha1_SyncLeaf(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SyncLeaf 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.SyncLeafSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeafStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeafSpec", "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeafStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_pkg_apis_kosmos_v1alpha1_SyncLeafList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "BackupList is a list of SyncLeafs.", + 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.SyncLeaf"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeaf", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_pkg_apis_kosmos_v1alpha1_SyncLeafProgress(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_SyncLeafSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SyncLeafSpec defines the desired state of SyncLeaf", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "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: "", + }, + }, + }, + }, + }, + "includedResources": { + 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_SyncLeafStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SyncLeafStatus defines the observed state of SyncLeaf", + 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.SyncLeafProgress"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1.SyncLeafProgress", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + func schema_pkg_apis_kosmos_v1alpha1_TolerationConverter(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..b8f6f07c8 100644 --- a/pkg/kosmosctl/manifest/manifest_crds.go +++ b/pkg/kosmosctl/manifest/manifest_crds.go @@ -420,6 +420,8 @@ spec: properties: clusterLinkOptions: properties: + autodetectionMethod: + type: string bridgeCIDRs: default: ip: 220.0.0.0/8 @@ -652,7 +654,6 @@ spec: storage: true subresources: {} ` - const NodeConfig = `--- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -1418,3 +1419,126 @@ spec: type CRDReplace struct { Namespace string } + +const SyncLeaf = `--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.13.0 + name: syncleaves.kosmos.io +spec: + group: kosmos.io + names: + kind: SyncLeaf + listKind: SyncLeafList + plural: syncleaves + singular: syncleaf + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: SyncLeaf 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: SyncLeafSpec defines the desired state of SyncLeaf + properties: + 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 + 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 + includedResources: + 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 + type: object + status: + description: SyncLeafStatus defines the observed state of SyncLeaf + 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 +`