Fix processing of UNDEF and UNSET during wwctl <node|profile> set. #1837
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -201,7 +201,7 @@ func recursiveFlatten(obj interface{}) (hasContent bool) {
|
||||
if typeObj.Elem().Field(i).Type == reflect.TypeOf([]string{}) {
|
||||
del := false
|
||||
for _, elem := range (valObj.Elem().Field(i).Interface()).([]string) {
|
||||
if strings.EqualFold(elem, undef) {
|
||||
if isUnsetValue(elem) {
|
||||
del = true
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func recursiveFlatten(obj interface{}) (hasContent bool) {
|
||||
hasContent = true
|
||||
}
|
||||
case reflect.String:
|
||||
if strings.EqualFold(valObj.Elem().Field(i).String(), undef) {
|
||||
if isUnsetValue(valObj.Elem().Field(i).String()) {
|
||||
valObj.Elem().Field(i).SetString("")
|
||||
}
|
||||
if valObj.Elem().Field(i).String() != "" {
|
||||
@@ -421,3 +421,9 @@ func (netdev *NetDev) IpCIDR() string {
|
||||
}
|
||||
return ipCIDR.String()
|
||||
}
|
||||
|
||||
var unsetValues = []string{"UNSET", "UNDEF"}
|
||||
|
||||
func isUnsetValue(value string) bool {
|
||||
return util.InSlice(unsetValues, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user