Skip to content

Commit a827cd6

Browse files
committed
Address review feedback
Changes: 1. Restore case-insensitive MAC comparison using strings.EqualFold() - The EqualFold check was removed inadvertently but is necessary for case-insensitive bootMACAddress validation 2. Use existing host.InspectionDisabled() method - Remove duplicate isInspectionDisabled() function - Replace custom implementation with the existing BareMetalHost method - The host.InspectionDisabled() method provides identical functionality Assisted-by: Claude (AI Assistant) Signed-off-by: Don Penney <[email protected]>
1 parent ae0f01e commit a827cd6

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

internal/webhooks/metal3.io/v1alpha1/baremetalhost_validation.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (webhook *BareMetalHost) validateChanges(oldObj *metal3api.BareMetalHost, n
109109
errs = append(errs, errors.New("BMC address can not be changed if the BMH is not in the Registering state, or if the BMH is not detached"))
110110
}
111111

112-
if oldObj.Spec.BootMACAddress != "" && newObj.Spec.BootMACAddress != oldObj.Spec.BootMACAddress {
112+
if oldObj.Spec.BootMACAddress != "" && !strings.EqualFold(newObj.Spec.BootMACAddress, oldObj.Spec.BootMACAddress) {
113113
errs = append(errs, errors.New("bootMACAddress can not be changed once it is set"))
114114
}
115115

@@ -120,19 +120,6 @@ func (webhook *BareMetalHost) validateChanges(oldObj *metal3api.BareMetalHost, n
120120
return errs
121121
}
122122

123-
// isInspectionDisabled checks if inspection is disabled via annotation or spec field.
124-
func isInspectionDisabled(host *metal3api.BareMetalHost) bool {
125-
// Check the InspectionMode field first
126-
if host.Spec.InspectionMode == metal3api.InspectionModeDisabled {
127-
return true
128-
}
129-
// Check the annotation
130-
if host.Annotations[metal3api.InspectAnnotationPrefix] == metal3api.InspectAnnotationValueDisabled {
131-
return true
132-
}
133-
return false
134-
}
135-
136123
func validateBMCAccess(host *metal3api.BareMetalHost, bmcAccess bmc.AccessDetails) []error {
137124
var errs []error
138125
s := host.Spec
@@ -156,7 +143,7 @@ func validateBMCAccess(host *metal3api.BareMetalHost, bmcAccess bmc.AccessDetail
156143
// Check if bootMACAddress is required
157144
requiresMAC := bmcAccess.NeedsMAC()
158145
// Virtual media drivers (NeedsMAC() returns false) still require MAC when inspection is disabled
159-
if !requiresMAC && isInspectionDisabled(host) {
146+
if !requiresMAC && host.InspectionDisabled() {
160147
requiresMAC = true
161148
}
162149

0 commit comments

Comments
 (0)