|
| 1 | +/* |
| 2 | +Copyright 2021 RadonDB. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + corev1 "k8s.io/api/core/v1" |
| 21 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | +) |
| 23 | + |
| 24 | +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! |
| 25 | +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. |
| 26 | + |
| 27 | +// BackupSpec defines the desired state of Backup |
| 28 | +type BackupSpec struct { |
| 29 | + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster |
| 30 | + // Important: Run "make" to regenerate code after modifying this file |
| 31 | + |
| 32 | + // To specify the image that will be used for sidecar container. |
| 33 | + // +optional |
| 34 | + // +kubebuilder:default:="radondb/mysql-sidecar:0.1.88" |
| 35 | + Image string `json:"image"` |
| 36 | + |
| 37 | + // HostName represents the host for which to take backup |
| 38 | + HostName string `json:"hostname"` |
| 39 | + |
| 40 | + // Cluster represents the cluster name to backup |
| 41 | + ClusterName string `json:"clustname"` |
| 42 | + |
| 43 | + // History Limit of job |
| 44 | + // +optional |
| 45 | + // +kubebuilder:default:=3 |
| 46 | + HistoryLimit *int32 `json:"historyLimit,omitempty"` |
| 47 | +} |
| 48 | + |
| 49 | +// BackupStatus defines the observed state of Backup |
| 50 | +type BackupStatus struct { |
| 51 | + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster |
| 52 | + // Important: Run "make" to regenerate code after modifying this file |
| 53 | + |
| 54 | + // Completed indicates whether the backup is in a final state, |
| 55 | + // no matter whether its' corresponding job failed or succeeded |
| 56 | + Completed bool `json:"completed,omitempty"` |
| 57 | + |
| 58 | + // Conditions represents the backup resource conditions list. |
| 59 | + Conditions []BackupCondition `json:"conditions,omitempty"` |
| 60 | +} |
| 61 | + |
| 62 | +//+kubebuilder:object:root=true |
| 63 | +//+kubebuilder:subresource:status |
| 64 | + |
| 65 | +// Backup is the Schema for the backups API |
| 66 | +type Backup struct { |
| 67 | + metav1.TypeMeta `json:",inline"` |
| 68 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 69 | + |
| 70 | + Spec BackupSpec `json:"spec,omitempty"` |
| 71 | + Status BackupStatus `json:"status,omitempty"` |
| 72 | +} |
| 73 | + |
| 74 | +// BackupCondition defines condition struct for backup resource |
| 75 | +type BackupCondition struct { |
| 76 | + // type of cluster condition, values in (\"Ready\") |
| 77 | + Type BackupConditionType `json:"type"` |
| 78 | + // Status of the condition, one of (\"True\", \"False\", \"Unknown\") |
| 79 | + Status corev1.ConditionStatus `json:"status"` |
| 80 | + // LastTransitionTime |
| 81 | + LastTransitionTime metav1.Time `json:"lastTransitionTime"` |
| 82 | + // Reason |
| 83 | + Reason string `json:"reason"` |
| 84 | + // Message |
| 85 | + Message string `json:"message"` |
| 86 | +} |
| 87 | + |
| 88 | +// BackupConditionType defines condition types of a backup resources |
| 89 | +type BackupConditionType string |
| 90 | + |
| 91 | +const ( |
| 92 | + // BackupComplete means the backup has finished his execution |
| 93 | + BackupComplete BackupConditionType = "Complete" |
| 94 | + // BackupFailed means backup has failed |
| 95 | + BackupFailed BackupConditionType = "Failed" |
| 96 | +) |
| 97 | + |
| 98 | +//+kubebuilder:object:root=true |
| 99 | + |
| 100 | +// BackupList contains a list of Backup |
| 101 | +type BackupList struct { |
| 102 | + metav1.TypeMeta `json:",inline"` |
| 103 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 104 | + Items []Backup `json:"items"` |
| 105 | +} |
| 106 | + |
| 107 | +func init() { |
| 108 | + SchemeBuilder.Register(&Backup{}, &BackupList{}) |
| 109 | +} |
0 commit comments