Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· OpenAIAi2 WildChat-4.8M (AI2)

in helm chart I have this code: {{- if or (contains .Values.toleration "small")…

  1. User

    in helm chart I have this code: {{- if or (contains .Values.toleration "small") (contains .Values.toleration "medium") }} - key: {{ .Values.toleration }} {{- else }} - key: {{ .Values.toleration }}-base {{- end }}

    toleration value is "core-small" but the key that i get in the deployment is "core-small-base" why?

  2. Assistant

    The issue here is caused by the use of the contains function. In your code, you are checking if the string "small" or "medium" is contained in the .Values.toleration value, which is "core-small" in this case. Since "small" is indeed contained in "core-small", the first branch of the conditional should be taken, and you should get the - key: {{ .Values.toleration }} line.

    However, you mentioned that you are getting the key as "core-small-base", which means the else branch is being taken. This suggests that there might be an issue with the true branch condition, or there is an issue with the Helm version you are using. In order to understand the problem better, I suggest the following steps:

    1. Double-check if you are using the correct Helm version - Helm v3 or v2 (the template syntax might behave differently).

    2. Check if there are any issues with the input value for .Values.toleration. You can also try to print the value of .Values.toleration and its sub-strings (e.g., {{ printf .Values.toleration }}, {{ printf (contains .Values.toleration "small") }}, and {{ printf (contains .Values.toleration "medium") }}) in the template to understand how they are being interpreted.

    3. Additionally, to test the conditions, you can try using simpler strings for testing by directly using string literals in the contains function (e.g., contains "core-small" "small").

    Once you have debugged the Helm code and found the issue, you can adjust the conditions accordingly to get the intended output.