go-templates Questions
4
Solved
For example:
{{range .Users}}
{{if .IsAdmin}}
{{/* How to use "break" or "continue"? */}}
{{end}}
{{end}}
The documentation for "break" or "continue" in templates is not available in golang.o...
Mcgannon asked 19/4, 2017 at 2:29
1
Solved
I'm trying to understand helm templates and found syntax like this:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
So I thought every thing had to sta...
Juvenal asked 28/4, 2021 at 4:20
3
I have an helm chart used to deploy an application that have configuration file in YAML format.
Currently, my helm chart use the following code:
values.yaml
databaseUser: "dbuser"
configFiles:
...
Mae asked 17/6, 2020 at 15:26
3
Getting this error message after kubectl apply -f .
error: error converting YAML to JSON: yaml: invalid map key: map[interface {}]interface {}{"include (print $.Template.BasePath \"/configmap.yaml...
Adulteration asked 8/7, 2019 at 23:6
2
Solved
I need to concatenate a scoped variable and a string with go templates, something like that:
{{ $url := .Release.Namespace + ".myurl.com" }}
How can I do that?
Loupgarou asked 18/12, 2020 at 14:25
5
I need to print only specific fields of Kubernetes Events, sorted by a specific field.
This is to help me gather telemetry and analytics about my namespace
How could I do that?
Sally asked 20/7, 2017 at 23:31
1
Solved
Say I have these values
grafana:
...
ingress:
enabled: true
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.loca...
Lissa asked 9/10, 2020 at 17:2
2
Solved
I'm getting an error when I try and access a function I'm passing to my template:
Error: template: struct.tpl:3: function "makeGoName" not defined
Can anyone please let me know what I'm doing w...
Megargee asked 22/2, 2016 at 9:45
1
I have a template that get rendered several times with a range iteration and I can access variables external variables such as $.Release.Name without a problem. However, when I include templates I ...
Besnard asked 18/4, 2020 at 22:31
2
Solved
How can I look up the value of a map by using a variable key without iterating?
So one can lookup a constant key on variable map $x with $x.key1, but is it possible to do amap.$key?
Jiggle asked 1/10, 2014 at 23:5
1
I want to create a helm chart that results in a config map that looks like this:
apiVersion: v1
kind: ConfigMap
metadata:
name: myconfigmap
data:
myconfigfile1.properties: |
property11 = value1...
Drews asked 17/6, 2020 at 20:56
2
Solved
I have this below golang template code snippet where I take values from a map of type map[string]interface{} and check if that string is empty or not but my string empty check is failing as:
templa...
Morganne asked 24/2, 2017 at 9:4
3
Solved
It noticed a weird thing with Go templates when I try to use Funcs and FuncMap. The following code works as expected:
buffer := bytes.NewBufferString("")
funcMap := template.FuncMap{
"label": st...
Hamza asked 17/4, 2012 at 21:11
2
Solved
I'm trying to do something like:
{{- $cassandrafullname := template "cassandra.fullname" . -}}
but I'm getting this error on a dry run:
Error: UPGRADE FAILED: parse error in "cassandra/template...
Arthro asked 20/9, 2018 at 3:6
1
Solved
I've seen many examples of dash being use for if statements ("{{- if.."), e.g:
{{- if hasKey .Values.mymap "mykey" }}
# do something conditional here...
{{- end }}
what is the purpose of the da...
Cannon asked 6/1, 2020 at 6:29
4
I am using go templates to create yaml definitions for kubernetes. I am trying to nest templates but run into issues where I can't re-use a definition simply because the indention is wrong when inc...
Ornate asked 6/5, 2017 at 15:7
3
Solved
I have created a function to check if a variable is defined:
fm["isset"] = func(a interface{}) bool {
if a == nil || a == "" || a == 0 {
fmt.Println("is not set")
return false
}
fmt.Println("...
Woodall asked 21/6, 2017 at 11:41
3
Question
How do I do something like this:
{{ $use_ssl := (ne $.Env.CERT_NAME "") }}
where $.Env.CERT_NAME may be nil/undefined. If it is nil, it gives this error:
at <ne $.Env.CERT_NAME ""&...
Atiptoe asked 24/3, 2016 at 20:43
2
Solved
I'm looking to loop over an array with Go templates and I want to add an extra string to the last item in the loop.
In python, I can do
{% for host in hosts %}
{{ host }}{% if loop.last %} ;{% e...
Superstructure asked 29/11, 2014 at 21:8
1
Solved
I'm trying to make a list of env vars from a values.yaml become a single secret.yaml file containing the list of envs of the type "secret". The idea is to only create this secret file if at least o...
Squires asked 7/8, 2019 at 20:17
1
Solved
I need to define a variable based on an if statement and use that variable multiple times.
In order not to repeat the if I tried something like this:
{{ if condition}}
{{ $my_val = "http" }}
{{ e...
Taeniasis asked 27/5, 2019 at 10:37
3
Solved
I'm trying to write a template (using html/template) and passing it a struct that has some methods attached to it, many of which return multiple values. Is there any way of accessing these from wit...
Internuncial asked 8/7, 2015 at 8:28
1
Simple question is it possible to get size list with helm and sprig function ?
My list :
list:
- a
- b
- c
I tried like this :
{{ .Values.list | len }}
{{ .Values.list | size }}
{{ .Values....
Cue asked 18/4, 2019 at 7:52
0
Is there any way to "spread" parameters in Go templates?
In my code I have a function that returns the properties of a list of structs as a string slice
"colStr": func(col string, a ...interface...
Beore asked 14/2, 2019 at 19:20
1
I'm setting up a ConfigMap for my Helm chart.
As per good practice, I want to include non-yaml resources through separate files rather than inline. Currently I am trying to include both an xml fil...
Britten asked 13/2, 2019 at 12:57
© 2022 - 2024 — McMap. All rights reserved.