Fix helm chart error when value cannot be compared to nil#2983
Fix helm chart error when value cannot be compared to nil#2983cccs-cat001 wants to merge 9 commits intoapache:mainfrom
Conversation
helm/polaris/templates/_helpers.tpl
Outdated
| {{- $global := index . 2 -}} | ||
| {{- $valAsString := "" -}} | ||
| {{- if ne $value nil -}} | ||
| {{- if $value -}} |
There was a problem hiding this comment.
We really want this to be if ne $value nil. This is unusual, I know, but here we need to distinguish other zero-values from nil. For example, foo: false or foo: 0 should result in the config property foo being included in the ConfigMap, with value false or 0.
If we change this as you suggested, these properties would not be included.
Taking a step back, can you show us a test case that is currently failing? This would help us understand your issue and fix it. Thanks!
There was a problem hiding this comment.
I really have no idea what values it was failing on. Helm has been pretty useless in telling me where it went wrong.
Error: template: catalog/charts/polaris/templates/configmap.yaml:216:7: executing "catalog/charts/polaris/templates/configmap.yaml" at <include "polaris.appendConfigOption" (list $k $v $global)>: error calling include: template: catalog/charts/polaris/templates/_helpers.tpl:145:7: executing "polaris.appendConfigOption" at <ne $value nil>: error calling ne: incompatible types for comparison
helm.go:81: [debug] template: catalog/charts/polaris/templates/configmap.yaml:216:7: executing "catalog/charts/polaris/templates/configmap.yaml" at <include "polaris.appendConfigOption" (list $k $v $global)>: error calling include: template: catalog/charts/polaris/templates/_helpers.tpl:145:7: executing "polaris.appendConfigOption" at <ne $value nil>: error calling ne: incompatible types for comparison
There was a problem hiding this comment.
OK but what was your values file? So that I can reproduce and debug :-)
|
@cccs-cat001 you pushed and closed this PR? Was it intentional or by mistake? :) |
|
I am very bad at git, it was definitely a mistake 😆 Haven't had the time to create a minimal example for this sorry, I'll get to it next week! |
|
I can't seem to reproduce this again. It must've been some config I was using last week that has since changed, or possibly the outdated version of helm that I was using. I think we're safe to close this as a user error :P |
|
Thanks for confirming that everything is working on your end @cccs-cat001 ! Closing as per your request. |
I faced an issue deploying the helm chart with this line. I found that comparing with nil is unnecessary, because you can just do what's proposed. Sometimes an object/string/map is incompatible with nil and the helm chart will throw errors.
Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)