# Sample Templates

### Copy these samples into the CloudTruth Template editor

{% hint style="info" %}
The samples include the relevant CloudTruth CLI command to fetch the template and assume the CloudTruth API key has been exported to an environment variable.&#x20;
{% endhint %}

#### JSON

<pre class="language-liquid" data-line-numbers><code class="lang-liquid"><strong>#
</strong><strong># Iterates through all parameters in the project
</strong><strong>#
</strong>{
{%- for param in cloudtruth.parameters %}
  "{{param[0]}}": "{{param[1]}}"{%unless forloop.last%},{%endunless%}
{%- endfor %}
}
#
#
# Sample CloudTruth CLI command to fetch this template:
# Remove below after copying
#
# Assumes CloudTruth API key is exported to ENV variable
# 
cloudtruth --project {{cloudtruth.project}} template get "{{cloudtruth.self}}"
</code></pre>

#### YAML

{% code lineNumbers="true" %}

```liquid
#
# Iterates through all parameters in the project
#
{%- for param in cloudtruth.parameters -%}
{{param[0]}}: {{param[1]}}
{% endfor -%}
}
#
#
# Sample CloudTruth CLI command to fetch this template:
# Remove below after copying
#
# Assumes CloudTruth API key is exported to ENV variable
# 
cloudtruth --project {{cloudtruth.project}} template get "{{cloudtruth.self}}"
```

{% endcode %}

#### ConfigMap

{% code lineNumbers="true" %}

```liquid
# 
# Sample ConfigMap template Kubetruth will fetch from the platform
#
{% assign params = cloudtruth.parameters | values | where: "secret", false -%}
{% assign version = cloudtruth.parameters | sort | to_json | sha256 | slice: 0, 7 -%}
{% if params.size > 0 -%}
kind: ConfigMap
metadata:
  name: "{{ cloudtruth.project }}"
  namespace: "{{ cloudtruth.environment }}"
  labels:
    version: "{{ version }}"
data:
  {%- for param in params %}
  {{ param.name | key_safe }}: |-
    {{ param.value }}
  {%- endfor %}
{% endif -%}

#
# Sample CloudTruth CLI command to fetch this template:
#
cloudtruth --project {{cloudtruth.project}} template get "{{cloudtruth.self}}"
```

{% endcode %}

#### ShellENV

{% code lineNumbers="true" %}

```liquid
#
# Iterates through all parameters in the project
#
{%- for param in cloudtruth.parameters %}
export {{param[0] | upcase}}="{{param[1]}}"
{%- endfor %}
#
#
# Sample CloudTruth CLI command to fetch this template:
#
cloudtruth --project {{cloudtruth.project}} template get "{{cloudtruth.self}}"y
```

{% endcode %}

#### TFVars

```liquid
###
# Sample Liquid code to list all TF parameters for project {{cloudtruth.project}}
###
#
{%- for x in cloudtruth.parameters %}
TF_VAR_{{x[0]}}="{{x[1]}}"
{%- endfor %}
#
# Sample CloudTruth CLI command to fetch this template:
#
cloudtruth --project {{cloudtruth.project}} template get "{{cloudtruth.self}}"
```

#### Java Properties

```liquid
#File Updated
# -
#{{ "now" | date: "%Y-%m-%d %H:%M" }}
#
#
{%- for param in cloudtruth.parameters -%}
{{param[0]}}={{param[1]}}
{% endfor -%}
#
# Sample CloudTruth CLI command to fetch this template:
#
cloudtruth --project {{cloudtruth.project}} template get "{{cloudtruth.self}}"
```
