Skip to content

Commit

Permalink
Changes made in validate.go
Browse files Browse the repository at this point in the history
                            -  instead of  if  statement , use switch- case statement for s390x-* layout.
  • Loading branch information
madhu-pillai committed Sep 11, 2023
1 parent 0bc6fdd commit 3615224
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions config/fcos/v1_6_exp/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,22 @@ func (d BootDevice) Validate(c path.ContextPath) (r report.Report) {
}
//Validate s390x layout device specific luks.s390x-device.
//s390x layout does not support Mirror.
//Validate the s390x layout specific device
if d.Layout != nil && (*d.Layout == "s390x-zfcp" || *d.Layout == "s390x-eckd") {
if util.NilOrEmpty(d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
}
if len(d.Mirror.Devices) > 0 {
r.AddOnError(c.Append(*d.Layout), common.ErrMirrorNotSupport)
}
if *d.Layout == "s390x-zfcp" && util.NotEmpty(d.Luks.Device) && !sdRe.MatchString(*d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
}
if *d.Layout == "s390x-eckd" && util.NotEmpty(d.Luks.Device) && !dasdRe.MatchString(*d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
//Validate the luks.s390x-device and matching the device
if d.Layout != nil {
switch *d.Layout {
case "s390x-eckd", "s390x-zfcp":
if util.NilOrEmpty(d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
}
if len(d.Mirror.Devices) > 0 {
r.AddOnError(c.Append(*d.Layout), common.ErrMirrorNotSupport)
}
if *d.Layout == "s390x-zfcp" && util.NotEmpty(d.Luks.Device) && !sdRe.MatchString(*d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
}
if *d.Layout == "s390x-eckd" && util.NotEmpty(d.Luks.Device) && !dasdRe.MatchString(*d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
}
}
}
r.Merge(d.Mirror.Validate(c.Append("mirror")))
Expand Down

0 comments on commit 3615224

Please sign in to comment.