Sprig and Gomplate functions don't work when templates are wrapped with double quotes and also use double quotes inside the template
Describe the Bug
components:
terraform:
postgres-database-base:
metadata:
type: abstract
vars:
application: "my-app"
resource_names:
application_schema_name: "{{ .vars.application | replace "-" "_" }}"
database_name: "{{ .vars.application | strings.ReplaceAll "-" "_" }}"
The above code produces:
invalid stack manifest 'catalog/postgres-database-base.yaml'
yaml: line X: did not find expected key
Whereas changing the double quotes around the outside of the templates on both application_schema_name and database_name` to single quotes works properly.
Expected Behavior
Expected it to work like helm, where the double quotes inside the template are treated separately from the double quotes outside of the template.
Steps to Reproduce
Have a template that uses sprig or gomplate functions where double quotes are needed inside the template, and wrap that in double quotes. Run atmos terraform plan. Change the outer double quotes to single quotes. Run atmos terraform plan again.
Screenshots
No response
Environment
- OS: MacOS Sequoia 15.6.1
- Version: 1.182.0
- Module version: N/A
- Terraform version: N/A
Additional Context
No response
This isn’t an Atmos bug — it’s YAML doing exactly what it’s supposed to.
In YAML, writing:
foo: "this" "that"
means two adjacent strings, which YAML concatenates into thisthat.
If what you actually want is the literal text with quotes inside it:
foo: "this\" \"that"
that produces the value this" "that.
Atmos doesn’t alter this — it just reads the YAML after it’s parsed. So the difference is purely YAML syntax.
The good news: you don’t actually need to wrap it in quotes at all if you use YAML’s block scalar style. For example:
foo: >
{{ ... }}
Also, the { ... } is valid JSON map notation. YAML is a superset of JSON.
We should really write up a document explaining all this.
So if you write the following, YAML things it's a busted JSON map, not a go template. Therefore you need the > block scalar.
foo: {{ .... }}
Hi @osterman I opened this at the request of @aknysh: https://sweetops.slack.com/archives/C031919U8A0/p1759327368455859?thread_ts=1759274940.648179&cid=C031919U8A0
I do understand yaml parsing of quotes, and I would like to counter that helm has no issue passing what's inside a template {{ }} to the go-template parser even when the template is wrapped in double quotes, so I beg to consider that the request is valid from the standpoint that this isn't so much of a YAML parsing issue as it is an order of operations issue.
❯ head -1 values.yaml templates/a.yaml
==> values.yaml <==
a: "foo"
==> templates/a.yaml <==
b: "{{ .Values.a | replace "f" "b" }}"
❯ helm template .
---
# Source: test/templates/a.yaml
b: "boo"