Questions tagged [go-templates]

Go language supports built-in template functionality. Packages with this support include 1) text/template and; 2) html/template.

Filter by
Sorted by
Tagged with
0 votes
0 answers
26 views

Helm error converting YAML to JSON: yaml: could not find expected ':'

I have read and tried numerous answers here and elsewhere, but so far, no joy. Using Helm's ConfigMap And Secrets (Helm Version:"v3.13.0" and I am using MACOS Ventura 13.6.2 on an M1 chip) I ...
Jay Blanchard's user avatar
0 votes
1 answer
21 views

How do I nest base templates in Hugo?

I'm trying to do the following in Hugo: layouts/_default/baseof.html: <html> <body> <span>main baseof.html</span> {{ block "body" . }} ...
Nishant George Agrwal's user avatar
0 votes
1 answer
38 views

Getting a value from a ConfigMap in my Argo Workflow

My Argo Workflow has a template that generates the following Config Map: { "apiVersion": "v1", "kind": "ConfigMap", "metadata": { "name&...
Daniel's user avatar
  • 653
0 votes
1 answer
46 views

Helm iterate over complex values

Im trying to iterate over the following values in my helm values.yaml using a helm helper .tpl Values: pubSub: - topicName: topic-1 topicEnvVar: TOPIC_1 subscriptions: - ...
Kris's user avatar
  • 215
0 votes
0 answers
43 views

bad character U+003D '=' in template

I'm unable to conditionally modify a template's variable value in Go templates, due to the following error: bad character U+003D '=' Minimal reproducible example (derived from the example in the ...
89f3a1c's user avatar
  • 1,458
0 votes
1 answer
23 views

Return a list variable from a helm helper function

I would like to save some boilerplate template code in helm. In my values.yaml I have to fields: schema, schemas which define the same object, once singular and once as list. In my template I would ...
Herr Derb's user avatar
  • 5,040
0 votes
0 answers
14 views

helm: access dict via functions arguments

The fully qualified name of images from the chart including subcharts is returned via a function. The name of the function is custom.image.fullname. The function gets a list as argument. At the first ...
Volker Raschek's user avatar
0 votes
2 answers
37 views

helper function not resolving correctly

Hi I am having a helm chart named test-service. I have a helper chart named helm-common-templates. my chart has dependency on the helm-common-templates. it has a function named "helm-common-...
Starbucks Admin's user avatar
2 votes
1 answer
72 views

How to return a default false if a property dont exists in values.yaml file?

yaml file . i have a value as below defined under global global: logging: log4j: enabled: true I am also have a helper function {{- define "helm-basic-template.logging-enabled" -}...
Starbucks Admin's user avatar
0 votes
1 answer
34 views

Helm dig using dynamic list of values

I am trying to use the dig function in helm to check if a value exists in my dictionary, I have a space delimited string that I want to use as each key to check in the dictionary. For example without ...
user3116846's user avatar
1 vote
1 answer
50 views

helmfile: Put Go Template into environmental values

I have a particular need. I'd like to add a go template to the environment values, but have them interpreted in releases.values. Here's a simplified example: helmfile.yaml releases: - name: cluster ...
stucki-stuck's user avatar
4 votes
2 answers
66 views

Golang text/template multiple conditions with !not operator

How can I chain multiple conditions using indirect template functions in Go? I want to check if .hello doesn't contain "world" and .world doesn't contain "hello", but I cannot ...
Manticore's user avatar
  • 153
0 votes
0 answers
46 views

How to add custom annotations based on labels with alertmanager templates?

I have an Alertmanager, sending alerts to an Alerta. Alerts sent contains annotations field with only description, and a tons of labels. What I would like to do is create a template for Alertmanager ...
Mymy la brute's user avatar
1 vote
1 answer
23 views

How to use the {{ $labels.instance }} syntax within the Prometheus query

Given the Prometheus query syntax below for a annotation field "currentNumber" in the alert.yaml currentNumber: "{{ with query \"max_over_time(json_exporter_resultList__0::...
Bruce's user avatar
  • 661
2 votes
1 answer
41 views

How to check if go template utilizes ALL template data

Let's say I have a template string today i visited {{ .market }} to buy {{ .fruit }} and the provided template data is map[string]string := { market: "whole foods", fruit: "bananas&...
jchi2241's user avatar
  • 2,124
0 votes
1 answer
51 views

How can i use arithmetic operations in the description of a Prometheus Alert?

I have an alert in Prometheus that fires if a SSL Certificate expires 29 days from now. The Alert works perfectly fine. The problem is the Value it returns is not in days. The query i use is as follow:...
Lino Kaiser's user avatar
0 votes
1 answer
23 views

How can I access a value in a parent Helm chart from a subchart containing dashes in its name?

I am trying to access values in a parent Helm chart from a subchart using the method described in this PR: {{ template "foo-bar.fullname" .Subcharts.foo-bar }}-rest-of-string However, I am ...
rasebo's user avatar
  • 968
1 vote
0 answers
27 views

How to force the order of the annotations in a custom alert template (instead of alphabetical order) in Grafana?

I am trying to setup a custom template for my alerts, but I found that whenever I loop through the annotations, it keeps on showing them in alphabetical order instead of the order I initially ...
Mohamed Aziz Tousli's user avatar
1 vote
1 answer
32 views

Creating a "insert if exists" helper function in Helm

I'm creating a library chart that will be used across over a dozen different deployments. Each has only one container, and in the container description I have the following definitions in some but not ...
Kyle Dumouchelle's user avatar
1 vote
0 answers
23 views

How to debug Grafana Message templates for alerts?

I am currently trying to create a Grafana alert for each log in elastic that contains fields.alert:1. The alert itself works, but now I dont want to use the default message template. I tried to come ...
TeaJ's user avatar
  • 35
0 votes
0 answers
59 views

Prometheus Alertmanager notification template periodical buggy output

I'm using kube-prometheus-stack alertmanager (0.25) notification template to send alerts to opsgenie. Grouping is disabled for alertmanager. All alerts have following label: "k8sCluster: dev"...
Ivan's user avatar
  • 1
1 vote
1 answer
111 views

How to parse embed.FS templates with the template.ParseFS function

I want to parse all of the templates in the same template.Template struct but I don't know how and also it gives me an error. I have the next code: package main import ( "embed" &...
otaxhu's user avatar
  • 138
0 votes
1 answer
43 views

Helm chart template: How to render complex structure as is

Scenario: We have 2 settings: commonSettings and appSettings. If a key is present in both commonSettings and appSettings, then the one in appSettings overrides the other. Issue: The complex structure ...
Kiran's user avatar
  • 57.2k
0 votes
0 answers
28 views

How to enter this complex string in helm template?

I have this problematic string I want to use in helm template. Eventually, I'd like my yml file to contain: pattern.console: "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p [My App,%X{X-B3-...
yoel's user avatar
  • 305
1 vote
1 answer
158 views

Grafana won't fully render Slack template

I have Grafana alerting to Slack and now I want to add additional annotation: traces to be displayed in the alert. For some reason it is not being shown in the alert, but I can see this new annotation ...
DisplayName's user avatar
2 votes
1 answer
45 views

How to pass in a map "created on the way" in a go template

I want to make something like a UI component 100% reusable in Go templates but i don't know if it's possible to do it. So I'm trying to do the next: {{define "components/menu-button"}} <a ...
otaxhu's user avatar
  • 138
1 vote
1 answer
48 views

Golang Gorm Fiber / argon2.Config undefined

I'm trying to switch from PHP to GO, but I'm stuck at one point, I ask for your help. I'm trying to create a password hashing function using Argon2, but I keep getting the error "undefined: ...
Ugur Tas's user avatar
  • 224
1 vote
0 answers
59 views

How to add node_filesystem_avail_bytes metric value to description grafana?

I'm having a problem. When I set up alert rules in prometheus, I had a disk space monitoring rule that showed me the percentage of remaining space and humanize the value of the ...
Stanislav_iz's user avatar
0 votes
0 answers
13 views

During helm templating, get list entry which has specific value

In my values.yaml I have the following object: configs: - service1: this: that - service2: this: thisandthat It is obviousely no problem if I don't have this as list like: configs: ...
Herr Derb's user avatar
  • 5,040
2 votes
2 answers
123 views

Grafana Alerting - setting email subject according to alert labels

I'm trying to include dynamic subject into my Grafana (Grafana v9.5.0, datasource - Logstash) alerts. Goal would be to have subject similar to : "$serviceName is failing...". I was trying to ...
eirugn's user avatar
  • 21
0 votes
2 answers
826 views

Difference between $.Values and .Values in Helm

I understand the usage of .Values.varName in Helm chart and which is used to refer the variable from Values.yaml file I would like to know the difference between $.Values.varName and .Values.varName ...
Sathish Kumar's user avatar
0 votes
1 answer
176 views

Template Inheritance in Golang

I am trying to inherit a base template into my *home page file in Golang My directory structure: project_root /templates /layouts base.layout.html /pages home.page.html Gin ...
Sujan Gainju's user avatar
  • 4,450
3 votes
1 answer
84 views

How can I run a range within a range in golang using html/template

I want to run a range within a range using html/template. The sample code (https://go.dev/play/p/fxx61RwIDhd) looks like this: package main import ( "html/template" "os" ) ...
nexty5's user avatar
  • 47
2 votes
1 answer
71 views

Golang Gorm Fiber - How can I send the name I defined as alias to my index template?

I'm trying to switch from PHP to GO, but I'm stuck at one point, I ask for your help. I just define an alias named "durums" in the query, there is no such named field in the database. how ...
Ugur Tas's user avatar
  • 224
2 votes
1 answer
83 views

Golang - Html Template : How do I create a Nav-item - Submenu? I couldn't find how to do it

I'm trying to switch from PHP to GO, but I'm stuck at one point, I ask for your help. I have a table called Menu in the database. Here, menuid equal to 0 becomes the main menu. Those not equal to 0 ...
Ugur Tas's user avatar
  • 224
0 votes
1 answer
190 views

How to check the nested element within line_format expression in Grafana?

I am using the line_format to create a nicer log message and I want to filter out some nested json labels. I currently have the following code {application="app", environment="...
Menelaos Vergis's user avatar
0 votes
1 answer
155 views

How to load array with values using helm (Go template)

I have the following content in a yml file: values: my_values: - value_1 - value_2 - value_3 I also have a _env file where I try to load those values in a list: - name: ...
Chira George's user avatar
0 votes
1 answer
511 views

Argo Workflows template - how to create conditional parameter based on runtime information

i have an argo workflow - where one of the templates needs to receive a parameter that depends on an input variable (in this case the repository). arguments: parameters: - name: ...
light_303's user avatar
  • 2,101
1 vote
1 answer
71 views

GO language always print false condition part in html

About the issue I am using Go language and trying to pass bool variable value from function to html. Please check the function articlesHandler, in which IsLoggedIn value has been initialized to true ...
Pankaj's user avatar
  • 9,812
0 votes
1 answer
196 views

helm template specific multiple value

I want to declare in the _helpers.tpl file that a particular CRD is longer than 63 characters, and apply it to the CRD Name field. I have configured CRDs to be N count created as shown in the values....
Park jinhong's user avatar
1 vote
0 answers
38 views

Golang HTML template trying to display data based on selection of secondary data

I'm not even sure if this is possible with GoLang templates but I am trying to display 2 different select boxes but the second select box displays based on the first select box. // Main category ...
Chris Williamson's user avatar
1 vote
1 answer
35 views

gotemplate not rendering data

func renderTemplate(w http.ResponseWriter, tmpl string, data interface{}) { layout := "static/layout.html" tmplFiles := []string{layout, tmpl} fmt.Printf("%v\n", data) ...
user3709120's user avatar
1 vote
0 answers
81 views

How to load HTML templates from a module in Golang?

I am working on my own project where I have some separate repositories and each repository will have its own template folder and handlers. I want to combine and load templates in the main repository ...
shantanu sharma's user avatar
2 votes
2 answers
556 views

golang text/template startswith function

I don't see any type of startswith function in the Go text/template package. Is this the best implementation? {{if eq (slice $c 0 5) "begin"}}
David Tahvildaran's user avatar
0 votes
1 answer
105 views

kubectl -o go-template > bad character U+002F '/'

I'm trying to get the restartCount of the pod for matching deployment but '/' causing an issue Query: kubectl -n <namespace> get pod -o go-template='{{range .items}}{{if eq .metadata.labels.app....
mansing shinde's user avatar
0 votes
1 answer
24 views

Is it possible to display the value of an environment variable in a Tyk Dashboard template file?

I'm trying to reference an environment variable in Tyk Dashboard. I set up a docker-compose.yaml file containing environment variables: version: '3.6' services: tyk-portal: image: tykio/portal:...
Patrick's user avatar
  • 1,878
0 votes
1 answer
175 views

Bug in Helm template rending when injecting text into template via .Files.Get?

I am having difficulty determining whether a portion of a rendered Helm Chart template is technically faulty and may fail me in the future. The YAML in question is accepted right now by both Helm (...
Kevin Serikstad's user avatar
1 vote
2 answers
241 views

How to assign a variable of a go template inside a go template?

I'm just starting to use golang and the template system to redevelop my webserver. Now I just want to write constant variables for each website but I don't even really know what I'm searching. I hope ...
Noah Till's user avatar
0 votes
1 answer
408 views

How know if a submap has a key on Helm

I have this values.yaml microservices: - name: service-1 - name: service-2 ingress: enabled: false I want to know if microservices.X.ingress.enabled exists. This is because if don't ...
ajotaops's user avatar
1 vote
3 answers
77 views

How to render a "template of templates", without escaping each action

Does anyone know how to render a "template of templates" with text/template, where only specific actions (ie: things wrapped in {{...}}) will be rendered, and the rest will be treated as ...
modulitos's user avatar
  • 14.9k

1
2 3 4 5
17