Skip to content

Templating

Igor Lysak edited this page Sep 28, 2022 · 4 revisions

Prior to component deployment Hub CLI performs parameters templating in files specified in component manifest templates:

templates:
  kind: curly  # the default, ${} templating engine
  directories:
  - config
  - app/config
  files:
  - "*.template"
  extra:
  - kind: mustache
    directories:
    - terraform
    files:
    - "*.tf.template"
  - kind: go
    files:
    - helm/values*.yaml.gotemplate

A non-recursive glob search is performed on files and directories. files may include directory. Either directory or files must be specified. The example above will match following files relative to component's root:

config/*.template
app/config/*.template
terraform/*.tf.template
helm/values*.yaml.gotemplate

We recommend to suffix template files with .template or .gotemplate and add generated files to .gitignore. In case there is no suffix to strip then substitution will be performed in-place.

Curly

A simple syntax where parameter name for substitution is included between curly brackets ${}, ie. ${kubernetes.api.endpoint}.

Substitution may include encoding function ${param/encoding} where encoding is one of: json, yaml, bcrypt, base64. Multiple encodings are supported, processed in the order above: ${component.dex.passwordDb.password/bcrypt/base64}.

Mustache

Set kind: mustache.

Parameter name enclosed in {{}}. Because of conflict with . special meaning in mustache, it must be replaced with _, for example {{component_cert-manager_issuerEmail}}.

Golang

Set kind: go.

Full-featured Golang templates with - in parameter name replaced with _, for example {{component.cert_manager.issuerEmail}}.

Sprig functions are available.

Clone this wiki locally