vs code formats yaml file with extra spaces between brackets

Viewed 1228

I use vscode as an editor and have several yaml files in the project where parameter replacement occurs. However, it re-formats only one file with extra spaces between brackets, a file named service.yaml used by helm in our ci/cd pipeline. See below for before and after. enter image description here

and after enter image description here

I was wondering if the name of the file has particular significance for vscode or any other extensions... Thanks.

2 Answers

Uncheck Bracket Spacing in Extensions/YAML.

enter image description here

Edit: There is a caveat. This will format {{ foo }} or { { foo } } to {{foo}}, which is not necessarily syntactically correct in terms of Jinja templating.

One of the way how to resolve this issue - wrap values into the quotes.

Like this:

app: "{{ .Values.name }}"

Probably not the best solution, but it works for me.

Related