Hi @Lukasz_Werenkowicz, I don’t believe this is possible today with optional values that are arrays, though it does seem like a reasonable feature request. Let me see if I can find a workaround for you in the meantime and I’ll share it here.
Certainly not the cleanest, but here is a potential workaround that might get you the resulting values that you are looking for. If you do find a cleaner solution, please do share it here.
In this case, I define some config items that are of type bool. These will represent the conditionals for each of the nav items you want to render out. Additionally I’ve also added some hidden config items that contain the resulting yaml that I want rendered for each.
- name: app_1_enabled
title: Enable App 1
type: bool
- name: app_1_nav_value
title: App 1 Nav Value
type: text
hidden: true
value: |
- name: "App1"
url: "url1"
- name: app_2_enabled
title: Enable App 2
type: bool
- name: app_2_nav_value
title: App 2 Nav Value
type: text
hidden: true
value: |
- name: "App2"
url: "url2"
In the HelmChart custom resource, you can use the the ConfigOption combined with nindent to render each value accordingly.
values:
config:
navLinks: repl{{ if ConfigOptionEquals "app_1_enabled" "1" }}repl{{ ConfigOption "app_1_nav_value" | nindent 6 }}repl{{ end }}repl{{ if ConfigOptionEquals "app_2_enabled" "1" }}repl{{ ConfigOption "app_2_nav_value" | nindent 6 }}repl{{ end }}
This would result in the following values if both checkboxes were selected by the user:
Thank you, @craig!
The workaround works very well.
As for now, I only have 3 items in my list (but each condition contains 2 checks) so, the code is still maintainable… but with more variables it may be problematic.
Having and additional param to control the merge strategy would be a really nice feature. Thanks!