Open sourcehawk opened 8 months ago
Hi @hauks96,
This provider uses Helm ParseInto function to parse set_list
values. If the list is empty, it produces an empty string that matches Helm CLI behavior. The new lines you observe most probably come from the chart template. They might not handle this case scenario well and don't trim a new line. This is something that the provider cannot do and is totally up to the chart developers.
Have you tried to run helm template
for the same chart and pass empty lists for the mentioned values explicitly? Please make sure you use the same chart version.
P.S.: I have tried the following config and don't see any issues.
resource "helm_release" "this" {
name = "this"
repository = "oci://registry-1.docker.io"
chart = "bitnamicharts/thanos"
namespace = "default"
timeout = 900
set_list {
name = "thanos.query.extraFlags"
value = []
}
set_list {
name = "thanos.query.stores"
value = []
}
}
$ helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
this default 1 2023-10-23 14:08:43.442646 +0200 CEST deployed thanos-12.13.12 0.32.5
Here is the chart I used to reproduce: https://artifacthub.io/packages/helm/bitnami/thanos
ages/helm/bitnami/thanos
Try it without the "thanos" path. I am using "thanos" in my path because I am using it as a subchart. Your assignment here will not have any effect because you are not setting the right attributes.
resource "helm_release" "this" {
name = "this"
repository = "oci://registry-1.docker.io"
chart = "bitnamicharts/thanos"
namespace = "default"
timeout = 900
set_list {
name = "query.extraFlags"
value = []
}
set_list {
name = "query.stores"
value = []
}
}
Hi @hauks96,
Thank you for the correction. However, my answer remains the same. An empty list produces an empty line(this matches with Helm CLI) and the observed behavior is how chart developers handle this case.
Thanks.
My problem here is the fact that using a values.yaml
file produces a different output from set_list
with the exact same value. I don't quite understand how that is the chart templates fault.
@arybolovlev Can you please re-add the bug label? This is clearly not intended behavior, given that it is not matching the behavior of vanilla helm values file. I've resorted to using the values
section of helm_release to set the arrays in this case to prevent the issue from happening.
It's a BUG, I am trying to set an empty list but with this extra item, it fails because my tempalte fails to evaluate the expected structure at <.name>: can't evaluate field name in type interface {}
Terraform, Provider, Kubernetes and Helm Versions
Affected Resource(s)
Terraform Configuration Files
Relevant section displayed (two cases of set_list) with an empty array, which is also the default value within the chart itself, meaning it should have no effect
Values.yaml file
Debug Output
Here in the "Args" section we can see that there is a newline before the "State" section. This newline is preventing the container from starting, as it errors upon startup because of an invalid start command.
Now if I comment out the set_list fields from earlier, this newline is no longer present. Even though an empty array is also the default value in my values.yaml file.
Update:
If I go into edit mode using kubectl edit on the pod, there seems to be an additional array element added. Again, this does not happen when deploying using only values.yaml file with the same values, so the behavior in set_list is clearly not the same.
Expected Behavior
The set_list only creates lists and does not add anything that is not expected.
Actual Behavior
The set_list creates an unwanted newline where it is not expected.
Community Note