-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathbackup_types.go
133 lines (111 loc) · 4.49 KB
/
backup_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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
Copyright 2021 RadonDB.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type JuiceOpt struct {
// sqlite or redis
JuiceMeta string `json:"juiceMeta"`
// backupSecrete name for S3
BackupSecretName string `json:"backupSecretName"`
JuiceName string `json:"juiceName"`
}
// This is the backup Job CRD.
// BackupSpec defines the desired state of Backup
type BackupSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// To specify the image that will be used for sidecar container.
// +optional
// +kubebuilder:default:="radondb/mysql57-sidecar:v2.3.0"
Image string `json:"image"`
// HostName represents the host for which to take backup
// If is empty, is use leader HostName
HostName string `json:"hostName,omitempty"`
// Represents the ip address of the nfs server.
// +optional
NFSServerAddress string `json:"nfsServerAddress,omitempty"`
// Represents the juicefs parameters which need.
// +optional
JuiceOpt *JuiceOpt `json:"juiceOpt,omitempty"`
// ClusterName represents the cluster name to backup
ClusterName string `json:"clusterName"`
// History Limit of job
// +optional
// +kubebuilder:default:=3
HistoryLimit *int32 `json:"historyLimit,omitempty"`
}
// BackupStatus defines the observed state of Backup
type BackupStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Completed indicates whether the backup is in a final state,
// no matter whether its' corresponding job failed or succeeded
// +kubebuilder:default:=false
Completed bool `json:"completed"`
// Get the backup path.
BackupName string `json:"backupName,omitempty"`
// Get the backup Date
BackupDate string `json:"backupDate,omitempty"`
// Get the backup Type
BackupType string `json:"backupType,omitempty"`
// Conditions represents the backup resource conditions list.
Conditions []BackupCondition `json:"conditions,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="BackupName",type="string",JSONPath=".status.backupName",description="The Backup name"
// +kubebuilder:printcolumn:name="BackupDate",type="string",JSONPath=".status.backupDate",description="The Backup Date time"
// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".status.backupType",description="The Backup Type"
// +kubebuilder:printcolumn:name="Success",type="string",JSONPath=".status.conditions[?(@.type==\"Complete\")].status",description="Whether the backup Success?"
// Backup is the Schema for the backups API
type Backup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec BackupSpec `json:"spec,omitempty"`
Status BackupStatus `json:"status,omitempty"`
}
// BackupCondition defines condition struct for backup resource
type BackupCondition struct {
// type of cluster condition, values in (\"Ready\")
Type BackupConditionType `json:"type"`
// Status of the condition, one of (\"True\", \"False\", \"Unknown\")
Status corev1.ConditionStatus `json:"status"`
// LastTransitionTime
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
// Reason
Reason string `json:"reason"`
// Message
Message string `json:"message"`
}
// BackupConditionType defines condition types of a backup resources
type BackupConditionType string
const (
// BackupComplete means the backup has finished his execution
BackupComplete BackupConditionType = "Complete"
// BackupFailed means backup has failed
BackupFailed BackupConditionType = "Failed"
BackupStart BackupConditionType = "Started"
)
//+kubebuilder:object:root=true
// BackupList contains a list of Backup
type BackupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Backup `json:"items"`
}
func init() {
SchemeBuilder.Register(&Backup{}, &BackupList{})
}