What is the difference between the quote function vs using quotation marks?

Dan

Why should I prefer this:

args: [{{ Values.somevalue | quote }}]

to this

args: ["{{ Values.somevalue }}"]

I feel like I read about the difference somewhere but I can find anything about what "" do in the docs, they only mention | quote. But if the two lines I wrote above are equivalent, why would they bother creating the quote function in the first place?

David Maze

It looks like quote's actual interesting property is that it can take arbitrarily many parameters, quotes each of them, and puts a single space between each

{{ $v := "foo" }}
{{ quote $v "bar" "baz" }}
{{/* "foo" "bar" "baz" */}}

If you had a need to include it in an extended pipeline, the function form could be convenient.

{{ list (quote $x) | toJson }}
{{/* ["\"foo\""] */}}

But otherwise it doesn't seem to do anything special, and in particular doesn't do any quote escaping.

{{ $x := "foo" -}}
{{/* All produce "foo": */}}
"{{ $x }}"
{{ $x | quote }}
{{ $x | printf "\"%s\"" }}

{{/* Not what you hoped for: */}}
{{ $y := "bar\", \"baz" }}
{{ $y | quote }}
{{/* "bar", "baz" */}}

(FWIW I almost always {{ ... | quote }}; but I think when I started learning Helm I also expected this to actually do escaping and it doesn't.)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

For Python language, What is the difference between single and double quotation marks

Is there a way of removing quotation marks when using the quote crate?

Remove quotation marks between tags using regex

What's the difference between using quotation with parameters and not using in a shell script

hashtages between quotation marks

Using quotation marks inside quotation marks

Using quotation marks inside quotation marks

Search numbers between quotation marks and remove it (VS Code)

What is the difference between quote and double quote in mssql

What is the difference between quote and list?

Dealing with quotation marks in a quote-surrounded string

What is the reason to add quotation marks around R function names?

what is the difference between single quotation ' and double quotation " on CSS?

Insert white space between double quotation marks using gsub in Ruby

PostgreSQL : what are simple quotation marks for?

What is the difference, if any, between using single quote and double quote in a python dictionary?

Analyze a string between quotation marks containing single quotation marks with ANTLR

Using sed with quote marks

Using quotation marks in Javascript with innerHTML

using variable within quotation marks

What's the difference between manipulating a prop using a constant vs. using a function?

What is the difference between using the '*' operator vs the '%' operator when using the rand() function in C++?

What's the difference between substitute and quote in R

What is the difference between single quote identifiers and double-quote in ClojureScript?

What is the difference between bash string with quote and without quote

Difference between using or not using Back Quote

what is the difference between [=] vs [this]?

JS: what's the difference between function vs method on function expressions?

What is the difference between executing in subshells vs using & vs coproc command?