Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Xieql <[email protected]>
  • Loading branch information
Xieql committed Aug 30, 2023
1 parent bf1435f commit 9798539
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
42 changes: 18 additions & 24 deletions pkg/apis/backups/v1alpha1/backup_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ type Backup struct {
}

type BackupSpec struct {
// Storage details where the backup data should be stored.
// If not set, the backup will use the default Storage that is created during Velero installation.
// +optional
Storage BackupStorage `json:"storage"`
// TODO: consider add Storage setting for backup

// Schedule defines when to run the Backup using a Cron expression.
// A cron expression is a format used to specify the execution time of recurring tasks, consisting of multiple fields representing different time units.
// For example, "30 * * * *" represents execution at the 30th minute of every hour, "*/15 * * * *" represents execution every 15 minutes, and "10 10,14 * * *" represents execution at 10:10 AM and 2:10 PM every day.
// ┌───────────── minute (0 - 59)
// │ ┌───────────── hour (0 - 23)
// │ │ ┌───────────── day of the month (1 - 31)
// │ │ │ ┌───────────── month (1 - 12)
// │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
// │ │ │ │ │ 7 is also Sunday on some systems)
// │ │ │ │ │
// │ │ │ │ │
// * * * * *
// For example, "30 * * * *" represents execution at the 30th minute of every hour, and "10 10,14 * * *" represents execution at 10:10 AM and 2:10 PM every day.
// If not set, the backup will be executed only once.
// +optional
Schedule string `json:"schedule,omitempty"`
Expand All @@ -60,25 +66,6 @@ type BackupSpec struct {
Policy *BackupPolicy `json:"policy,omitempty"`
}

type BackupStorage struct {
// Location specifies the location where the backup data will be stored.
Location BackupStorageLocation `json:"location"`

// Credentials to access the backup storage location.
Credentials string `json:"credentials"`
}

type BackupStorageLocation struct {
// Bucket specifies the storage bucket name.
Bucket string `json:"bucket"`
// Provider specifies the storage provider type (e.g., aws).
Provider string `json:"provider"`
// S3Url provides the endpoint URL for S3-compatible storage.
S3Url string `json:"s3Url"`
// Region specifies the region of the storage.
Region string `json:"region"`
}

// Note: partly copied from https://github.com/vmware-tanzu/velero/pkg/apis/backup_types.go
// BackupSpec defines the specification for a backup.
type BackupPolicy struct {
Expand All @@ -97,6 +84,13 @@ type BackupPolicy struct {
// OrderedResources specifies the backup order of resources of specific Kind.
// The map key is the resource name and value is a list of object names separated by commas.
// Each resource name has format "namespace/objectname". For cluster resources, simply use "objectname".
// For example, if you have a specific order for pods, such as "pod1, pod2, pod3" with all belonging to the "ns1" namespace,
// and a specific order for persistentvolumes, such as "pv4, pv8", you can use the orderedResources field in YAML format as shown below:
// ```yaml
// orderedResources:
// pods: "ns1/pod1, ns1/pod2, ns1/pod3"
// persistentvolumes: "pv4, pv8"
// ```
// +optional
// +nullable
OrderedResources map[string]string `json:"orderedResources,omitempty"`
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/backups/v1alpha1/migrate_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ type Migrate struct {
}

type MigrateSpec struct {
// Storage details where the data should be stored.
Storage BackupStorage `json:"storage"`

// SourceCluster represents the source cluster for migration.
SourceCluster *Destination `json:"sourceCluster"`

Expand Down
20 changes: 15 additions & 5 deletions pkg/apis/backups/v1alpha1/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,52 @@ type ResourceFilter struct {
ExcludedNamespaces []string `json:"excludedNamespaces,omitempty"`

// IncludedResources is a slice of resource names to include in the backup.
// For example, we can populate this string array with "deployments" and "configmaps", then we will select all resources of type deployments and configmaps,
// If empty, all resources are included.
// Cannot work with IncludedClusterScopedResources, ExcludedClusterScopedResources, IncludedNamespaceScopedResources and ExcludedNamespaceScopedResources.
// +optional
// +nullable
IncludedResources []string `json:"includedResources,omitempty"`

// ExcludedResources is a slice of resource names that are not included in the backup.
// Cannot work with IncludedClusterScopedResources, ExcludedClusterScopedResources, IncludedNamespaceScopedResources and ExcludedNamespaceScopedResources.
// +optional
// +nullable
ExcludedResources []string `json:"excludedResources,omitempty"`

// IncludeClusterResources specifies whether cluster-scoped resources should be included for consideration in the backup.
// Cannot work with IncludedClusterScopedResources, ExcludedClusterScopedResources, IncludedNamespaceScopedResources and ExcludedNamespaceScopedResources.
// +optional
// +nullable
IncludeClusterResources *bool `json:"includeClusterResources,omitempty"`

// IncludedClusterScopedResources is a slice of cluster-scoped resource type names to include in the backup.
// For example, we can populate this string array with "storageclasses" and "clusterroles", then we will select all resources of type storageclasses and clusterroles,
// If set to "*", all cluster-scoped resource types are included.
// The default value is empty, which means only related cluster-scoped resources are included.
// Cannot work with IncludedResources, ExcludedResources and IncludeClusterResources.
// +optional
// +nullable
IncludedClusterScopedResources []string `json:"includedClusterScopedResources,omitempty"`

// ExcludedClusterScopedResources is a slice of cluster-scoped resource type names to exclude from the backup.
// If set to "*", all cluster-scoped resource types are excluded. The default value is empty.
// Cannot work with IncludedResources, ExcludedResources and IncludeClusterResources.
// +optional
// +nullable
ExcludedClusterScopedResources []string `json:"excludedClusterScopedResources,omitempty"`

// IncludedNamespaceScopedResources is a slice of namespace-scoped resource type names to include in the backup.
// For example, we can populate this string array with "deployments" and "configmaps", then we will select all resources of type deployments and configmaps,
// The default value is "*".
// Cannot work with IncludedResources, ExcludedResources and IncludeClusterResources.
// +optional
// +nullable
IncludedNamespaceScopedResources []string `json:"includedNamespaceScopedResources,omitempty"`

// ExcludedNamespaceScopedResources is a slice of namespace-scoped resource type names to exclude from the backup.
// If set to "*", all namespace-scoped resource types are excluded. The default value is empty.
// Cannot work with IncludedResources, ExcludedResources and IncludeClusterResources.
// +optional
// +nullable
ExcludedNamespaceScopedResources []string `json:"excludedNamespaceScopedResources,omitempty"`
Expand All @@ -109,9 +124,4 @@ type ResourceFilter struct {
// +optional
// +nullable
OrLabelSelectors []*metav1.LabelSelector `json:"orLabelSelectors,omitempty"`

// IncludeClusterResources specifies whether cluster-scoped resources should be included for consideration in the backup.
// +optional
// +nullable
IncludeClusterResources *bool `json:"includeClusterResources,omitempty"`
}

0 comments on commit 9798539

Please sign in to comment.