Functions
Configuration files can use built-in functions which are interpolated at runtime. For example the env(<environment-variable-name>)
function could be used to return the value of an environment variable.
env
The env
function can be used to interpolate a system set environment variable inside your configuration.
len
The len
function returns the length of a string or an array.
home
The home
function returns the location of the current users HOME folder.
file
The file
function returns the contents of a file at the given path.
dir
The dir
function returns the directory of the file containing the current resource.
trim
The trim
function removes whitespace from the given string.
docker_ip
The docker_ip
function returns the ip address of the configured docker host.
docker_host
The docker_host
function returns the socket or TCP address for the current Docker host.
data
The data
function creates a temporary folder that exists until sandbox is destroyed. Data folders are created with the permissions 755
.
First use of data
creates the folder, subsequent uses return the path.
data_with_permissions
The data_with_permissions
function creates a temporary folder that exists until the sandbox is destroyed. Unlike data
, data_with_permissions
allows you to specify the directory permissions as a parameter.
First use of data_with_permissions
creates the folder, subsequent uses return the path.
system
When "os" is passed in as a parameter it returns the OS of the system (darwin, linux, windows, etc.), and when "arch" is passed in as a parameter it returns the architecture of the system (amd64, arm64, etc.).
template_file
Returns the rendered contents of a template file at the given path with the given input variables.
Templates can leverage the Handlebars templating language, more details on Handlebars can be found at https://handlebarsjs.com/
Template helpers
The template_file
function provides helpers that can be used inside your templates as shown in the examples below.
quote
Returns the original string wrapped in quotations, quote can be used with the Go template pipe modifier.
trim
Removes whitespace such as carrige returns and spaces from the begining and the end of the string, can be used with the Go template pipe modifier.
Last updated