Skip to content

[Controller] Remove nil check from GetBoolValue to return proper error

Mitchell Nielsen requested to merge fix-getboolvalue-nil-result into master

Created out of !163 (comment 602195688).

Removes the nil check in GetBoolValue, since 'nil' isn't a valid value for a boolean anyway. This caused issues because the method would return a nil in some cases. For example, take the following values:

...
nginx-ingress:
  rbac:
    create: false
...

... and the following code:

enabled, err := GetBoolValue("nginx-ingress.enabled")
if err != nil {
  enabled = true
}

Checking for the value of a key that is not defined on a non-nil map would result returning nil for the err. This meant that the if err != nil block wouldn't be evaluated, meaning we couldn't set a desired default and would therefore always get false.

The change in this MR removes the portion of code that would return nil in this case. Now err will have a proper error in it, as nil cannot be cast to a boolean.

Edited by Mitchell Nielsen

Merge request reports

Loading