-
Notifications
You must be signed in to change notification settings - Fork 74
/
localvolumesnapshotrestore_types.go
79 lines (62 loc) · 3.44 KB
/
localvolumesnapshotrestore_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
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// 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 (
SourceVolumeSnapshotAnnoKey = "hwameistor.io/source-snapshot"
VolumeSnapshotRestoreCompletedAnnoKey = "hwameistor.io/snapshot-restore-completed"
)
// LocalVolumeSnapshotRestoreSpec defines the desired state of LocalVolumeSnapshotRestore
type LocalVolumeSnapshotRestoreSpec struct {
// TargetVolume is the name of the volume to restore to
TargetVolume string `json:"targetVolume,omitempty"`
// TargetVolume is the name of the target volume will place at
TargetPoolName string `json:"targetPoolName,omitempty"`
// SourceVolumeSnapshot represents which snapshot is used for volume to restore from
// +kubebuilder:validation:Required
SourceVolumeSnapshot string `json:"sourceVolumeSnapshot"`
// RestoreType is the type about how to restore the volume, e.g., rollback, create. By default, create.
// +Kubebuilder:default:=create
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum:=rollback;create
RestoreType RestoreType `json:"restoreType"`
// Abort can be used to abort the restore operation and clean up sub resources created by the restore operation automatically
// +kubebuilder:default:=false
Abort bool `json:"abort,omitempty"`
}
// LocalVolumeSnapshotRestoreStatus defines the observed state of LocalVolumeSnapshotRestore
type LocalVolumeSnapshotRestoreStatus struct {
// VolumeReplicaSnapshotRestore is the replica snapshot to be restored
VolumeReplicaSnapshotRestore []string `json:"volumeReplicaSnapshotRestore,omitempty"`
// State is the phase of restore volume snapshot, e.g. submitted, started, completed, abort, ...
State State `json:"state,omitempty"`
// Message error message to describe some states
Message string `json:"message,omitempty"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// LocalVolumeSnapshotRestore is a user's request for either restoring a local volume snapshot to a new volume, or merging into the old volume.
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=localvolumesnapshotrestores,scope=Cluster,shortName=lvsrestore;lvsnaprestore
// +kubebuilder:printcolumn:name="targetvolume",type=string,JSONPath=`.spec.targetVolume`,description="Target for the restore"
// +kubebuilder:printcolumn:name="sourcesnapshot",type=string,JSONPath=`.spec.sourceVolumeSnapshot`,description="Source snapshot for the restore"
// +kubebuilder:printcolumn:name="state",type=string,JSONPath=`.status.state`,description="State of the restore"
// +kubebuilder:printcolumn:name="age",type=date,JSONPath=`.metadata.creationTimestamp`
type LocalVolumeSnapshotRestore struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec LocalVolumeSnapshotRestoreSpec `json:"spec,omitempty"`
Status LocalVolumeSnapshotRestoreStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// LocalVolumeSnapshotRestoreList contains a list of LocalVolumeSnapshotRestore
type LocalVolumeSnapshotRestoreList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LocalVolumeSnapshotRestore `json:"items"`
}
func init() {
SchemeBuilder.Register(&LocalVolumeSnapshotRestore{}, &LocalVolumeSnapshotRestoreList{})
}