Merge branch 'main' into issue-fix-5875

This commit is contained in:
Lyndon-Li
2023-05-18 16:04:00 +08:00
116 changed files with 3676 additions and 785 deletions
@@ -14,11 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
package shared
// PodVolumeOperationProgress represents the progress of a
// PodVolumeBackup/Restore operation
type PodVolumeOperationProgress struct {
// DataMoveOperationProgress represents the progress of a
// data movement operation
// +k8s:deepcopy-gen=true
type DataMoveOperationProgress struct {
// +optional
TotalBytes int64 `json:"totalBytes,omitempty"`
+10
View File
@@ -165,6 +165,16 @@ type BackupSpec struct {
// ResourcePolicy specifies the referenced resource policies that backup should follow
// +optional
ResourcePolicy *v1.TypedLocalObjectReference `json:"resourcePolicy,omitempty"`
// SnapshotMoveData specifies whether snapshot data should be moved
// +optional
// +nullable
SnapshotMoveData *bool `json:"snapshotMoveData,omitempty"`
// DataMover specifies the data mover to be used by the backup.
// If DataMover is "" or "velero", the built-in data mover will be used.
// +optional
DataMover string `json:"datamover,omitempty"`
}
// BackupHooks contains custom behaviors that should be executed at different phases of the backup.
@@ -19,6 +19,8 @@ package v1
import (
corev1api "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
)
// PodVolumeBackupSpec is the specification for a PodVolumeBackup.
@@ -100,7 +102,7 @@ type PodVolumeBackupStatus struct {
// number of backed up bytes. This can be used to display progress information
// about the backup operation.
// +optional
Progress PodVolumeOperationProgress `json:"progress,omitempty"`
Progress shared.DataMoveOperationProgress `json:"progress,omitempty"`
}
// TODO(2.0) After converting all resources to use the runttime-controller client,
@@ -19,6 +19,8 @@ package v1
import (
corev1api "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
)
// PodVolumeRestoreSpec is the specification for a PodVolumeRestore.
@@ -86,7 +88,7 @@ type PodVolumeRestoreStatus struct {
// number of restored bytes. This can be used to display progress information
// about the restore operation.
// +optional
Progress PodVolumeOperationProgress `json:"progress,omitempty"`
Progress shared.DataMoveOperationProgress `json:"progress,omitempty"`
}
// TODO(2.0) After converting all resources to use the runtime-controller client, the genclient and k8s:deepcopy markers will no longer be needed and should be removed.
+5 -15
View File
@@ -376,6 +376,11 @@ func (in *BackupSpec) DeepCopyInto(out *BackupSpec) {
*out = new(corev1.TypedLocalObjectReference)
(*in).DeepCopyInto(*out)
}
if in.SnapshotMoveData != nil {
in, out := &in.SnapshotMoveData, &out.SnapshotMoveData
*out = new(bool)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupSpec.
@@ -977,21 +982,6 @@ func (in *PodVolumeBackupStatus) DeepCopy() *PodVolumeBackupStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodVolumeOperationProgress) DeepCopyInto(out *PodVolumeOperationProgress) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodVolumeOperationProgress.
func (in *PodVolumeOperationProgress) DeepCopy() *PodVolumeOperationProgress {
if in == nil {
return nil
}
out := new(PodVolumeOperationProgress)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodVolumeRestore) DeepCopyInto(out *PodVolumeRestore) {
*out = *in
@@ -0,0 +1,156 @@
/*
Copyright the Velero contributors.
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 v2alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
)
// DataDownloadSpec is the specification for a DataDownload.
type DataDownloadSpec struct {
// TargetVolume is the information of the target PVC and PV.
TargetVolume TargetVolumeSpec `json:"targetVolume"`
// BackupStorageLocation is the name of the backup storage location
// where the backup repository is stored.
BackupStorageLocation string `json:"backupStorageLocation"`
// DataMover specifies the data mover to be used by the backup.
// If DataMover is "" or "velero", the built-in data mover will be used.
// +optional
DataMover string `json:"datamover,omitempty"`
// SnapshotID is the ID of the Velero backup snapshot to be restored from.
SnapshotID string `json:"snapshotID"`
// SourceNamespace is the original namespace where the volume is backed up from.
// It may be different from SourcePVC's namespace if namespace is remapped during restore.
SourceNamespace string `json:"sourceNamespace"`
// DataMoverConfig is for data-mover-specific configuration fields.
// +optional
DataMoverConfig map[string]string `json:"dataMoverConfig,omitempty"`
// Cancel indicates request to cancel the ongoing DataDownload. It can be set
// when the DataDownload is in InProgress phase
Cancel bool `json:"cancel,omitempty"`
// OperationTimeout specifies the time used to wait internal operations,
// before returning error as timeout.
OperationTimeout metav1.Duration `json:"operationTimeout"`
}
// TargetPVCSpec is the specification for a target PVC.
type TargetVolumeSpec struct {
// PVC is the name of the target PVC that is created by Velero restore
PVC string `json:"pvc"`
// PV is the name of the target PV that is created by Velero restore
PV string `json:"pv"`
// Namespace is the target namespace
Namespace string `json:"namespace"`
}
// DataDownloadPhase represents the lifecycle phase of a DataDownload.
// +kubebuilder:validation:Enum=New;Accepted;Prepared;InProgress;Canceling;Canceled;Completed;Failed
type DataDownloadPhase string
const (
DataDownloadPhaseNew DataDownloadPhase = "New"
DataDownloadPhaseAccepted DataDownloadPhase = "Accepted"
DataDownloadPhasePrepared DataDownloadPhase = "Prepared"
DataDownloadPhaseInProgress DataDownloadPhase = "InProgress"
DataDownloadPhaseCanceling DataDownloadPhase = "Canceling"
DataDownloadPhaseCanceled DataDownloadPhase = "Canceled"
DataDownloadPhaseCompleted DataDownloadPhase = "Completed"
DataDownloadPhaseFailed DataDownloadPhase = "Failed"
)
// DataDownloadStatus is the current status of a DataDownload.
type DataDownloadStatus struct {
// Phase is the current state of the DataDownload.
// +optional
Phase DataDownloadPhase `json:"phase,omitempty"`
// Message is a message about the DataDownload's status.
// +optional
Message string `json:"message,omitempty"`
// StartTimestamp records the time a restore was started.
// The server's time is used for StartTimestamps
// +optional
// +nullable
StartTimestamp *metav1.Time `json:"startTimestamp,omitempty"`
// CompletionTimestamp records the time a restore was completed.
// Completion time is recorded even on failed restores.
// The server's time is used for CompletionTimestamps
// +optional
// +nullable
CompletionTimestamp *metav1.Time `json:"completionTimestamp,omitempty"`
// Progress holds the total number of bytes of the snapshot and the current
// number of restored bytes. This can be used to display progress information
// about the restore operation.
// +optional
Progress shared.DataMoveOperationProgress `json:"progress,omitempty"`
}
// TODO(2.0) After converting all resources to use the runtime-controller client, the genclient and k8s:deepcopy markers will no longer be needed and should be removed.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:generate=true
// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="DataDownload status such as New/InProgress"
// +kubebuilder:printcolumn:name="Started",type="date",JSONPath=".status.startTimestamp",description="Time duration since this DataDownload was started"
// +kubebuilder:printcolumn:name="Bytes Done",type="integer",format="int64",JSONPath=".status.progress.bytesDone",description="Completed bytes"
// +kubebuilder:printcolumn:name="Total Bytes",type="integer",format="int64",JSONPath=".status.progress.totalBytes",description="Total bytes"
// +kubebuilder:printcolumn:name="Storage Location",type="string",JSONPath=".spec.backupStorageLocation",description="Name of the Backup Storage Location where the backup data is stored"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since this DataDownload was created"
type DataDownload struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// +optional
Spec DataDownloadSpec `json:"spec,omitempty"`
// +optional
Status DataDownloadStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:generate=true
// +kubebuilder:object:root=true
// +kubebuilder:rbac:groups=velero.io,resources=datadownloads,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=velero.io,resources=datadownloads/status,verbs=get;update;patch
// DataDownloadList is a list of DataDownloads.
type DataDownloadList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []DataDownload `json:"items"`
}
@@ -0,0 +1,209 @@
/*
Copyright the Velero contributors.
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 v2alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
)
// DataUploadSpec is the specification for a DataUpload.
type DataUploadSpec struct {
// SnapshotType is the type of the snapshot to be backed up.
SnapshotType SnapshotType `json:"snapshotType"`
// If SnapshotType is CSI, CSISnapshot provides the information of the CSI snapshot.
// +optional
// +nullable
CSISnapshot *CSISnapshotSpec `json:"csiSnapshot"`
// SourcePVC is the name of the PVC which the snapshot is taken for.
SourcePVC string `json:"sourcePVC"`
// DataMover specifies the data mover to be used by the backup.
// If DataMover is "" or "velero", the built-in data mover will be used.
// +optional
DataMover string `json:"datamover,omitempty"`
// BackupStorageLocation is the name of the backup storage location
// where the backup repository is stored.
BackupStorageLocation string `json:"backupStorageLocation"`
// SourceNamespace is the original namespace where the volume is backed up from.
// It is the same namespace for SourcePVC and CSI namespaced objects.
SourceNamespace string `json:"sourceNamespace"`
// DataMoverConfig is for data-mover-specific configuration fields.
// +optional
// +nullable
DataMoverConfig *map[string]string `json:"dataMoverConfig,omitempty"`
// Cancel indicates request to cancel the ongoing DataUpload. It can be set
// when the DataUpload is in InProgress phase
Cancel bool `json:"cancel,omitempty"`
// OperationTimeout specifies the time used to wait internal operations,
// before returning error as timeout.
OperationTimeout metav1.Duration `json:"operationTimeout"`
}
type SnapshotType string
const (
SnapshotTypeCSI SnapshotType = "CSI"
)
// CSISnapshotSpec is the specification for a CSI snapshot.
type CSISnapshotSpec struct {
// VolumeSnapshot is the name of the volume snapshot to be backed up
VolumeSnapshot string `json:"volumeSnapshot"`
// StorageClass is the name of the storage class of the PVC that the volume snapshot is created from
StorageClass string `json:"storageClass"`
// StorageClass is the name of the snapshot class that the volume snapshot is created with
// +optional
SnapshotClass string `json:"snapshotClass"`
}
// DataUploadPhase represents the lifecycle phase of a DataUpload.
// +kubebuilder:validation:Enum=New;Accepted;Prepared;InProgress;Canceling;Canceled;Completed;Failed
type DataUploadPhase string
const (
DataUploadPhaseNew DataUploadPhase = "New"
DataUploadPhaseAccepted DataUploadPhase = "Accepted"
DataUploadPhasePrepared DataUploadPhase = "Prepared"
DataUploadPhaseInProgress DataUploadPhase = "InProgress"
DataUploadPhaseCanceling DataUploadPhase = "Canceling"
DataUploadPhaseCanceled DataUploadPhase = "Canceled"
DataUploadPhaseCompleted DataUploadPhase = "Completed"
DataUploadPhaseFailed DataUploadPhase = "Failed"
)
// DataUploadStatus is the current status of a DataUpload.
type DataUploadStatus struct {
// Phase is the current state of the DataUpload.
// +optional
Phase DataUploadPhase `json:"phase,omitempty"`
// Path is the full path of the snapshot volume being backed up.
// +optional
Path string `json:"path,omitempty"`
// SnapshotID is the identifier for the snapshot in the backup repository.
// +optional
SnapshotID string `json:"snapshotID,omitempty"`
// DataMoverResult stores data-mover-specific information as a result of the DataUpload.
// +optional
// +nullable
DataMoverResult *map[string]string `json:"dataMoverResult,omitempty"`
// Message is a message about the DataUpload's status.
// +optional
Message string `json:"message,omitempty"`
// StartTimestamp records the time a backup was started.
// Separate from CreationTimestamp, since that value changes
// on restores.
// The server's time is used for StartTimestamps
// +optional
// +nullable
StartTimestamp *metav1.Time `json:"startTimestamp,omitempty"`
// CompletionTimestamp records the time a backup was completed.
// Completion time is recorded even on failed backups.
// Completion time is recorded before uploading the backup object.
// The server's time is used for CompletionTimestamps
// +optional
// +nullable
CompletionTimestamp *metav1.Time `json:"completionTimestamp,omitempty"`
// Progress holds the total number of bytes of the volume and the current
// number of backed up bytes. This can be used to display progress information
// about the backup operation.
// +optional
Progress shared.DataMoveOperationProgress `json:"progress,omitempty"`
}
// TODO(2.0) After converting all resources to use the runttime-controller client,
// the genclient and k8s:deepcopy markers will no longer be needed and should be removed.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:object:generate=true
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="DataUpload status such as New/InProgress"
// +kubebuilder:printcolumn:name="Started",type="date",JSONPath=".status.startTimestamp",description="Time duration since this DataUpload was started"
// +kubebuilder:printcolumn:name="Bytes Done",type="integer",format="int64",JSONPath=".status.progress.bytesDone",description="Completed bytes"
// +kubebuilder:printcolumn:name="Total Bytes",type="integer",format="int64",JSONPath=".status.progress.totalBytes",description="Total bytes"
// +kubebuilder:printcolumn:name="Storage Location",type="string",JSONPath=".spec.backupStorageLocation",description="Name of the Backup Storage Location where this backup should be stored"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since this DataUpload was created"
type DataUpload struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// +optional
Spec DataUploadSpec `json:"spec,omitempty"`
// +optional
Status DataUploadStatus `json:"status,omitempty"`
}
// TODO(2.0) After converting all resources to use the runtime-controller client,
// the k8s:deepcopy marker will no longer be needed and should be removed.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:rbac:groups=velero.io,resources=datauploads,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=velero.io,resources=datauploads/status,verbs=get;update;patch
// DataUploadList is a list of DataUploads.
type DataUploadList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []DataUpload `json:"items"`
}
// DataUploadResult represents the SnasphotBackup result to be used by DataDownload.
type DataUploadResult struct {
// BackupStorageLocation is the name of the backup storage location
// where the backup repository is stored.
BackupStorageLocation string `json:"backupStorageLocation"`
// DataMover specifies the data mover used by the DataUpload
// +optional
DataMover string `json:"datamover,omitempty"`
// SnapshotID is the identifier for the snapshot in the backup repository.
SnapshotID string `json:"snapshotID,omitempty"`
// SourceNamespace is the original namespace where the volume is backed up from.
SourceNamespace string `json:"sourceNamespace"`
// DataMoverResult stores data-mover-specific information as a result of the DataUpload.
// +optional
// +nullable
DataMoverResult *map[string]string `json:"dataMoverResult,omitempty"`
}
+21
View File
@@ -0,0 +1,21 @@
/*
Copyright the Velero contributors.
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.
*/
// +k8s:deepcopy-gen=package
// Package v2alpha1 is the v2alpha1 version of the API.
// +groupName=velero.io
package v2alpha1
@@ -0,0 +1,36 @@
/*
Copyright 2020 the Velero contributors.
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 v2alpha1 contains API Schema definitions for the velero v2alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=velero.io
package v2alpha1
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "velero.io", Version: "v2alpha1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
+60
View File
@@ -0,0 +1,60 @@
/*
Copyright 2017 the Velero contributors.
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 v2alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// Resource gets a Velero GroupResource for a specified resource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
type typeInfo struct {
PluralName string
ItemType runtime.Object
ItemListType runtime.Object
}
func newTypeInfo(pluralName string, itemType, itemListType runtime.Object) typeInfo {
return typeInfo{
PluralName: pluralName,
ItemType: itemType,
ItemListType: itemListType,
}
}
// CustomResources returns a map of all custom resources within the Velero
// API group, keyed on Kind.
func CustomResources() map[string]typeInfo {
return map[string]typeInfo{
"DataUpload": newTypeInfo("datauploads", &DataUpload{}, &DataUploadList{}),
"DataDownload": newTypeInfo("datadownloads", &DataDownload{}, &DataDownloadList{}),
}
}
func addKnownTypes(scheme *runtime.Scheme) error {
for _, typeInfo := range CustomResources() {
scheme.AddKnownTypes(SchemeGroupVersion, typeInfo.ItemType, typeInfo.ItemListType)
}
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
@@ -0,0 +1,299 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
// Code generated by controller-gen. DO NOT EDIT.
package v2alpha1
import (
"k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CSISnapshotSpec) DeepCopyInto(out *CSISnapshotSpec) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSISnapshotSpec.
func (in *CSISnapshotSpec) DeepCopy() *CSISnapshotSpec {
if in == nil {
return nil
}
out := new(CSISnapshotSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DataDownload) DeepCopyInto(out *DataDownload) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataDownload.
func (in *DataDownload) DeepCopy() *DataDownload {
if in == nil {
return nil
}
out := new(DataDownload)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *DataDownload) 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 *DataDownloadList) DeepCopyInto(out *DataDownloadList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]DataDownload, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataDownloadList.
func (in *DataDownloadList) DeepCopy() *DataDownloadList {
if in == nil {
return nil
}
out := new(DataDownloadList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *DataDownloadList) 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 *DataDownloadSpec) DeepCopyInto(out *DataDownloadSpec) {
*out = *in
out.TargetVolume = in.TargetVolume
if in.DataMoverConfig != nil {
in, out := &in.DataMoverConfig, &out.DataMoverConfig
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
out.OperationTimeout = in.OperationTimeout
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataDownloadSpec.
func (in *DataDownloadSpec) DeepCopy() *DataDownloadSpec {
if in == nil {
return nil
}
out := new(DataDownloadSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DataDownloadStatus) DeepCopyInto(out *DataDownloadStatus) {
*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()
}
out.Progress = in.Progress
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataDownloadStatus.
func (in *DataDownloadStatus) DeepCopy() *DataDownloadStatus {
if in == nil {
return nil
}
out := new(DataDownloadStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DataUpload) DeepCopyInto(out *DataUpload) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataUpload.
func (in *DataUpload) DeepCopy() *DataUpload {
if in == nil {
return nil
}
out := new(DataUpload)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *DataUpload) 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 *DataUploadList) DeepCopyInto(out *DataUploadList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]DataUpload, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataUploadList.
func (in *DataUploadList) DeepCopy() *DataUploadList {
if in == nil {
return nil
}
out := new(DataUploadList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *DataUploadList) 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 *DataUploadResult) DeepCopyInto(out *DataUploadResult) {
*out = *in
if in.DataMoverResult != nil {
in, out := &in.DataMoverResult, &out.DataMoverResult
*out = new(map[string]string)
if **in != nil {
in, out := *in, *out
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataUploadResult.
func (in *DataUploadResult) DeepCopy() *DataUploadResult {
if in == nil {
return nil
}
out := new(DataUploadResult)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DataUploadSpec) DeepCopyInto(out *DataUploadSpec) {
*out = *in
if in.CSISnapshot != nil {
in, out := &in.CSISnapshot, &out.CSISnapshot
*out = new(CSISnapshotSpec)
**out = **in
}
if in.DataMoverConfig != nil {
in, out := &in.DataMoverConfig, &out.DataMoverConfig
*out = new(map[string]string)
if **in != nil {
in, out := *in, *out
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
out.OperationTimeout = in.OperationTimeout
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataUploadSpec.
func (in *DataUploadSpec) DeepCopy() *DataUploadSpec {
if in == nil {
return nil
}
out := new(DataUploadSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DataUploadStatus) DeepCopyInto(out *DataUploadStatus) {
*out = *in
if in.DataMoverResult != nil {
in, out := &in.DataMoverResult, &out.DataMoverResult
*out = new(map[string]string)
if **in != nil {
in, out := *in, *out
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
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()
}
out.Progress = in.Progress
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataUploadStatus.
func (in *DataUploadStatus) DeepCopy() *DataUploadStatus {
if in == nil {
return nil
}
out := new(DataUploadStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TargetVolumeSpec) DeepCopyInto(out *TargetVolumeSpec) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetVolumeSpec.
func (in *TargetVolumeSpec) DeepCopy() *TargetVolumeSpec {
if in == nil {
return nil
}
out := new(TargetVolumeSpec)
in.DeepCopyInto(out)
return out
}
+15 -1
View File
@@ -20,6 +20,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
corev1api "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
v1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
@@ -61,5 +62,18 @@ func (a *PVCAction) Execute(item runtime.Unstructured, backup *v1.Backup) (runti
GroupResource: kuberesource.PersistentVolumes,
Name: pvc.Spec.VolumeName,
}
return item, []velero.ResourceIdentifier{pv}, nil
// remove dataSource if exists from prior restored CSI volumes
if pvc.Spec.DataSource != nil {
pvc.Spec.DataSource = nil
}
if pvc.Spec.DataSourceRef != nil {
pvc.Spec.DataSourceRef = nil
}
pvcMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&pvc)
if err != nil {
return nil, nil, errors.Wrap(err, "unable to convert pvc to unstructured item")
}
return &unstructured.Unstructured{Object: pvcMap}, []velero.ResourceIdentifier{pv}, nil
}
+4
View File
@@ -32,6 +32,7 @@ import (
"k8s.io/client-go/rest"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
velerov2alpha1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
clientset "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
)
@@ -156,6 +157,9 @@ func (f *factory) KubebuilderClient() (kbclient.Client, error) {
if err := velerov1api.AddToScheme(scheme); err != nil {
return nil, err
}
if err := velerov2alpha1api.AddToScheme(scheme); err != nil {
return nil, err
}
if err := k8scheme.AddToScheme(scheme); err != nil {
return nil, err
}
+5
View File
@@ -45,6 +45,7 @@ import (
"github.com/vmware-tanzu/velero/internal/credentials"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
velerov2alpha1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
"github.com/vmware-tanzu/velero/pkg/buildinfo"
"github.com/vmware-tanzu/velero/pkg/client"
"github.com/vmware-tanzu/velero/pkg/cmd"
@@ -125,6 +126,10 @@ func newNodeAgentServer(logger logrus.FieldLogger, factory client.Factory, metri
cancelFunc()
return nil, err
}
if err := velerov2alpha1api.AddToScheme(scheme); err != nil {
cancelFunc()
return nil, err
}
if err := v1.AddToScheme(scheme); err != nil {
cancelFunc()
return nil, err
+5
View File
@@ -55,6 +55,7 @@ import (
"github.com/vmware-tanzu/velero/internal/credentials"
"github.com/vmware-tanzu/velero/internal/storage"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
velerov2alpha1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
"github.com/vmware-tanzu/velero/pkg/backup"
"github.com/vmware-tanzu/velero/pkg/buildinfo"
"github.com/vmware-tanzu/velero/pkg/client"
@@ -317,6 +318,10 @@ func newServer(f client.Factory, config serverConfig, logger *logrus.Logger) (*s
cancelFunc()
return nil, err
}
if err := velerov2alpha1api.AddToScheme(scheme); err != nil {
cancelFunc()
return nil, err
}
if err := corev1api.AddToScheme(scheme); err != nil {
cancelFunc()
return nil, err
+2 -1
View File
@@ -32,6 +32,7 @@ import (
"github.com/fatih/color"
kbclient "sigs.k8s.io/controller-runtime/pkg/client"
veleroapishared "github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/cmd/util/downloadrequest"
"github.com/vmware-tanzu/velero/pkg/features"
@@ -597,7 +598,7 @@ type volumesByPod struct {
// Add adds a pod volume with the specified pod namespace, name
// and volume to the appropriate group.
func (v *volumesByPod) Add(namespace, name, volume, phase string, progress velerov1api.PodVolumeOperationProgress) {
func (v *volumesByPod) Add(namespace, name, volume, phase string, progress veleroapishared.DataMoveOperationProgress) {
if v.volumesByPodMap == nil {
v.volumesByPodMap = make(map[string]*podVolumeGroup)
}
@@ -32,6 +32,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/vmware-tanzu/velero/internal/credentials"
veleroapishared "github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/metrics"
"github.com/vmware-tanzu/velero/pkg/podvolume"
@@ -303,7 +304,7 @@ func (r *PodVolumeBackupReconciler) NewBackupProgressUpdater(ctx context.Context
// UpdateProgress which implement ProgressUpdater interface to update pvb progress status
func (b *BackupProgressUpdater) UpdateProgress(p *uploader.Progress) {
original := b.PodVolumeBackup.DeepCopy()
b.PodVolumeBackup.Status.Progress = velerov1api.PodVolumeOperationProgress{TotalBytes: p.TotalBytes, BytesDone: p.BytesDone}
b.PodVolumeBackup.Status.Progress = veleroapishared.DataMoveOperationProgress{TotalBytes: p.TotalBytes, BytesDone: p.BytesDone}
if b.Cli == nil {
b.Log.Errorf("failed to update backup pod %s volume %s progress with uninitailize client", b.PodVolumeBackup.Spec.Pod.Name, b.PodVolumeBackup.Spec.Volume)
return
@@ -38,6 +38,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/source"
"github.com/vmware-tanzu/velero/internal/credentials"
veleroapishared "github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/podvolume"
"github.com/vmware-tanzu/velero/pkg/repository"
@@ -321,7 +322,7 @@ func (c *PodVolumeRestoreReconciler) NewRestoreProgressUpdater(ctx context.Conte
// UpdateProgress which implement ProgressUpdater interface to update pvr progress status
func (c *RestoreProgressUpdater) UpdateProgress(p *uploader.Progress) {
original := c.PodVolumeRestore.DeepCopy()
c.PodVolumeRestore.Status.Progress = velerov1api.PodVolumeOperationProgress{TotalBytes: p.TotalBytes, BytesDone: p.BytesDone}
c.PodVolumeRestore.Status.Progress = veleroapishared.DataMoveOperationProgress{TotalBytes: p.TotalBytes, BytesDone: p.BytesDone}
if c.Cli == nil {
c.Log.Errorf("failed to update restore pod %s volume %s progress with uninitailize client", c.PodVolumeRestore.Spec.Pod.Name, c.PodVolumeRestore.Spec.Volume)
return
+4
View File
@@ -36,6 +36,7 @@ import (
. "github.com/onsi/gomega"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
velerov2alpha1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
@@ -98,6 +99,9 @@ func newTestEnvironment() *testEnvironment {
err := velerov1api.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
err = velerov2alpha1api.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
env = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
}
+15 -1
View File
@@ -22,6 +22,7 @@ import (
"fmt"
velerov1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1"
velerov2alpha1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v2alpha1"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
@@ -30,13 +31,15 @@ import (
type Interface interface {
Discovery() discovery.DiscoveryInterface
VeleroV1() velerov1.VeleroV1Interface
VeleroV2alpha1() velerov2alpha1.VeleroV2alpha1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
veleroV1 *velerov1.VeleroV1Client
veleroV1 *velerov1.VeleroV1Client
veleroV2alpha1 *velerov2alpha1.VeleroV2alpha1Client
}
// VeleroV1 retrieves the VeleroV1Client
@@ -44,6 +47,11 @@ func (c *Clientset) VeleroV1() velerov1.VeleroV1Interface {
return c.veleroV1
}
// VeleroV2alpha1 retrieves the VeleroV2alpha1Client
func (c *Clientset) VeleroV2alpha1() velerov2alpha1.VeleroV2alpha1Interface {
return c.veleroV2alpha1
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
@@ -69,6 +77,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil {
return nil, err
}
cs.veleroV2alpha1, err = velerov2alpha1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
@@ -82,6 +94,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.veleroV1 = velerov1.NewForConfigOrDie(c)
cs.veleroV2alpha1 = velerov2alpha1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
@@ -91,6 +104,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.veleroV1 = velerov1.New(c)
cs.veleroV2alpha1 = velerov2alpha1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
@@ -22,6 +22,8 @@ import (
clientset "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
velerov1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1"
fakevelerov1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1/fake"
velerov2alpha1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v2alpha1"
fakevelerov2alpha1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v2alpha1/fake"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery"
@@ -83,3 +85,8 @@ var (
func (c *Clientset) VeleroV1() velerov1.VeleroV1Interface {
return &fakevelerov1.FakeVeleroV1{Fake: &c.Fake}
}
// VeleroV2alpha1 retrieves the VeleroV2alpha1Client
func (c *Clientset) VeleroV2alpha1() velerov2alpha1.VeleroV2alpha1Interface {
return &fakevelerov2alpha1.FakeVeleroV2alpha1{Fake: &c.Fake}
}
@@ -20,6 +20,7 @@ package fake
import (
velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
velerov2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
@@ -32,6 +33,7 @@ var codecs = serializer.NewCodecFactory(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
velerov1.AddToScheme,
velerov2alpha1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
@@ -20,6 +20,7 @@ package scheme
import (
velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
velerov2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
@@ -32,6 +33,7 @@ var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
velerov1.AddToScheme,
velerov2alpha1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
@@ -0,0 +1,195 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v2alpha1
import (
"context"
"time"
v2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
scheme "github.com/vmware-tanzu/velero/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"
)
// DataDownloadsGetter has a method to return a DataDownloadInterface.
// A group's client should implement this interface.
type DataDownloadsGetter interface {
DataDownloads(namespace string) DataDownloadInterface
}
// DataDownloadInterface has methods to work with DataDownload resources.
type DataDownloadInterface interface {
Create(ctx context.Context, dataDownload *v2alpha1.DataDownload, opts v1.CreateOptions) (*v2alpha1.DataDownload, error)
Update(ctx context.Context, dataDownload *v2alpha1.DataDownload, opts v1.UpdateOptions) (*v2alpha1.DataDownload, error)
UpdateStatus(ctx context.Context, dataDownload *v2alpha1.DataDownload, opts v1.UpdateOptions) (*v2alpha1.DataDownload, 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) (*v2alpha1.DataDownload, error)
List(ctx context.Context, opts v1.ListOptions) (*v2alpha1.DataDownloadList, 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 *v2alpha1.DataDownload, err error)
DataDownloadExpansion
}
// dataDownloads implements DataDownloadInterface
type dataDownloads struct {
client rest.Interface
ns string
}
// newDataDownloads returns a DataDownloads
func newDataDownloads(c *VeleroV2alpha1Client, namespace string) *dataDownloads {
return &dataDownloads{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the dataDownload, and returns the corresponding dataDownload object, and an error if there is any.
func (c *dataDownloads) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2alpha1.DataDownload, err error) {
result = &v2alpha1.DataDownload{}
err = c.client.Get().
Namespace(c.ns).
Resource("datadownloads").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of DataDownloads that match those selectors.
func (c *dataDownloads) List(ctx context.Context, opts v1.ListOptions) (result *v2alpha1.DataDownloadList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v2alpha1.DataDownloadList{}
err = c.client.Get().
Namespace(c.ns).
Resource("datadownloads").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested dataDownloads.
func (c *dataDownloads) 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("datadownloads").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a dataDownload and creates it. Returns the server's representation of the dataDownload, and an error, if there is any.
func (c *dataDownloads) Create(ctx context.Context, dataDownload *v2alpha1.DataDownload, opts v1.CreateOptions) (result *v2alpha1.DataDownload, err error) {
result = &v2alpha1.DataDownload{}
err = c.client.Post().
Namespace(c.ns).
Resource("datadownloads").
VersionedParams(&opts, scheme.ParameterCodec).
Body(dataDownload).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a dataDownload and updates it. Returns the server's representation of the dataDownload, and an error, if there is any.
func (c *dataDownloads) Update(ctx context.Context, dataDownload *v2alpha1.DataDownload, opts v1.UpdateOptions) (result *v2alpha1.DataDownload, err error) {
result = &v2alpha1.DataDownload{}
err = c.client.Put().
Namespace(c.ns).
Resource("datadownloads").
Name(dataDownload.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(dataDownload).
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 *dataDownloads) UpdateStatus(ctx context.Context, dataDownload *v2alpha1.DataDownload, opts v1.UpdateOptions) (result *v2alpha1.DataDownload, err error) {
result = &v2alpha1.DataDownload{}
err = c.client.Put().
Namespace(c.ns).
Resource("datadownloads").
Name(dataDownload.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(dataDownload).
Do(ctx).
Into(result)
return
}
// Delete takes name of the dataDownload and deletes it. Returns an error if one occurs.
func (c *dataDownloads) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("datadownloads").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *dataDownloads) 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("datadownloads").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched dataDownload.
func (c *dataDownloads) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2alpha1.DataDownload, err error) {
result = &v2alpha1.DataDownload{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("datadownloads").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
@@ -0,0 +1,195 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v2alpha1
import (
"context"
"time"
v2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
scheme "github.com/vmware-tanzu/velero/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"
)
// DataUploadsGetter has a method to return a DataUploadInterface.
// A group's client should implement this interface.
type DataUploadsGetter interface {
DataUploads(namespace string) DataUploadInterface
}
// DataUploadInterface has methods to work with DataUpload resources.
type DataUploadInterface interface {
Create(ctx context.Context, dataUpload *v2alpha1.DataUpload, opts v1.CreateOptions) (*v2alpha1.DataUpload, error)
Update(ctx context.Context, dataUpload *v2alpha1.DataUpload, opts v1.UpdateOptions) (*v2alpha1.DataUpload, error)
UpdateStatus(ctx context.Context, dataUpload *v2alpha1.DataUpload, opts v1.UpdateOptions) (*v2alpha1.DataUpload, 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) (*v2alpha1.DataUpload, error)
List(ctx context.Context, opts v1.ListOptions) (*v2alpha1.DataUploadList, 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 *v2alpha1.DataUpload, err error)
DataUploadExpansion
}
// dataUploads implements DataUploadInterface
type dataUploads struct {
client rest.Interface
ns string
}
// newDataUploads returns a DataUploads
func newDataUploads(c *VeleroV2alpha1Client, namespace string) *dataUploads {
return &dataUploads{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the dataUpload, and returns the corresponding dataUpload object, and an error if there is any.
func (c *dataUploads) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2alpha1.DataUpload, err error) {
result = &v2alpha1.DataUpload{}
err = c.client.Get().
Namespace(c.ns).
Resource("datauploads").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of DataUploads that match those selectors.
func (c *dataUploads) List(ctx context.Context, opts v1.ListOptions) (result *v2alpha1.DataUploadList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v2alpha1.DataUploadList{}
err = c.client.Get().
Namespace(c.ns).
Resource("datauploads").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested dataUploads.
func (c *dataUploads) 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("datauploads").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a dataUpload and creates it. Returns the server's representation of the dataUpload, and an error, if there is any.
func (c *dataUploads) Create(ctx context.Context, dataUpload *v2alpha1.DataUpload, opts v1.CreateOptions) (result *v2alpha1.DataUpload, err error) {
result = &v2alpha1.DataUpload{}
err = c.client.Post().
Namespace(c.ns).
Resource("datauploads").
VersionedParams(&opts, scheme.ParameterCodec).
Body(dataUpload).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a dataUpload and updates it. Returns the server's representation of the dataUpload, and an error, if there is any.
func (c *dataUploads) Update(ctx context.Context, dataUpload *v2alpha1.DataUpload, opts v1.UpdateOptions) (result *v2alpha1.DataUpload, err error) {
result = &v2alpha1.DataUpload{}
err = c.client.Put().
Namespace(c.ns).
Resource("datauploads").
Name(dataUpload.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(dataUpload).
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 *dataUploads) UpdateStatus(ctx context.Context, dataUpload *v2alpha1.DataUpload, opts v1.UpdateOptions) (result *v2alpha1.DataUpload, err error) {
result = &v2alpha1.DataUpload{}
err = c.client.Put().
Namespace(c.ns).
Resource("datauploads").
Name(dataUpload.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(dataUpload).
Do(ctx).
Into(result)
return
}
// Delete takes name of the dataUpload and deletes it. Returns an error if one occurs.
func (c *dataUploads) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("datauploads").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *dataUploads) 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("datauploads").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched dataUpload.
func (c *dataUploads) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2alpha1.DataUpload, err error) {
result = &v2alpha1.DataUpload{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("datauploads").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
@@ -0,0 +1,20 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v2alpha1
@@ -0,0 +1,20 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake
@@ -0,0 +1,142 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
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"
)
// FakeDataDownloads implements DataDownloadInterface
type FakeDataDownloads struct {
Fake *FakeVeleroV2alpha1
ns string
}
var datadownloadsResource = schema.GroupVersionResource{Group: "velero.io", Version: "v2alpha1", Resource: "datadownloads"}
var datadownloadsKind = schema.GroupVersionKind{Group: "velero.io", Version: "v2alpha1", Kind: "DataDownload"}
// Get takes name of the dataDownload, and returns the corresponding dataDownload object, and an error if there is any.
func (c *FakeDataDownloads) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2alpha1.DataDownload, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(datadownloadsResource, c.ns, name), &v2alpha1.DataDownload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataDownload), err
}
// List takes label and field selectors, and returns the list of DataDownloads that match those selectors.
func (c *FakeDataDownloads) List(ctx context.Context, opts v1.ListOptions) (result *v2alpha1.DataDownloadList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(datadownloadsResource, datadownloadsKind, c.ns, opts), &v2alpha1.DataDownloadList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2alpha1.DataDownloadList{ListMeta: obj.(*v2alpha1.DataDownloadList).ListMeta}
for _, item := range obj.(*v2alpha1.DataDownloadList).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 dataDownloads.
func (c *FakeDataDownloads) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(datadownloadsResource, c.ns, opts))
}
// Create takes the representation of a dataDownload and creates it. Returns the server's representation of the dataDownload, and an error, if there is any.
func (c *FakeDataDownloads) Create(ctx context.Context, dataDownload *v2alpha1.DataDownload, opts v1.CreateOptions) (result *v2alpha1.DataDownload, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(datadownloadsResource, c.ns, dataDownload), &v2alpha1.DataDownload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataDownload), err
}
// Update takes the representation of a dataDownload and updates it. Returns the server's representation of the dataDownload, and an error, if there is any.
func (c *FakeDataDownloads) Update(ctx context.Context, dataDownload *v2alpha1.DataDownload, opts v1.UpdateOptions) (result *v2alpha1.DataDownload, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(datadownloadsResource, c.ns, dataDownload), &v2alpha1.DataDownload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataDownload), 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 *FakeDataDownloads) UpdateStatus(ctx context.Context, dataDownload *v2alpha1.DataDownload, opts v1.UpdateOptions) (*v2alpha1.DataDownload, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(datadownloadsResource, "status", c.ns, dataDownload), &v2alpha1.DataDownload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataDownload), err
}
// Delete takes name of the dataDownload and deletes it. Returns an error if one occurs.
func (c *FakeDataDownloads) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(datadownloadsResource, c.ns, name), &v2alpha1.DataDownload{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeDataDownloads) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(datadownloadsResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v2alpha1.DataDownloadList{})
return err
}
// Patch applies the patch and returns the patched dataDownload.
func (c *FakeDataDownloads) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2alpha1.DataDownload, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(datadownloadsResource, c.ns, name, pt, data, subresources...), &v2alpha1.DataDownload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataDownload), err
}
@@ -0,0 +1,142 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
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"
)
// FakeDataUploads implements DataUploadInterface
type FakeDataUploads struct {
Fake *FakeVeleroV2alpha1
ns string
}
var datauploadsResource = schema.GroupVersionResource{Group: "velero.io", Version: "v2alpha1", Resource: "datauploads"}
var datauploadsKind = schema.GroupVersionKind{Group: "velero.io", Version: "v2alpha1", Kind: "DataUpload"}
// Get takes name of the dataUpload, and returns the corresponding dataUpload object, and an error if there is any.
func (c *FakeDataUploads) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2alpha1.DataUpload, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(datauploadsResource, c.ns, name), &v2alpha1.DataUpload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataUpload), err
}
// List takes label and field selectors, and returns the list of DataUploads that match those selectors.
func (c *FakeDataUploads) List(ctx context.Context, opts v1.ListOptions) (result *v2alpha1.DataUploadList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(datauploadsResource, datauploadsKind, c.ns, opts), &v2alpha1.DataUploadList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2alpha1.DataUploadList{ListMeta: obj.(*v2alpha1.DataUploadList).ListMeta}
for _, item := range obj.(*v2alpha1.DataUploadList).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 dataUploads.
func (c *FakeDataUploads) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(datauploadsResource, c.ns, opts))
}
// Create takes the representation of a dataUpload and creates it. Returns the server's representation of the dataUpload, and an error, if there is any.
func (c *FakeDataUploads) Create(ctx context.Context, dataUpload *v2alpha1.DataUpload, opts v1.CreateOptions) (result *v2alpha1.DataUpload, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(datauploadsResource, c.ns, dataUpload), &v2alpha1.DataUpload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataUpload), err
}
// Update takes the representation of a dataUpload and updates it. Returns the server's representation of the dataUpload, and an error, if there is any.
func (c *FakeDataUploads) Update(ctx context.Context, dataUpload *v2alpha1.DataUpload, opts v1.UpdateOptions) (result *v2alpha1.DataUpload, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(datauploadsResource, c.ns, dataUpload), &v2alpha1.DataUpload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataUpload), 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 *FakeDataUploads) UpdateStatus(ctx context.Context, dataUpload *v2alpha1.DataUpload, opts v1.UpdateOptions) (*v2alpha1.DataUpload, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(datauploadsResource, "status", c.ns, dataUpload), &v2alpha1.DataUpload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataUpload), err
}
// Delete takes name of the dataUpload and deletes it. Returns an error if one occurs.
func (c *FakeDataUploads) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(datauploadsResource, c.ns, name), &v2alpha1.DataUpload{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeDataUploads) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(datauploadsResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v2alpha1.DataUploadList{})
return err
}
// Patch applies the patch and returns the patched dataUpload.
func (c *FakeDataUploads) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2alpha1.DataUpload, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(datauploadsResource, c.ns, name, pt, data, subresources...), &v2alpha1.DataUpload{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.DataUpload), err
}
@@ -0,0 +1,44 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v2alpha1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v2alpha1"
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
)
type FakeVeleroV2alpha1 struct {
*testing.Fake
}
func (c *FakeVeleroV2alpha1) DataDownloads(namespace string) v2alpha1.DataDownloadInterface {
return &FakeDataDownloads{c, namespace}
}
func (c *FakeVeleroV2alpha1) DataUploads(namespace string) v2alpha1.DataUploadInterface {
return &FakeDataUploads{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeVeleroV2alpha1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}
@@ -0,0 +1,23 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v2alpha1
type DataDownloadExpansion interface{}
type DataUploadExpansion interface{}
@@ -0,0 +1,94 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v2alpha1
import (
v2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
"github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/scheme"
rest "k8s.io/client-go/rest"
)
type VeleroV2alpha1Interface interface {
RESTClient() rest.Interface
DataDownloadsGetter
DataUploadsGetter
}
// VeleroV2alpha1Client is used to interact with features provided by the velero.io group.
type VeleroV2alpha1Client struct {
restClient rest.Interface
}
func (c *VeleroV2alpha1Client) DataDownloads(namespace string) DataDownloadInterface {
return newDataDownloads(c, namespace)
}
func (c *VeleroV2alpha1Client) DataUploads(namespace string) DataUploadInterface {
return newDataUploads(c, namespace)
}
// NewForConfig creates a new VeleroV2alpha1Client for the given config.
func NewForConfig(c *rest.Config) (*VeleroV2alpha1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &VeleroV2alpha1Client{client}, nil
}
// NewForConfigOrDie creates a new VeleroV2alpha1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *VeleroV2alpha1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new VeleroV2alpha1Client for the given RESTClient.
func New(c rest.Interface) *VeleroV2alpha1Client {
return &VeleroV2alpha1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v2alpha1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *VeleroV2alpha1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}
@@ -22,6 +22,7 @@ import (
"fmt"
v1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
v2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
)
@@ -76,6 +77,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
case v1.SchemeGroupVersion.WithResource("volumesnapshotlocations"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Velero().V1().VolumeSnapshotLocations().Informer()}, nil
// Group=velero.io, Version=v2alpha1
case v2alpha1.SchemeGroupVersion.WithResource("datadownloads"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Velero().V2alpha1().DataDownloads().Informer()}, nil
case v2alpha1.SchemeGroupVersion.WithResource("datauploads"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Velero().V2alpha1().DataUploads().Informer()}, nil
}
return nil, fmt.Errorf("no informer found for %v", resource)
@@ -21,12 +21,15 @@ package velero
import (
internalinterfaces "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions/internalinterfaces"
v1 "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions/velero/v1"
v2alpha1 "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions/velero/v2alpha1"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// V1 provides access to shared informers for resources in V1.
V1() v1.Interface
// V2alpha1 provides access to shared informers for resources in V2alpha1.
V2alpha1() v2alpha1.Interface
}
type group struct {
@@ -44,3 +47,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
func (g *group) V1() v1.Interface {
return v1.New(g.factory, g.namespace, g.tweakListOptions)
}
// V2alpha1 returns a new v2alpha1.Interface.
func (g *group) V2alpha1() v2alpha1.Interface {
return v2alpha1.New(g.factory, g.namespace, g.tweakListOptions)
}
@@ -0,0 +1,90 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v2alpha1
import (
"context"
time "time"
velerov2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
versioned "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
internalinterfaces "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions/internalinterfaces"
v2alpha1 "github.com/vmware-tanzu/velero/pkg/generated/listers/velero/v2alpha1"
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"
)
// DataDownloadInformer provides access to a shared informer and lister for
// DataDownloads.
type DataDownloadInformer interface {
Informer() cache.SharedIndexInformer
Lister() v2alpha1.DataDownloadLister
}
type dataDownloadInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewDataDownloadInformer constructs a new informer for DataDownload 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 NewDataDownloadInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredDataDownloadInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredDataDownloadInformer constructs a new informer for DataDownload 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 NewFilteredDataDownloadInformer(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.VeleroV2alpha1().DataDownloads(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.VeleroV2alpha1().DataDownloads(namespace).Watch(context.TODO(), options)
},
},
&velerov2alpha1.DataDownload{},
resyncPeriod,
indexers,
)
}
func (f *dataDownloadInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredDataDownloadInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *dataDownloadInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&velerov2alpha1.DataDownload{}, f.defaultInformer)
}
func (f *dataDownloadInformer) Lister() v2alpha1.DataDownloadLister {
return v2alpha1.NewDataDownloadLister(f.Informer().GetIndexer())
}
@@ -0,0 +1,90 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v2alpha1
import (
"context"
time "time"
velerov2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
versioned "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
internalinterfaces "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions/internalinterfaces"
v2alpha1 "github.com/vmware-tanzu/velero/pkg/generated/listers/velero/v2alpha1"
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"
)
// DataUploadInformer provides access to a shared informer and lister for
// DataUploads.
type DataUploadInformer interface {
Informer() cache.SharedIndexInformer
Lister() v2alpha1.DataUploadLister
}
type dataUploadInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewDataUploadInformer constructs a new informer for DataUpload 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 NewDataUploadInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredDataUploadInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredDataUploadInformer constructs a new informer for DataUpload 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 NewFilteredDataUploadInformer(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.VeleroV2alpha1().DataUploads(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.VeleroV2alpha1().DataUploads(namespace).Watch(context.TODO(), options)
},
},
&velerov2alpha1.DataUpload{},
resyncPeriod,
indexers,
)
}
func (f *dataUploadInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredDataUploadInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *dataUploadInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&velerov2alpha1.DataUpload{}, f.defaultInformer)
}
func (f *dataUploadInformer) Lister() v2alpha1.DataUploadLister {
return v2alpha1.NewDataUploadLister(f.Informer().GetIndexer())
}
@@ -0,0 +1,52 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v2alpha1
import (
internalinterfaces "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// DataDownloads returns a DataDownloadInformer.
DataDownloads() DataDownloadInformer
// DataUploads returns a DataUploadInformer.
DataUploads() DataUploadInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// DataDownloads returns a DataDownloadInformer.
func (v *version) DataDownloads() DataDownloadInformer {
return &dataDownloadInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// DataUploads returns a DataUploadInformer.
func (v *version) DataUploads() DataUploadInformer {
return &dataUploadInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
@@ -0,0 +1,99 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v2alpha1
import (
v2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// DataDownloadLister helps list DataDownloads.
// All objects returned here must be treated as read-only.
type DataDownloadLister interface {
// List lists all DataDownloads in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2alpha1.DataDownload, err error)
// DataDownloads returns an object that can list and get DataDownloads.
DataDownloads(namespace string) DataDownloadNamespaceLister
DataDownloadListerExpansion
}
// dataDownloadLister implements the DataDownloadLister interface.
type dataDownloadLister struct {
indexer cache.Indexer
}
// NewDataDownloadLister returns a new DataDownloadLister.
func NewDataDownloadLister(indexer cache.Indexer) DataDownloadLister {
return &dataDownloadLister{indexer: indexer}
}
// List lists all DataDownloads in the indexer.
func (s *dataDownloadLister) List(selector labels.Selector) (ret []*v2alpha1.DataDownload, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v2alpha1.DataDownload))
})
return ret, err
}
// DataDownloads returns an object that can list and get DataDownloads.
func (s *dataDownloadLister) DataDownloads(namespace string) DataDownloadNamespaceLister {
return dataDownloadNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// DataDownloadNamespaceLister helps list and get DataDownloads.
// All objects returned here must be treated as read-only.
type DataDownloadNamespaceLister interface {
// List lists all DataDownloads in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2alpha1.DataDownload, err error)
// Get retrieves the DataDownload from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v2alpha1.DataDownload, error)
DataDownloadNamespaceListerExpansion
}
// dataDownloadNamespaceLister implements the DataDownloadNamespaceLister
// interface.
type dataDownloadNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all DataDownloads in the indexer for a given namespace.
func (s dataDownloadNamespaceLister) List(selector labels.Selector) (ret []*v2alpha1.DataDownload, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v2alpha1.DataDownload))
})
return ret, err
}
// Get retrieves the DataDownload from the indexer for a given namespace and name.
func (s dataDownloadNamespaceLister) Get(name string) (*v2alpha1.DataDownload, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v2alpha1.Resource("datadownload"), name)
}
return obj.(*v2alpha1.DataDownload), nil
}
@@ -0,0 +1,99 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v2alpha1
import (
v2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// DataUploadLister helps list DataUploads.
// All objects returned here must be treated as read-only.
type DataUploadLister interface {
// List lists all DataUploads in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2alpha1.DataUpload, err error)
// DataUploads returns an object that can list and get DataUploads.
DataUploads(namespace string) DataUploadNamespaceLister
DataUploadListerExpansion
}
// dataUploadLister implements the DataUploadLister interface.
type dataUploadLister struct {
indexer cache.Indexer
}
// NewDataUploadLister returns a new DataUploadLister.
func NewDataUploadLister(indexer cache.Indexer) DataUploadLister {
return &dataUploadLister{indexer: indexer}
}
// List lists all DataUploads in the indexer.
func (s *dataUploadLister) List(selector labels.Selector) (ret []*v2alpha1.DataUpload, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v2alpha1.DataUpload))
})
return ret, err
}
// DataUploads returns an object that can list and get DataUploads.
func (s *dataUploadLister) DataUploads(namespace string) DataUploadNamespaceLister {
return dataUploadNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// DataUploadNamespaceLister helps list and get DataUploads.
// All objects returned here must be treated as read-only.
type DataUploadNamespaceLister interface {
// List lists all DataUploads in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2alpha1.DataUpload, err error)
// Get retrieves the DataUpload from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v2alpha1.DataUpload, error)
DataUploadNamespaceListerExpansion
}
// dataUploadNamespaceLister implements the DataUploadNamespaceLister
// interface.
type dataUploadNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all DataUploads in the indexer for a given namespace.
func (s dataUploadNamespaceLister) List(selector labels.Selector) (ret []*v2alpha1.DataUpload, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v2alpha1.DataUpload))
})
return ret, err
}
// Get retrieves the DataUpload from the indexer for a given namespace and name.
func (s dataUploadNamespaceLister) Get(name string) (*v2alpha1.DataUpload, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v2alpha1.Resource("dataupload"), name)
}
return obj.(*v2alpha1.DataUpload), nil
}
@@ -0,0 +1,35 @@
/*
Copyright the Velero contributors.
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.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v2alpha1
// DataDownloadListerExpansion allows custom methods to be added to
// DataDownloadLister.
type DataDownloadListerExpansion interface{}
// DataDownloadNamespaceListerExpansion allows custom methods to be added to
// DataDownloadNamespaceLister.
type DataDownloadNamespaceListerExpansion interface{}
// DataUploadListerExpansion allows custom methods to be added to
// DataUploadLister.
type DataUploadListerExpansion interface{}
// DataUploadNamespaceListerExpansion allows custom methods to be added to
// DataUploadNamespaceLister.
type DataUploadNamespaceListerExpansion interface{}
+9 -1
View File
@@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
v1crds "github.com/vmware-tanzu/velero/config/crd/v1/crds"
v2alpha1crds "github.com/vmware-tanzu/velero/config/crd/v2alpha1/crds"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
)
@@ -252,7 +253,14 @@ func AllCRDs() *unstructured.UnstructuredList {
for _, crd := range v1crds.CRDs {
crd.SetLabels(Labels())
if err := appendUnstructured(resources, crd); err != nil {
fmt.Printf("error appending CRD %s: %s\n", crd.GetName(), err.Error())
fmt.Printf("error appending v1 CRD %s: %s\n", crd.GetName(), err.Error())
}
}
for _, crd := range v2alpha1crds.CRDs {
crd.SetLabels(Labels())
if err := appendUnstructured(resources, crd); err != nil {
fmt.Printf("error appending v2alpha1 CRD %s: %s\n", crd.GetName(), err.Error())
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ import (
)
func PluginConfigLabelSelector(kind PluginKind, name string) string {
return fmt.Sprintf("velero.io/plugin-config=true,%s=%s", name, kind)
return fmt.Sprintf("velero.io/plugin-config,%s=%s", name, kind)
}
func GetPluginConfig(kind PluginKind, name string, client corev1client.ConfigMapInterface) (*corev1.ConfigMap, error) {
@@ -22,7 +22,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/fake"
@@ -35,7 +34,7 @@ func TestGetPluginConfig(t *testing.T) {
name string
objects []runtime.Object
}
pluginLabelsSet, _ := labels.ConvertSelectorToLabelsMap(PluginConfigLabelSelector(PluginKindRestoreItemAction, "foo"))
pluginLabelsMap := map[string]string{"velero.io/plugin-config": "", "foo": "RestoreItemAction"}
testConfigMap := &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Kind: "ConfigMap",
@@ -43,7 +42,7 @@ func TestGetPluginConfig(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "foo-config",
Namespace: velerov1.DefaultNamespace,
Labels: pluginLabelsSet,
Labels: pluginLabelsMap,
},
}
tests := []struct {
@@ -75,7 +74,7 @@ func TestGetPluginConfig(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "foo-config",
Namespace: velerov1.DefaultNamespace,
Labels: pluginLabelsSet,
Labels: pluginLabelsMap,
},
},
&corev1.ConfigMap{
@@ -85,7 +84,7 @@ func TestGetPluginConfig(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "foo-config-duplicate",
Namespace: velerov1.DefaultNamespace,
Labels: pluginLabelsSet,
Labels: pluginLabelsMap,
},
},
},
+1 -1
View File
@@ -131,7 +131,7 @@ func (b *backupper) BackupPodVolumes(backup *velerov1api.Backup, pod *corev1api.
if len(volumesToBackup) == 0 {
return nil, nil
}
log.Infof("pod %s/%s has volumes to backup: %v", pod.Namespace, pod.Name, volumesToBackup)
err := kube.IsPodRunning(pod)
if err != nil {
for _, volumeName := range volumesToBackup {
+65
View File
@@ -17,13 +17,19 @@ limitations under the License.
package podvolume
import (
"bytes"
"context"
"fmt"
"testing"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
corev1api "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/vmware-tanzu/velero/internal/resourcepolicies"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
)
func TestIsHostPathVolume(t *testing.T) {
@@ -139,3 +145,62 @@ func (g *fakePVGetter) Get(ctx context.Context, name string, opts metav1.GetOpti
return nil, errors.New("item not found")
}
func Test_backupper_BackupPodVolumes_log_test(t *testing.T) {
type args struct {
backup *velerov1api.Backup
pod *corev1api.Pod
volumesToBackup []string
resPolicies *resourcepolicies.Policies
}
tests := []struct {
name string
args args
wantLog string
}{
{
name: "backup pod volumes should log volume names",
args: args{
backup: &velerov1api.Backup{
ObjectMeta: metav1.ObjectMeta{
Name: "backup-1",
Namespace: "ns-1",
},
},
pod: &corev1api.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-1",
Namespace: "ns-1",
},
Spec: corev1api.PodSpec{
Volumes: []corev1api.Volume{
{
Name: "vol-1",
},
{
Name: "vol-2",
},
},
},
},
volumesToBackup: []string{"vol-1", "vol-2"},
resPolicies: nil,
},
wantLog: "pod ns-1/pod-1 has volumes to backup: [vol-1 vol-2]",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := &backupper{
ctx: context.Background(),
}
logOutput := bytes.Buffer{}
var log = logrus.New()
log.SetOutput(&logOutput)
b.BackupPodVolumes(tt.args.backup, tt.args.pod, tt.args.volumesToBackup, tt.args.resPolicies, log)
fmt.Println(logOutput.String())
assert.Contains(t, logOutput.String(), tt.wantLog)
})
}
}
+5
View File
@@ -18,6 +18,7 @@ package provider
import (
"context"
"encoding/base64"
"fmt"
"net/url"
"path"
@@ -498,6 +499,10 @@ func getStorageVariables(backupLocation *velerov1api.BackupStorageLocation, repo
result[udmrepo.StoreOptionS3Endpoint] = strings.Trim(s3URL, "/")
result[udmrepo.StoreOptionS3DisableTLSVerify] = config["insecureSkipTLSVerify"]
result[udmrepo.StoreOptionS3DisableTLS] = strconv.FormatBool(disableTLS)
if backupLocation.Spec.ObjectStorage != nil && backupLocation.Spec.ObjectStorage.CACert != nil {
result[udmrepo.StoreOptionS3CustomCA] = base64.StdEncoding.EncodeToString(backupLocation.Spec.ObjectStorage.CACert)
}
} else if backendType == repoconfig.AzureBackend {
domain, err := getAzureStorageDomain(config)
if err != nil {
@@ -18,6 +18,7 @@ package provider
import (
"context"
"encoding/base64"
"errors"
"testing"
@@ -380,6 +381,42 @@ func TestGetStorageVariables(t *testing.T) {
"skipTLSVerify": "false",
},
},
{
name: "aws, ObjectStorage section exists in BSL, s3Url exist, https, custom CA exist",
backupLocation: velerov1api.BackupStorageLocation{
Spec: velerov1api.BackupStorageLocationSpec{
Provider: "velero.io/aws",
Config: map[string]string{
"bucket": "fake-bucket-config",
"prefix": "fake-prefix-config",
"region": "fake-region",
"s3Url": "https://fake-url/",
"insecureSkipTLSVerify": "false",
},
StorageType: velerov1api.StorageType{
ObjectStorage: &velerov1api.ObjectStorageLocation{
Bucket: "fake-bucket-object-store",
Prefix: "fake-prefix-object-store",
CACert: []byte{0x01, 0x02, 0x03, 0x04, 0x05},
},
},
},
},
getS3BucketRegion: func(bucket string) (string, error) {
return "region from bucket: " + bucket, nil
},
repoBackend: "fake-repo-type",
expected: map[string]string{
"bucket": "fake-bucket-object-store",
"prefix": "fake-prefix-object-store/fake-repo-type/",
"region": "fake-region",
"fspath": "",
"endpoint": "fake-url",
"doNotUseTLS": "false",
"skipTLSVerify": "false",
"customCA": base64.StdEncoding.EncodeToString([]byte{0x01, 0x02, 0x03, 0x04, 0x05}),
},
},
{
name: "azure, getAzureStorageDomain fail",
backupLocation: velerov1api.BackupStorageLocation{
@@ -44,6 +44,7 @@ func (c *S3Backend) Setup(ctx context.Context, flags map[string]string) error {
c.options.DoNotUseTLS = optionalHaveBool(ctx, udmrepo.StoreOptionS3DisableTLS, flags)
c.options.DoNotVerifyTLS = optionalHaveBool(ctx, udmrepo.StoreOptionS3DisableTLSVerify, flags)
c.options.SessionToken = optionalHaveString(udmrepo.StoreOptionS3Token, flags)
c.options.RootCA = optionalHaveBase64(ctx, udmrepo.StoreOptionS3CustomCA, flags)
c.options.Limits = setupLimits(ctx, flags)
@@ -18,6 +18,7 @@ package backend
import (
"context"
"encoding/base64"
"strconv"
"time"
@@ -84,6 +85,19 @@ func optionalHaveDuration(ctx context.Context, key string, flags map[string]stri
return 0
}
func optionalHaveBase64(ctx context.Context, key string, flags map[string]string) []byte {
if value, exist := flags[key]; exist {
ret, err := base64.StdEncoding.DecodeString(value)
if err == nil {
return ret
}
backendLog()(ctx).Errorf("Ignore %s, value [%s] is invalid, err %v", key, value, err)
}
return nil
}
func backendLog() func(ctx context.Context) logging.Logger {
return logging.Module("kopialib-bd")
}
+1
View File
@@ -42,6 +42,7 @@ const (
StoreOptionS3Endpoint = "endpoint"
StoreOptionS3DisableTLS = "doNotUseTLS"
StoreOptionS3DisableTLSVerify = "skipTLSVerify"
StoreOptionS3CustomCA = "customCA"
StoreOptionAzureKey = "storageKey"
StoreOptionAzureDomain = "storageDomain"
+6 -6
View File
@@ -55,7 +55,7 @@ func TestChangeImageRepositoryActionExecute(t *testing.T) {
Image: "1.1.1.1:5000/abc:test",
}).Result(),
configMap: builder.ForConfigMap("velero", "change-image-name").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-image-name", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-image-name", "RestoreItemAction")).
Data("case1", "1.1.1.1:5000 , 2.2.2.2:3000").
Result(),
freshedImageName: "2.2.2.2:3000/abc:test",
@@ -70,7 +70,7 @@ func TestChangeImageRepositoryActionExecute(t *testing.T) {
Image: "1.1.1.1:5000/abc:test",
}).Result(),
configMap: builder.ForConfigMap("velero", "change-image-name").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-image-name", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-image-name", "RestoreItemAction")).
Data("specific", "1.1.1.1:5000,2.2.2.2:3000").
Result(),
freshedImageName: "2.2.2.2:3000/abc:test",
@@ -85,7 +85,7 @@ func TestChangeImageRepositoryActionExecute(t *testing.T) {
Image: "1.1.1.1:5000/abc:test",
}).Result(),
configMap: builder.ForConfigMap("velero", "change-image-name").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-image-name", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-image-name", "RestoreItemAction")).
Data("specific", "abc:test,myproject:latest").
Result(),
freshedImageName: "1.1.1.1:5000/myproject:latest",
@@ -100,7 +100,7 @@ func TestChangeImageRepositoryActionExecute(t *testing.T) {
Image: "1.1.1.1:5000/abc:test",
}).Result(),
configMap: builder.ForConfigMap("velero", "change-image-name").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-image-name", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-image-name", "RestoreItemAction")).
Data("specific", "5000,3333").
Result(),
freshedImageName: "1.1.1.1:5000/abc:test",
@@ -115,7 +115,7 @@ func TestChangeImageRepositoryActionExecute(t *testing.T) {
Image: "1.1.1.1:5000/abc:test",
}).Result(),
configMap: builder.ForConfigMap("velero", "change-image-name").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-image-name", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-image-name", "RestoreItemAction")).
Data("specific", "test,latest").
Result(),
freshedImageName: "1.1.1.1:5000/abc:test",
@@ -130,7 +130,7 @@ func TestChangeImageRepositoryActionExecute(t *testing.T) {
Image: "dev/image1:dev",
}).Result(),
configMap: builder.ForConfigMap("velero", "change-image-name").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-image-name", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-image-name", "RestoreItemAction")).
Data("specific", "dev/,test/").
Result(),
freshedImageName: "dev/image1:dev",
+6 -6
View File
@@ -57,7 +57,7 @@ func TestChangePVCNodeSelectorActionExecute(t *testing.T) {
builder.WithAnnotations("volume.kubernetes.io/selected-node", "source-node"),
).Result(),
configMap: builder.ForConfigMap("velero", "change-pvc-node").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
Data("source-node", "dest-node").
Result(),
newNode: builder.ForNode("dest-node").Result(),
@@ -73,7 +73,7 @@ func TestChangePVCNodeSelectorActionExecute(t *testing.T) {
builder.WithAnnotations("volume.kubernetes.io/selected-node", "source-node"),
).Result(),
configMap: builder.ForConfigMap("velero", "change-pvc-node").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/some-other-plugin", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/some-other-plugin", "RestoreItemAction")).
Data("source-noed", "dest-node").
Result(),
want: builder.ForPersistentVolumeClaim("source-ns", "pvc-1").Result(),
@@ -85,7 +85,7 @@ func TestChangePVCNodeSelectorActionExecute(t *testing.T) {
builder.WithAnnotations("volume.kubernetes.io/selected-node", "source-node"),
).Result(),
configMap: builder.ForConfigMap("velero", "change-pvc-node").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
Result(),
want: builder.ForPersistentVolumeClaim("source-ns", "pvc-1").Result(),
},
@@ -96,7 +96,7 @@ func TestChangePVCNodeSelectorActionExecute(t *testing.T) {
builder.WithAnnotations("volume.kubernetes.io/selected-node", "source-node"),
).Result(),
configMap: builder.ForConfigMap("velero", "change-pvc-node").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
Result(),
// MAYANK TODO
node: builder.ForNode("source-node").Result(),
@@ -109,7 +109,7 @@ func TestChangePVCNodeSelectorActionExecute(t *testing.T) {
name: "when persistent volume claim has no node selector, the item is returned as-is",
pvc: builder.ForPersistentVolumeClaim("source-ns", "pvc-1").Result(),
configMap: builder.ForConfigMap("velero", "change-pvc-node").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
Data("source-node", "dest-node").
Result(),
want: builder.ForPersistentVolumeClaim("source-ns", "pvc-1").Result(),
@@ -121,7 +121,7 @@ func TestChangePVCNodeSelectorActionExecute(t *testing.T) {
builder.WithAnnotations("volume.kubernetes.io/selected-node", "source-node"),
).Result(),
configMap: builder.ForConfigMap("velero", "change-pvc-node").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-pvc-node-selector", "RestoreItemAction")).
Data("source-node-1", "dest-node").
Result(),
want: builder.ForPersistentVolumeClaim("source-ns", "pvc-1").Result(),
+18 -18
View File
@@ -53,7 +53,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "a valid mapping for a persistent volume is applied correctly",
pvOrPvcOrSTS: builder.ForPersistentVolume("pv-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "storageclass-2").
Result(),
storageClass: builder.ForStorageClass("storageclass-2").Result(),
@@ -63,7 +63,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "a valid mapping for a persistent volume claim is applied correctly",
pvOrPvcOrSTS: builder.ForPersistentVolumeClaim("velero", "pvc-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "storageclass-2").
Result(),
storageClass: builder.ForStorageClass("storageclass-2").Result(),
@@ -73,7 +73,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when no config map exists for the plugin, the item is returned as-is",
pvOrPvcOrSTS: builder.ForPersistentVolume("pv-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/some-other-plugin", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/some-other-plugin", "RestoreItemAction")).
Data("storageclass-1", "storageclass-2").
Result(),
want: builder.ForPersistentVolume("pv-1").StorageClass("storageclass-1").Result(),
@@ -82,7 +82,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when no storage class mappings exist in the plugin config map, the item is returned as-is",
pvOrPvcOrSTS: builder.ForPersistentVolume("pv-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Result(),
want: builder.ForPersistentVolume("pv-1").StorageClass("storageclass-1").Result(),
},
@@ -90,7 +90,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when persistent volume has no storage class, the item is returned as-is",
pvOrPvcOrSTS: builder.ForPersistentVolume("pv-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "storageclass-2").
Result(),
want: builder.ForPersistentVolume("pv-1").Result(),
@@ -99,7 +99,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when persistent volume claim has no storage class, the item is returned as-is",
pvOrPvcOrSTS: builder.ForPersistentVolumeClaim("velero", "pvc-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "storageclass-2").
Result(),
want: builder.ForPersistentVolumeClaim("velero", "pvc-1").Result(),
@@ -108,7 +108,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when persistent volume's storage class has no mapping in the config map, the item is returned as-is",
pvOrPvcOrSTS: builder.ForPersistentVolume("pv-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-3", "storageclass-4").
Result(),
want: builder.ForPersistentVolume("pv-1").StorageClass("storageclass-1").Result(),
@@ -117,7 +117,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when persistent volume claim's storage class has no mapping in the config map, the item is returned as-is",
pvOrPvcOrSTS: builder.ForPersistentVolumeClaim("velero", "pvc-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-3", "storageclass-4").
Result(),
want: builder.ForPersistentVolumeClaim("velero", "pvc-1").StorageClass("storageclass-1").Result(),
@@ -126,7 +126,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when persistent volume's storage class is mapped to a nonexistent storage class, an error is returned",
pvOrPvcOrSTS: builder.ForPersistentVolume("pv-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "nonexistent-storage-class").
Result(),
wantErr: errors.New("error getting storage class nonexistent-storage-class from API: storageclasses.storage.k8s.io \"nonexistent-storage-class\" not found"),
@@ -135,7 +135,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when persistent volume claim's storage class is mapped to a nonexistent storage class, an error is returned",
pvOrPvcOrSTS: builder.ForPersistentVolumeClaim("velero", "pvc-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "nonexistent-storage-class").
Result(),
wantErr: errors.New("error getting storage class nonexistent-storage-class from API: storageclasses.storage.k8s.io \"nonexistent-storage-class\" not found"),
@@ -144,7 +144,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when statefulset's VolumeClaimTemplates has only one pvc, a valid mapping for a statefulset is applied correctly",
pvOrPvcOrSTS: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "storageclass-2").
Result(),
storageClass: builder.ForStorageClass("storageclass-2").Result(),
@@ -154,7 +154,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when statefulset's VolumeClaimTemplates has more than one same pvc's storageClassName, a valid mapping for a statefulset is applied correctly",
pvOrPvcOrSTS: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1", "storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "storageclass-2", "storageclass-3", "storageclass-4").
Result(),
storageClass: builder.ForStorageClass("storageclass-2").Result(),
@@ -164,7 +164,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when statefulset's VolumeClaimTemplates has more than one different pvc's storageClassName, a valid mapping for a statefulset is applied correctly",
pvOrPvcOrSTS: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1", "storageclass-2", "storageclass-3").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "storageclass-a", "storageclass-2", "storageclass-b", "storageclass-3", "storageclass-c").
Result(),
storageClassSlice: builder.ForStorageClassSlice("storageclass-a", "storageclass-b", "storageclass-c").SliceResult(),
@@ -174,7 +174,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when no config map exists for the plugin, the statefulset item is returned as-is",
pvOrPvcOrSTS: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/some-other-plugin", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/some-other-plugin", "RestoreItemAction")).
Data("storageclass-1", "storageclass-2").
Result(),
want: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1").Result(),
@@ -183,7 +183,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when no storage class mappings exist in the plugin config map, the statefulset item is returned as-is",
pvOrPvcOrSTS: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Result(),
want: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1").Result(),
},
@@ -191,7 +191,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when persistent volume claim has no storage class, the statefulset item is returned as-is",
pvOrPvcOrSTS: builder.ForStatefulSet("velero", "sts-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Result(),
want: builder.ForStatefulSet("velero", "sts-1").Result(),
},
@@ -199,7 +199,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when statefulset's storage class has no mapping in the config map, the item is returned as-is",
pvOrPvcOrSTS: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-3", "storageclass-4").
Result(),
want: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1").Result(),
@@ -208,7 +208,7 @@ func TestChangeStorageClassActionExecute(t *testing.T) {
name: "when statefulset's storage class is mapped to a nonexistent storage class, an error is returned",
pvOrPvcOrSTS: builder.ForStatefulSet("velero", "sts-1").StorageClass("storageclass-1").Result(),
configMap: builder.ForConfigMap("velero", "change-storage-classs").
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "true", "velero.io/change-storage-class", "RestoreItemAction")).
ObjectMeta(builder.WithLabels("velero.io/plugin-config", "", "velero.io/change-storage-class", "RestoreItemAction")).
Data("storageclass-1", "nonexistent-storage-class").
Result(),
wantErr: errors.New("error getting storage class nonexistent-storage-class from API: storageclasses.storage.k8s.io \"nonexistent-storage-class\" not found"),
@@ -27,12 +27,15 @@ import (
k8sfake "sigs.k8s.io/controller-runtime/pkg/client/fake"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
velerov2alpha1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
)
func NewFakeControllerRuntimeClientBuilder(t *testing.T) *k8sfake.ClientBuilder {
scheme := runtime.NewScheme()
err := velerov1api.AddToScheme(scheme)
require.NoError(t, err)
err = velerov2alpha1api.AddToScheme(scheme)
require.NoError(t, err)
err = corev1api.AddToScheme(scheme)
require.NoError(t, err)
err = snapshotv1api.AddToScheme(scheme)
@@ -44,6 +47,8 @@ func NewFakeControllerRuntimeClient(t *testing.T, initObjs ...runtime.Object) cl
scheme := runtime.NewScheme()
err := velerov1api.AddToScheme(scheme)
require.NoError(t, err)
err = velerov2alpha1api.AddToScheme(scheme)
require.NoError(t, err)
err = corev1api.AddToScheme(scheme)
require.NoError(t, err)
err = snapshotv1api.AddToScheme(scheme)
+1
View File
@@ -174,6 +174,7 @@ func (sr *shimRepository) NewObjectWriter(ctx context.Context, option object.Wri
opt.Prefix = udmrepo.ID(option.Prefix)
opt.FullPath = ""
opt.AccessMode = udmrepo.ObjectDataAccessModeFile
opt.AsyncWrites = option.AsyncWrites
if strings.HasPrefix(option.Description, "DIR:") {
opt.DataType = udmrepo.ObjectDataTypeMetadata