Links

Templates

Use Templates to transform Parameter and Secret values into any format.
Templates allow you to transform your parameters and secrets into various required formats. Templates are created at an organization project scope allowing you to customize templates for your specific projects.
We use the popular Liquid Template Language for our templates.

Creating Templates

Once you've created a set of parameters, you can reference them in your project's templates.
Quickly start with sample templates for JSON, YAML, ConfigMaps, TFVars, etc.
Select the designated project from the left-hand menu and click Create New Template to open the Create Template dialogue.
Once the template is created, use the edit window to customize it. The template format is user-defined. In this example, we're following a JSON format. Parameters are referenced by name with Liquid notation.
The preview window will display the evaluated results based on the selected environment. You can validate your template by clicking Preview. Secrets are automatically hidden in templates and can be unmasked with the Show Secrets button.
Click Submit to save changes to the template.
Your application can reference templates with CloudTruth CLI.

Automatic Parameters

In addition to your parameters, CloudTruth adds several automatic parameters that can be referenced in templates:
cloudtruth.self
The name of the current template.
cloudtruth.project
The name of the current project.
cloudtruth.environment
The name of the current environment.
cloudtruth.templates.<name>
evaluates template <name> against the current environment and includes its contents in this template.
cloudtruth.parameters.<name>
Another way to reference the parameter <name>.
cloudtruth.projects.<name>
A reference to another project. See below for more on referencing parameters and templates in other projects.
CloudTruth will prevent you from creating a circular reference between templates (for example, template A references template B, template B references templates C, and template C references template A). If you create one by mistake, we'll show the loop to you.

Parameters with Untraditional Names

CloudTruth allows parameters to have any name you like, but Liquid follows the traditional identifier naming conventions-- alphanumerics and underscores only. If you need to reference a parameter with another character in it, such as
{{ My.Non Traditional Parameter Name! }}
You'll confuse Liquid. Instead, reference it like this:
{{ cloudtruth["My.Non Traditional Parameter Name!"] }}
... and you'll keep Liquid happy.
You can use this notation for any other reference, for example cloudtruth.templates["My.Non Traditional Template Name!"].

Parameters and Templates from Other Projects

By default, all parameters and templates are referenced from the current project. If you'd like to reference a parameter from another project, you can bring it into your template via cloudtruth.projects.<other_proj_name>.parameters.<param_name>. Likewise, you can reference a template from another project as cloudtruth.projects.<other_proj_name>.templates.<template_name>.

Parameter Attributes

All parameters automatically include attributes to allow retrieving attributes of that parameter. For example, to see the ID of your current project, use cloudtruth.project.id. These attributes are derived from the API and match the meaning in the API. The full list of available attributes is:
Attribute
Applies To
Description
id
All objects
The ID of the object.
name
All objects
The name of the object.
description
All objects
The description of the object.
parent
Environments
The parent Environment of the current Environment.
depends_on
Projects
Project that the specified project depends on.
value
Parameters and Templates
The value of the object.
secret
Parameters and Templates
If True, the object is a secret.
type
Parameters and Templates (including cloudtruth.self)
The type of the object.

CloudTruth Filters

In addition to the usual filters Liquid provides, CloudTruth adds a few new ones for you:
Custom Filter
Description
dns_safe
Ensures the value is safe for use as a DNS name or Kubernetes resources name.
env_safe
Ensures the value is safe for setting as shell environment variable.
key_safe
Ensures the value is safe for use as a key inside the Kubernetes ConfigMap/Secret data hash.
indent: count
Indents each line in the value by count spaces.
nindent: count
Adds a leading newline, then indents each line in the value by count spaces.
parse_yaml
Parses a YAML string into a structured representation.
to_yaml
Converts an object to a YAML representation.
parse_json
Parses a JSON string into a structured representation.
to_json
Converts an object to a JSON representation.
encode64
Base64 encodes a value.
decode64
Base64 decodes a value.
sha256
Takes the sha256 digest of a value.
merge: other
Merges the other hash value into this one.
re_replace: pat, repl, flags
Regular expression replaces pattern pat in the value with replacement repl, with optional flags "i" for ignore case, "m" for multiline and "x" for extended.
re_contains: pat, flags
Returns a boolean indicating whether the pattern pat is found in the value, with optional flags as re_replace.
names
Given a dictionary of parameters (e.g. cloudtruth.parameters), return a list of parameter names.
values
Given a dictionary of parameters, return a list of parameter values. Note that parameter attributes are still available to objects in this list.

Templates and Secrets

Templates cannot be secrets, but they CAN reference secrets. If you have secret information to use in a template, store it in a secret Parameter and reference it in your dynamic value. Any template that references secrets then becomes an implicit secret and thus behaves like a secret, for example, by requiring extra actions to display the actual values

Template History

You can view the history of raw project templates in the history page. Selecting Templates will bring up a template list for your specified project.

Template History by Tag

You can select an environment tag to compare the project's current templates to and click Apply.
The table now displays a dropdown to show any differences in the templates for the current time compared to the templates content at the selected tag. Selecting the dropdown will bring up a side-by-side view of the template with highlighted differences.

History by date

You can select a date and approximate time to compare the project's current templates to and click Apply.
The table now displays a dropdown to show any differences in the templates for the current time compared to the templates content at the selected time. Selecting the dropdown will bring up a side by side view of the template with highlighted differences.