Questions tagged [sprig-template-functions]

Questions about using the Sprig template functions. These are extensions to the Go text/template syntax that provide a variety of common support functions, including string and list manipulation. They are included in tools like Helm.

Sprig is a set of extension functions to the system. These support Go data types such as slices (lists) and maps (dictionaries), and provide a set of basic string-manipulation and arithmetic functions.

For example, a chart could be configured with a list of options that needs to be passed as a comma-separated list. In the core Go text/template language, you would need a complex range loop, but you can directly use the Sprig join function instead:

- name: OPTIONS
  value: {{ .Values.options | join "," }}
  #                           ^^^^

Use this tag on questions that use the language and specifically involve the Sprig extensions. Questions with this tag will almost always also be tagged with , and generally also with the main tool being used such as or .

46 questions
1
vote
1 answer

Helm regex match from the beginning until the last occurance of a character

Struggling with Helm to match the word from its beginning to the last occurance of -. I tried {{- printf "%s" .Release.Name | regexFind "[^-]*$" -}}, but it prints from the last occurrance to the end of the word. Expected input : hello-world-here…
Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254
0
votes
1 answer

Helm template condition check for string does not work as expected

WARNING: jp-osa do not have regional COS endpoint support, it is recommended to use Cross-Regional Storageclass. And the code snippet I have in NOTES.txt for this helm chart is: {{- if not (contains $.Values.region "storage-plugin.regionEP")…
ambikanair
  • 4,004
  • 11
  • 43
  • 83
0
votes
1 answer

How do I append values to a variable in helm helper_tpl file

I am trying to do an append operation in helper_tpl file {{/* Get Region List and append to a variable */}} {{- define "plugin.regionList" -}} {{- $regionString := "" -}} {{- $regionValueFile := (.Files.Get .Values.secondaryValueFile) | fromYaml…
ambikanair
  • 4,004
  • 11
  • 43
  • 83
0
votes
1 answer

Example of merge operation in helm

In offcial documentaion the description is very poor: Merge two or more dictionaries into one, giving precedence to the dest dictionary: $newdict := merge $dest $source1 $source2 This is a deep merge operation but not a deep copy operation. Nested…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
0
votes
1 answer

Passing values to include function inside range, using defaults with merge

Given this deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: deployment spec: revisionHistoryLimit: 5 template: spec: containers: {{- include "app.container" (merge .Values.app $) | nindent 8 }} {{-…
0
votes
0 answers

include inside range with merge using helm

i have a helm deployment.yaml template file containing the below: containers: {{- include "app.container" (merge .Values.app $) | nindent 8 }} {{- range $k, $v := .Values.extraContainers }} {{- $nameDict := dict "name" $k -}} …
0
votes
1 answer

How to replace dot in Helm template string

I'm trying to replace all the dot characters in a helm template string with \., like so: {{- regexReplaceAllLiteral "\." "https://endpoint.index.up" "\\\." -}} I want this to output - https://endpoint\.index\.up This is giving me a parse error.…
covfefe
  • 2,485
  • 8
  • 47
  • 77
0
votes
0 answers

helm chart to accept both Mi and Gi values

I have a helm chart and values file. part of helm chart: - name: RAM value: "{{ .Values.resources.requests.memory | trimSuffix "Mi" }}" here, how can i make it such that if I have values in Mi or Gi, both should get stripped. Also, if its…
rawwar
  • 4,834
  • 9
  • 32
  • 57
0
votes
1 answer

range can't iterate over list [x y]

I have this template in my helm chart: {{ $appEnvs := list "dev" "uat" }} {{- range $env := $appEnvs }} ... {{- end }} I am getting this error : <$appEnvs>: range can't iterate over [dev uat] I spent longtime trying many things like : {{- range…
0
votes
1 answer

Go template: is there any item in list of objects with a specific attribute value?

I'm using helm (sprig, go templates). I'm trying to build guards to selectively include stuff in my helm chart, but only if one of the components needs them. So, I have a list: - name: foo flag1: true flag2: false flag3: false - name: bar …
Jon O
  • 6,532
  • 1
  • 46
  • 57
0
votes
1 answer

Merging two Dictionaries in Helm

I am using Helm 3. I have two values.yaml files. In common/values.yaml I have defined: deployment: ports: - name: http protocol: TCP The common is of the type library. In my-app, which is of the type application, the common is added as…
Tapas Bose
  • 28,796
  • 74
  • 215
  • 331
0
votes
1 answer

How to use range function to keep values in same line in helm

I am trying to build configmap data out of values I have in values.yaml. CASE 1: values.yaml: example: abc xyz servers: IP1 IP2 IP3 I want configmap data something like all the example domain forwarded to servers. It would be really grateful…
anonymous user
  • 257
  • 5
  • 23
0
votes
1 answer

Using Helm For Deploying Spring Boot Microservice to K8s

We have build a few Microservices (MS) which have been deployed to our company's K8s clusters. For current deployment, any one of our MSs will be built as a Docker image and they deployed manually using the following steps; and it works…
paiego
  • 3,619
  • 34
  • 43
0
votes
1 answer

Query Values in helm template

I am trying to generate a TLS certificate for all of the ingress resources in my Helm chart. My helm chart contains an application with multiple backends so my Values.yaml is structed like this: backend1: ingress: host: testing.app.com …
Nathan
  • 835
  • 3
  • 11
  • 20
0
votes
1 answer

Sprig "Load more" not loading over https

I've recently added an SSL to the site I'm working on, and it seems to have broken my "load more" buttons via sprig. When I click the button now, I get Blocked loading mixed active content…