mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 14:30:12 +01:00
feat(backup,restore): adding validation for backup and restore
Added a schema validation for backup and restore CR. Also validating the server address in the backup/restore controller. Validating the server address as : ^([0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+)$ which is : <any number>.<any number>.<any number>.<any number>:<any number> Here we are validating just the format of the IP, not validating that IP should be correct which will be little more complex. In any case if IP is not correct, the zfs send will fail, so no need to do complex validation to validate the correct IP and port. Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
parent
5ea411ad05
commit
26968b5394
7 changed files with 62 additions and 15 deletions
|
|
@ -34,8 +34,10 @@ import (
|
|||
type ZFSBackup struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec ZFSBackupSpec `json:"spec"`
|
||||
Status ZFSBackupStatus `json:"status"`
|
||||
Spec ZFSBackupSpec `json:"spec"`
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:Enum=Init;Done;Failed;Pending;InProgress;Invalid
|
||||
Status ZFSBackupStatus `json:"status"`
|
||||
}
|
||||
|
||||
// ZFSBackupSpec is the spec for a ZFSBackup resource
|
||||
|
|
@ -61,6 +63,7 @@ type ZFSBackupSpec struct {
|
|||
// BackupDest is the remote address for backup transfer
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:MinLength=1
|
||||
// +kubebuilder:validation:Pattern="^([0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+)$"
|
||||
BackupDest string `json:"backupDest"`
|
||||
}
|
||||
|
||||
|
|
@ -69,9 +72,6 @@ type ZFSBackupStatus string
|
|||
|
||||
// Status written onto ZFSBackup objects.
|
||||
const (
|
||||
// BKPZFSStatusEmpty ensures the create operation is to be done, if import fails.
|
||||
BKPZFSStatusEmpty ZFSBackupStatus = ""
|
||||
|
||||
// BKPZFSStatusDone , backup is completed.
|
||||
BKPZFSStatusDone ZFSBackupStatus = "Done"
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ type ZFSRestore struct {
|
|||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"` // set name to restore name + volume name + something like csp tag
|
||||
Spec ZFSRestoreSpec `json:"spec"`
|
||||
Status ZFSRestoreStatus `json:"status"`
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:Enum=Init;Done;Failed;Pending;InProgress;Invalid
|
||||
Status ZFSRestoreStatus `json:"status"`
|
||||
}
|
||||
|
||||
// ZFSRestoreSpec is the spec for a ZFSRestore resource
|
||||
|
|
@ -46,6 +48,7 @@ type ZFSRestoreSpec struct {
|
|||
// it can be ip:port in case of restore from remote or volumeName in case of local restore
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:MinLength=1
|
||||
// +kubebuilder:validation:Pattern="^([0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+)$"
|
||||
RestoreSrc string `json:"restoreSrc"`
|
||||
}
|
||||
|
||||
|
|
@ -54,9 +57,6 @@ type ZFSRestoreStatus string
|
|||
|
||||
// Status written onto CStrorRestore object.
|
||||
const (
|
||||
// RSTZFSStatusEmpty ensures the create operation is to be done, if import fails.
|
||||
RSTZFSStatusEmpty ZFSRestoreStatus = ""
|
||||
|
||||
// RSTZFSStatusDone , restore operation is completed.
|
||||
RSTZFSStatusDone ZFSRestoreStatus = "Done"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue