From 3615224596f6a1df2ad46e268acd01e4cef1041d Mon Sep 17 00:00:00 2001 From: madhu-pillai Date: Mon, 11 Sep 2023 10:52:36 +0530 Subject: [PATCH] Changes made in validate.go - instead of if statement , use switch- case statement for s390x-* layout. --- config/fcos/v1_6_exp/validate.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/config/fcos/v1_6_exp/validate.go b/config/fcos/v1_6_exp/validate.go index aa901ef7..60ea7348 100644 --- a/config/fcos/v1_6_exp/validate.go +++ b/config/fcos/v1_6_exp/validate.go @@ -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")))