Helm Configmap Template: Cannot add quotes to values in template

10/13/2019

Here is my file in configfiles folder config.tmpl:

<Resource name="database"
  auth="Adam"
  type="java.sql.datasource"
  url={{ .Values.config.url }}
  password={{ .Values.config.pwd }}
  maxidle="10"/>

my config map template:

apiVersion: v1
kind: ConfigMap
metadata:
  name: test-config
data:
  {{tpl (.Files.Glob "configfiles/*").AsConfig | nindent 2 }}

here is my values.yaml

config:
  url: "jdbc db url"
  pwd: "xxxxxx"

when I render the template, here is the output

<Resource name="database"
  auth="Adam"
  type="java.sql.datasource"
  url=jdbc_db_url
  password=xxxxxx
  maxide="10"/>

Both url and password need to be in quotes, url = "jdbc_db_url" password="xxxxxx". I tried using the below approaches

1. url={{ .Values.config.url | quote}} this results in an error
2. url="{{ .Values.config.url }}" this works for password but not for url

Any ideas on how to get this correct?

-- user1708730
configmap
double-quotes
kubernetes-helm
templates

0 Answers