Skip to content

Commit

Permalink
changed NfsBackupSchedule to GcpNfsBackupSchedule
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-shankar-sap committed Jul 19, 2024
1 parent 2e21900 commit 4f1666d
Show file tree
Hide file tree
Showing 47 changed files with 1,343 additions and 1,113 deletions.
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ resources:
controller: true
domain: kyma-project.io
group: cloud-resources
kind: NfsBackupSchedule
kind: GcpNfsBackupSchedule
path: github.com/kyma-project/cloud-manager/api/cloud-resources/v1beta1
version: v1beta1
- api:
Expand Down
10 changes: 10 additions & 0 deletions api/cloud-resources/v1beta1/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@ const (
const (
ConditionTypeQuotaExceeded = "QuotaExceeded"
)

const (
ReasonInvalidCronExpression = "InvalidCronExpression"
ReasonTimeParseError = "TimeParseError"
ReasonScheduleError = "ScheduleError"
ReasonNfsVolumeNotFound = "NfsVolumeNotFound"
ReasonNfsVolumeNotReady = "NfsVolumeNotReady"
ReasonBackupCreateFailed = "BackupCreateFailed"
ReasonBackupListFailed = "BackupListFailed"
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,35 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

const (
ReasonInvalidCronExpression = "InvalidCronExpression"
ReasonTimeParseError = "TimeParseError"
ReasonScheduleError = "ScheduleError"
ReasonNfsVolumeNotFound = "NfsVolumeNotFound"
ReasonNfsVolumeNotReady = "NfsVolumeNotReady"
ReasonBackupCreateFailed = "BackupCreateFailed"
ReasonBackupListFailed = "BackupListFailed"
)

// NfsBackupScheduleSpec defines the desired state of NfsBackupSchedule
type NfsBackupScheduleSpec struct {
// GcpNfsBackupScheduleSpec defines the desired state of GcpNfsBackupSchedule
type GcpNfsBackupScheduleSpec struct {

// NfsVolumeRef specifies the NfsVolume resource that a backup has to be made of.
// NfsVolumeRef specifies the SourceRef resource that a backup has to be made of.
// +kubebuilder:validation:Required
NfsVolumeRef corev1.ObjectReference `json:"nfsVolumeRef"`

// Location specifies the location where the backup has to be stored.
// +optional
Location string `json:"location"`

// Cron expression of the schedule, e.g. "0 0 * * *" for daily at midnight
// Cron expression of the backupschedule, e.g. "0 0 * * *" for daily at midnight
// If not provided, backup will be taken once on the specified start time.
// +optional
Schedule string `json:"schedule,omitempty"`
Schedule string `json:"backupschedule,omitempty"`

// Prefix for the backup name.
// If not provided, schedule name will be used as prefix
// If not provided, backupschedule name will be used as prefix
// +optional
Prefix string `json:"prefix,omitempty"`

// StartTime specifies the time when the backup should start
// If not provided, schedule will start immediately
// If not provided, backupschedule will start immediately
// +optional
// +kubebuilder:validation:Format=date-time
StartTime *metav1.Time `json:"startTime,omitempty"`

// EndTime specifies the time when the backup should end
// If not provided, schedule will run indefinitely
// If not provided, backupschedule will run indefinitely
// +optional
// +kubebuilder:validation:Format=date-time
EndTime *metav1.Time `json:"endTime,omitempty"`
Expand All @@ -74,14 +64,19 @@ type NfsBackupScheduleSpec struct {
// +optional
MaxRetentionDays int `json:"maxRetentionDays,omitempty"`

// Suspend specifies whether the schedule should be suspended
// Suspend specifies whether the backupschedule should be suspended
// By default, suspend will be false
// +kubebuilder:default=false
Suspend bool `json:"suspend,omitempty"`

// DeleteCascade specifies whether to cascade delete the backups when this backupschedule is deleted.
// By default, deleteCascade will be false
// +kubebuilder:default=false
DeleteCascade bool `json:"deleteCascade,omitempty"`
}

// NfsBackupScheduleStatus defines the observed state of NfsBackupSchedule
type NfsBackupScheduleStatus struct {
// GcpNfsBackupScheduleStatus defines the observed state of GcpNfsBackupSchedule
type GcpNfsBackupScheduleStatus struct {
// +kubebuilder:validation:Enum=Processing;Pending;Suspended;Active;Done;Error
State string `json:"state,omitempty"`

Expand Down Expand Up @@ -116,156 +111,164 @@ type NfsBackupScheduleStatus struct {
// +optional
LastDeletedBackups []corev1.ObjectReference `json:"lastDeletedBackups,omitempty"`

// Schedule specifies the cron expression of the current active schedule
// Schedule specifies the cron expression of the current active backupschedule
// +optional
Schedule string `json:"schedule,omitempty"`
Schedule string `json:"backupschedule,omitempty"`

// BackupIndex specifies the current index of the backup created by this schedule
// BackupIndex specifies the current index of the backup created by this backupschedule
// +kubebuilder:default=0
BackupIndex int `json:"backupIndex,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Schedule",type="string",JSONPath=".spec.schedule"
// +kubebuilder:printcolumn:name="Schedule",type="string",JSONPath=".spec.backupschedule"
// +kubebuilder:printcolumn:name="Last Run Time",type="date",JSONPath=".status.lastCreateRun"
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"

// NfsBackupSchedule is the Schema for the nfsbackupschedules API
type NfsBackupSchedule struct {
// GcpNfsBackupSchedule is the Schema for the nfsbackupschedules API
type GcpNfsBackupSchedule struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NfsBackupScheduleSpec `json:"spec,omitempty"`
Status NfsBackupScheduleStatus `json:"status,omitempty"`
Spec GcpNfsBackupScheduleSpec `json:"spec,omitempty"`
Status GcpNfsBackupScheduleStatus `json:"status,omitempty"`
}

func (sc *NfsBackupSchedule) Conditions() *[]metav1.Condition {
func (sc *GcpNfsBackupSchedule) Conditions() *[]metav1.Condition {
return &sc.Status.Conditions
}

func (sc *NfsBackupSchedule) GetObjectMeta() *metav1.ObjectMeta {
func (sc *GcpNfsBackupSchedule) GetObjectMeta() *metav1.ObjectMeta {
return &sc.ObjectMeta
}

func (sc *NfsBackupSchedule) SpecificToFeature() featuretypes.FeatureName {
func (sc *GcpNfsBackupSchedule) SpecificToFeature() featuretypes.FeatureName {
return featuretypes.FeatureNfsBackup
}

func (sc *NfsBackupSchedule) SpecificToProviders() []string {
func (sc *GcpNfsBackupSchedule) SpecificToProviders() []string {
return []string{"gcp"}
}

func (sc *NfsBackupSchedule) State() string {
func (sc *GcpNfsBackupSchedule) State() string {
return sc.Status.State
}
func (sc *NfsBackupSchedule) SetState(state string) {
func (sc *GcpNfsBackupSchedule) SetState(state string) {
sc.Status.State = state
}
func (sc *NfsBackupSchedule) GetSourceRef() corev1.ObjectReference {
func (sc *GcpNfsBackupSchedule) GetSourceRef() corev1.ObjectReference {
return sc.Spec.NfsVolumeRef
}
func (sc *NfsBackupSchedule) SetSourceRef(ref corev1.ObjectReference) {
func (sc *GcpNfsBackupSchedule) SetSourceRef(ref corev1.ObjectReference) {
sc.Spec.NfsVolumeRef = ref
}
func (sc *NfsBackupSchedule) GetSchedule() string {
func (sc *GcpNfsBackupSchedule) GetSchedule() string {
return sc.Spec.Schedule
}
func (sc *NfsBackupSchedule) SetSchedule(schedule string) {
func (sc *GcpNfsBackupSchedule) SetSchedule(schedule string) {
sc.Spec.Schedule = schedule
}
func (sc *NfsBackupSchedule) GetPrefix() string {
func (sc *GcpNfsBackupSchedule) GetPrefix() string {
return sc.Spec.Prefix
}
func (sc *NfsBackupSchedule) SetPrefix(prefix string) {
func (sc *GcpNfsBackupSchedule) SetPrefix(prefix string) {
sc.Spec.Prefix = prefix
}
func (sc *NfsBackupSchedule) GetStartTime() *metav1.Time {
func (sc *GcpNfsBackupSchedule) GetStartTime() *metav1.Time {
return sc.Spec.StartTime
}
func (sc *NfsBackupSchedule) SetStartTime(start *metav1.Time) {
func (sc *GcpNfsBackupSchedule) SetStartTime(start *metav1.Time) {
sc.Spec.StartTime = start
}
func (sc *NfsBackupSchedule) GetEndTime() *metav1.Time {
func (sc *GcpNfsBackupSchedule) GetEndTime() *metav1.Time {
return sc.Spec.EndTime
}
func (sc *NfsBackupSchedule) SetEndTime(end *metav1.Time) {
func (sc *GcpNfsBackupSchedule) SetEndTime(end *metav1.Time) {
sc.Spec.EndTime = end
}
func (sc *NfsBackupSchedule) GetMaxRetentionDays() int {
func (sc *GcpNfsBackupSchedule) GetMaxRetentionDays() int {
return sc.Spec.MaxRetentionDays
}
func (sc *NfsBackupSchedule) SetMaxRetentionDays(days int) {
func (sc *GcpNfsBackupSchedule) SetMaxRetentionDays(days int) {
sc.Spec.MaxRetentionDays = days
}
func (sc *NfsBackupSchedule) GetSuspend() bool {
func (sc *GcpNfsBackupSchedule) GetSuspend() bool {
return sc.Spec.Suspend
}
func (sc *NfsBackupSchedule) SetSuspend(suspend bool) {
func (sc *GcpNfsBackupSchedule) SetSuspend(suspend bool) {
sc.Spec.Suspend = suspend
}

func (sc *NfsBackupSchedule) GetNextRunTimes() []string {
func (sc *GcpNfsBackupSchedule) GetDeleteCascade() bool {
return sc.Spec.DeleteCascade
}

func (sc *GcpNfsBackupSchedule) SetDeleteCascade(cascade bool) {
sc.Spec.DeleteCascade = cascade
}

func (sc *GcpNfsBackupSchedule) GetNextRunTimes() []string {
return sc.Status.NextRunTimes
}
func (sc *NfsBackupSchedule) SetNextRunTimes(times []string) {
func (sc *GcpNfsBackupSchedule) SetNextRunTimes(times []string) {
sc.Status.NextRunTimes = times
}
func (sc *NfsBackupSchedule) GetNextDeleteTimes() map[string]string {
func (sc *GcpNfsBackupSchedule) GetNextDeleteTimes() map[string]string {
return sc.Status.NextDeleteTimes
}
func (sc *NfsBackupSchedule) SetNextDeleteTimes(times map[string]string) {
func (sc *GcpNfsBackupSchedule) SetNextDeleteTimes(times map[string]string) {
sc.Status.NextDeleteTimes = times
}
func (sc *NfsBackupSchedule) GetLastCreateRun() *metav1.Time {
func (sc *GcpNfsBackupSchedule) GetLastCreateRun() *metav1.Time {
return sc.Status.LastCreateRun
}
func (sc *NfsBackupSchedule) SetLastCreateRun(time *metav1.Time) {
func (sc *GcpNfsBackupSchedule) SetLastCreateRun(time *metav1.Time) {
sc.Status.LastCreateRun = time
}
func (sc *NfsBackupSchedule) GetLastCreatedBackup() corev1.ObjectReference {
func (sc *GcpNfsBackupSchedule) GetLastCreatedBackup() corev1.ObjectReference {
return sc.Status.LastCreatedBackup
}
func (sc *NfsBackupSchedule) SetLastCreatedBackup(obj corev1.ObjectReference) {
func (sc *GcpNfsBackupSchedule) SetLastCreatedBackup(obj corev1.ObjectReference) {
sc.Status.LastCreatedBackup = obj
}
func (sc *NfsBackupSchedule) GetLastDeleteRun() *metav1.Time {
func (sc *GcpNfsBackupSchedule) GetLastDeleteRun() *metav1.Time {
return sc.Status.LastDeleteRun
}
func (sc *NfsBackupSchedule) SetLastDeleteRun(time *metav1.Time) {
func (sc *GcpNfsBackupSchedule) SetLastDeleteRun(time *metav1.Time) {
sc.Status.LastDeleteRun = time
}
func (sc *NfsBackupSchedule) GetLastDeletedBackups() []corev1.ObjectReference {
func (sc *GcpNfsBackupSchedule) GetLastDeletedBackups() []corev1.ObjectReference {
return sc.Status.LastDeletedBackups
}
func (sc *NfsBackupSchedule) SetLastDeletedBackups(objs []corev1.ObjectReference) {
func (sc *GcpNfsBackupSchedule) SetLastDeletedBackups(objs []corev1.ObjectReference) {
sc.Status.LastDeletedBackups = objs
}
func (sc *NfsBackupSchedule) GetActiveSchedule() string {
func (sc *GcpNfsBackupSchedule) GetActiveSchedule() string {
return sc.Status.Schedule
}
func (sc *NfsBackupSchedule) SetActiveSchedule(schedule string) {
func (sc *GcpNfsBackupSchedule) SetActiveSchedule(schedule string) {
sc.Status.Schedule = schedule
}
func (sc *NfsBackupSchedule) GetBackupIndex() int {
func (sc *GcpNfsBackupSchedule) GetBackupIndex() int {
return sc.Status.BackupIndex
}
func (sc *NfsBackupSchedule) SetBackupIndex(index int) {
func (sc *GcpNfsBackupSchedule) SetBackupIndex(index int) {
sc.Status.BackupIndex = index
}
func (sc *NfsBackupSchedule) GetList() client.ObjectList {
return &NfsBackupScheduleList{}
func (sc *GcpNfsBackupSchedule) GetList() client.ObjectList {
return &GcpNfsBackupScheduleList{}
}

//+kubebuilder:object:root=true

// NfsBackupScheduleList contains a list of NfsBackupSchedule
type NfsBackupScheduleList struct {
// GcpNfsBackupScheduleList contains a list of GcpNfsBackupSchedule
type GcpNfsBackupScheduleList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NfsBackupSchedule `json:"items"`
Items []GcpNfsBackupSchedule `json:"items"`
}

func init() {
SchemeBuilder.Register(&NfsBackupSchedule{}, &NfsBackupScheduleList{})
SchemeBuilder.Register(&GcpNfsBackupSchedule{}, &GcpNfsBackupScheduleList{})
}
Loading

0 comments on commit 4f1666d

Please sign in to comment.