-
Notifications
You must be signed in to change notification settings - Fork 17
/
cronhotbackup_types.go
97 lines (82 loc) · 3.61 KB
/
cronhotbackup_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// CronHotBackupSpec defines the desired state of CronHotBackup
type CronHotBackupSpec struct {
// Schedule contains a crontab-like expression that defines the schedule in which HotBackup will be started.
// If the Schedule is empty the HotBackup will start only once when applied.
// ---
// Several pre-defined schedules in place of a cron expression can be used.
// Entry | Description | Equivalent To
// ----- | ----------- | -------------
// @yearly (or @annually) | Run once a year, midnight, Jan. 1st | 0 0 1 1 *
// @monthly | Run once a month, midnight, first of month | 0 0 1 * *
// @weekly | Run once a week, midnight between Sat/Sun | 0 0 * * 0
// @daily (or @midnight) | Run once a day, midnight | 0 0 * * *
// @hourly | Run once an hour, beginning of hour | 0 * * * *
// +kubebuilder:validation:MinLength:=1
// +required
Schedule string `json:"schedule"`
// Specifies the hot backup that will be created when executing a CronHotBackup.
// +required
HotBackupTemplate HotBackupTemplateSpec `json:"hotBackupTemplate"`
// The number of successful finished hot backups to retain.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default:=5
// +optional
SuccessfulHotBackupsHistoryLimit *int32 `json:"successfulHotBackupsHistoryLimit,omitempty"`
// The number of failed finished hot backups to retain.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default:=3
// +optional
FailedHotBackupsHistoryLimit *int32 `json:"failedHotBackupsHistoryLimit,omitempty"`
// When true, CronHotBackup will stop creating HotBackup CRs until it is disabled
// +kubebuilder:default:=false
// +optional
Suspend bool `json:"suspend"`
}
type HotBackupTemplateSpec struct {
// Standard object's metadata of the hot backups created from this template.
// +kubebuilder:validation:XPreserveUnknownFields
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the hot backup.
// +required
Spec HotBackupSpec `json:"spec"`
}
// CronHotBackupStatus defines the observed state of CronHotBackup
type CronHotBackupStatus struct{}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=chb
// CronHotBackup is the Schema for the cronhotbackups API
// +kubebuilder:printcolumn:name="SUSPENDED",type="boolean",JSONPath=".spec.suspend",description="Suspention status of the CronHotBackup"
// +kubebuilder:printcolumn:name="Hazelcast-Resource",type="string",priority=1,JSONPath=".spec.hotBackupTemplate.spec.hazelcastResourceName",description="Name of the Hazelcast resource that this resource is created for"
type CronHotBackup struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// +required
Spec CronHotBackupSpec `json:"spec"`
// +optional
Status CronHotBackupStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// CronHotBackupList contains a list of CronHotBackup
type CronHotBackupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CronHotBackup `json:"items"`
}
func (chbl *CronHotBackupList) GetItems() []client.Object {
l := make([]client.Object, 0, len(chbl.Items))
for _, item := range chbl.Items {
l = append(l, client.Object(&item))
}
return l
}
func init() {
SchemeBuilder.Register(&CronHotBackup{}, &CronHotBackupList{})
}