/
foundationdbrestore_types.go
102 lines (81 loc) · 3.64 KB
/
foundationdbrestore_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
/*
Copyright 2020-2022 FoundationDB project authors.
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 v1beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +kubebuilder:object:root=true
// +kubebuilder:resource:shortName=fdbrestore
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:storageversion
// FoundationDBRestore is the Schema for the foundationdbrestores API
type FoundationDBRestore struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec FoundationDBRestoreSpec `json:"spec,omitempty"`
Status FoundationDBRestoreStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// FoundationDBRestoreList contains a list of FoundationDBRestore objects
type FoundationDBRestoreList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FoundationDBRestore `json:"items"`
}
// FoundationDBRestoreSpec describes the desired state of the backup for a cluster.
type FoundationDBRestoreSpec struct {
// DestinationClusterName provides the name of the cluster that the data is
// being restored into.
DestinationClusterName string `json:"destinationClusterName"`
// The key ranges to restore.
KeyRanges []FoundationDBKeyRange `json:"keyRanges,omitempty"`
// This is the configuration of the target blobstore for this backup.
BlobStoreConfiguration *BlobStoreConfiguration `json:"blobStoreConfiguration,omitempty"`
// CustomParameters defines additional parameters to pass to the backup
// agents.
CustomParameters FoundationDBCustomParameters `json:"customParameters,omitempty"`
}
// FoundationDBRestoreStatus describes the current status of the restore for a cluster.
type FoundationDBRestoreStatus struct {
// Running describes whether the restore is currently running.
Running bool `json:"running,omitempty"`
}
// FoundationDBKeyRange describes a range of keys for a command.
//
// The keys in the key range must match the following pattern:
// `^[A-Za-z0-9\/\\-]+$`. All other characters can be escaped with `\xBB`, where
// `BB` is the hexadecimal value of the byte.
type FoundationDBKeyRange struct {
// Start provides the beginning of the key range.
// +kubebuilder:validation:Pattern:=^[A-Za-z0-9\/\\-]+$
Start string `json:"start"`
// End provides the end of the key range.
// +kubebuilder:validation:Pattern:=^[A-Za-z0-9\/\\-]+$
End string `json:"end"`
}
// BackupName gets the name of the backup for the source backup.
// This will fill in a default value if the backup name in the spec is empty.
func (restore *FoundationDBRestore) BackupName() string {
if restore.Spec.BlobStoreConfiguration == nil || restore.Spec.BlobStoreConfiguration.BackupName == "" {
return restore.ObjectMeta.Name
}
return restore.Spec.BlobStoreConfiguration.BackupName
}
// BackupURL gets the destination url of the backup.
func (restore *FoundationDBRestore) BackupURL() string {
return restore.Spec.BlobStoreConfiguration.getURL(restore.BackupName(), restore.Spec.BlobStoreConfiguration.BucketName())
}
func init() {
SchemeBuilder.Register(&FoundationDBRestore{}, &FoundationDBRestoreList{})
}