1

In the helm template, I want to write something like below:

{{- if empty .Values.conf.proxy_server.filter:authtoken.auth_uri -}}
{{- $_ := tuple "identity" "internal" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup"| set .Values.conf.proxy_server.filter:authtoken "auth_uri" -}}
{{- end -}}

Since there is a colon in filter:authtoken, I got the error as below:

Error: parse error in "swift/templates/configmap-etc.yaml": template: swift/templates/configmap-etc.yaml:20: expected :=

In values.yaml, the snippet is as below:

conf:
  proxy_server:
    filter:authtoken:
      paste.filter_factory: keystonemiddleware.auth_token:filter_factory
      auth_type: password
      ......

So anyway to workaround this ?

1 Answer 1

0

That's not valid YAML; but YAML being YAML there are multiple ways to "spell" things. (All valid JSON is valid YAML.) Among other options, you can quote the key in the values file:

conf:
  proxy_server:
    "filter:authtoken":
      paste.filter_factory: "keystonemiddleware.auth_token:filter_factory"
      auth_type: password
      ......

(I've also quoted the value with a colon in in...just in case it gets misinterpreted as a mapping.)

When you go to read it back, you probably will have to use the Go text/template index function to pluck the value out, since it doesn't look like an ordinary name.

{{- if empty (index .Values.conf.proxy_server "filter:authtoken").auth_uri -}}

Since, as a chart author, you control what you're looking for in the values.yaml file, it may be easier to just pick a more neutral punctuation mark like a period or underscore, and avoid all of this.

1
  • David, thank you so much for the instructions. (index .Values.conf.proxy_server "filter:authtoken").auth_uri works for me. And the reason of attribute name like "filter:authtoken" is that it is from swift configuration file.
    – 英佶孙
    Dec 10, 2018 at 1:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.