Skip to content

Commit

Permalink
feat: validator QemuWorldWideName
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyblargon committed Jun 21, 2023
1 parent 0c3dcc2 commit 32d9a2d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions proxmox/config_qemu_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ func (disk *qemuDisk) validate() (err error) {
if err = disk.Serial.Validate(); err != nil {
return
}
if err = disk.WorldWideName.Validate(); err != nil {
return
}
if disk.Disk {
// disk
if err = disk.Format.Validate(); err != nil {
Expand Down Expand Up @@ -1016,6 +1019,17 @@ type qemuUpdateChanges struct {

type QemuWorldWideName string

const Error_QemuWorldWideName_Invalid string = "world wide name should be prefixed with 0x followed by 8 hexadecimal values"

var regexp_QemuWorldWideName = regexp.MustCompile(`^0x[0-9A-Fa-f]{16}$`)

func (wwn QemuWorldWideName) Validate() error {
if wwn == "" || regexp_QemuWorldWideName.MatchString(string(wwn)) {
return nil
}
return errors.New(Error_QemuWorldWideName_Invalid)
}

func diskSubtypeSet(set bool) error {
if set {
return errors.New(Error_QemuDisk_MutuallyExclusive)
Expand Down

0 comments on commit 32d9a2d

Please sign in to comment.