Workspace Configuration Templates
Workspace Manager uses the Go template language to process templated files specified in /shared/workspaceInit.yaml. This guide covers the template syntax and available variables for workspace initialization.
Template Basics
Section titled “Template Basics”Go templates are text files with dynamic expressions enclosed in double curly braces: {{ expression }}. Most content renders directly, with expressions replaced by their evaluated results.
Simple example:
<?phpecho "Hello {{ .name }}";Configuration example:
<?phpreturn [ 'db' => [ 'connection' => [ 'indexer' => [ 'host' => '{{ .env.WORKSPACE_DB_HOST }}', 'dbname' => '{{ .env.WORKSPACE_DB_NAME }}', 'username' => '{{ .env.WORKSPACE_DB_USER }}', 'password' => '{{ .env.WORKSPACE_DB_PASSWORD }}', ] ] ]];Variables
Section titled “Variables”Reference variables by starting with a period: .variableName
Built-in variable:
.env- Contains all environment variables available to the initialization job (see full list below)
Custom variables:
{{ $myVariable := "hello world" }}{{ $myArray := split "a b c" " " }}Functions
Section titled “Functions”Functions are called by name and can take parameters:
{{ $myArray := split "a b c" " " }}Functions can also be used as filters with the pipe operator |:
{{ $myArray := ("a b c" | split " ") }}Available functions:
-
env- Get environment variable value{{ env "ENV_VAR_NAME" }} -
default- Provide fallback value{{ .env.ENV_VAR_NAME | default "default_value" }} -
html- HTML-escape a string{{ "5 > 2" | html }} -
split- Split string by delimiter{{ split "a b c" " " }}{{ "example.foo.com" | split "." }} -
join- Join array with delimiter{{ "a b c" | split " " | join "-" }} {{- /* Result: a-b-c */ -}} -
add- Arithmetic addition{{ "a b c" | split " " | length | add -1 }} {{- /* Result: 2 */ -}}
See default Go template functions for additional built-in functions.
Control Structures
Section titled “Control Structures”Conditionals:
{{- if $expression }} {{- /* First option */ -}}{{- else if $anotherExpression }} {{- /* Else if option */ -}}{{- else }} {{- /* Else option */ -}}{{- end }}Loops:
{{- range $index, $value := $someArrayOrStruct }} {{ $index }}: {{ $value }}{{- end }}Whitespace Control
Section titled “Whitespace Control”Control whitespace around expressions with the minus sign:
{{- expression }}- Remove leading whitespace{{ expression -}}- Remove trailing whitespace{{- expression -}}- Remove whitespace on both sides
Comments
Section titled “Comments”{{- /* This is a comment */ -}}Escaping Curly Braces
Section titled “Escaping Curly Braces”When you need literal {{ or }} in your output (common in Magento env.php files), escape them with backticks:
{{ `{{literal_thing}}` }}Example:
'unsecure' => [ 'base_url' => 'https://{{ .env.WORKSPACE_DOMAIN_1 }}/', 'base_link_url' => '{{ `{{unsecure_base_url}}` }}', 'base_static_url' => null,],Environment Variables
Section titled “Environment Variables”Access environment variables using either .env.VARIABLE_NAME or env "VARIABLE_NAME":
{{ .env.WORKSPACE_NAME }}{{ env "WORKSPACE_NAME" }}Available variables:
| Variable | Description |
|---|---|
WORKSPACE_SHARED_DIR | Shared folder location (currently /shared) |
WORKSPACE_DOMAINS | Space-separated list of all workspace domains |
WORKSPACE_DOMAIN_N | Nth domain name (1-based: WORKSPACE_DOMAIN_1, WORKSPACE_DOMAIN_2, etc.) |
WORKSPACE_SUBDOMAINS | Space-separated list of all subdomains |
WORKSPACE_SUBDOMAIN_N | Nth subdomain (1-based: WORKSPACE_SUBDOMAIN_1, etc.) |
WORKSPACE_NAME | Workspace name/subdomain within the project |
WORKSPACE_ID | Unique workspace ID |
WORKSPACE_PROJECT_NAME | Project name |
WORKSPACE_PROJECT_ID | Unique project ID |
WORKSPACE_TEMPLATE | Workspace type (e.g., m2Ubuntu) |
WORKSPACE_PROJECT_TEMPLATE | Project type (e.g., default) |
WORKSPACE_DEVELOPER | Workspace owner name |
WORKSPACE_DEVELOPER_EMAIL | Workspace owner email |
WORKSPACE_DEVELOPER_ID | Unique owner ID |
WORKSPACE_DB_NAME | Database name for this workspace |
WORKSPACE_DB_HOST | Database hostname (currently db) |
WORKSPACE_DB_USER | Database user (currently root) |
WORKSPACE_DB_PASSWORD | Database password |
WORKSPACE_INIT_TYPE | Initialization type: repo or empty |
WORKSPACE_REPO | Git repository SSH URL (if applicable) |
WORKSPACE_REPO_REF | Branch or tag name used to seed workspace |
Magento Examples
Section titled “Magento Examples”Database Configuration
Section titled “Database Configuration”'db' => [ 'connection' => [ 'indexer' => [ 'host' => '{{ .env.WORKSPACE_DB_HOST }}', 'dbname' => '{{ .env.WORKSPACE_DB_NAME }}', 'username' => '{{ .env.WORKSPACE_DB_USER }}', 'password' => '{{ .env.WORKSPACE_DB_PASSWORD }}', 'model' => 'mysql4', 'engine' => 'innodb', 'initStatements' => 'SET NAMES utf8;', 'active' => '1', 'persistent' => null ], 'default' => [ 'host' => '{{ .env.WORKSPACE_DB_HOST }}', 'dbname' => '{{ .env.WORKSPACE_DB_NAME }}', 'username' => '{{ .env.WORKSPACE_DB_USER }}', 'password' => '{{ .env.WORKSPACE_DB_PASSWORD }}', 'model' => 'mysql4', 'engine' => 'innodb', 'initStatements' => 'SET NAMES utf8;', 'active' => '1', 'driver_options' => [ 1014 => false ] ] ], 'table_prefix' => ''],Redis Sessions
Section titled “Redis Sessions”'session' => [ 'save' => 'redis', 'redis' => [ 'host' => '{{ .env.WORKSPACE_REDIS_HOST | default "127.0.0.1" }}', 'port' => '{{ .env.WORKSPACE_REDIS_PORT | default "6379" }}', 'password' => '', 'timeout' => '2.5', 'persistent_identifier' => '', 'database' => '2', 'compression_threshold' => '2048', 'compression_library' => 'gzip', 'log_level' => '1', 'max_concurrency' => '6', 'break_after_frontend' => '5', 'break_after_adminhtml' => '30', 'first_lifetime' => '600', 'bot_first_lifetime' => '60', 'bot_lifetime' => '7200', 'disable_locking' => '0', 'min_lifetime' => '60', 'max_lifetime' => '2592000', 'sentinel_master' => '', 'sentinel_servers' => '', 'sentinel_connect_retries' => '5', 'sentinel_verify_master' => '0' ]],Redis Cache
Section titled “Redis Cache”'cache' => [ 'frontend' => [ 'default' => [ 'id_prefix' => '0e2_', 'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis', 'backend_options' => [ 'server' => '{{ .env.WORKSPACE_REDIS_HOST | default "127.0.0.1" }}', 'database' => '0', 'port' => '{{ .env.WORKSPACE_REDIS_PORT | default "6379" }}', 'password' => '', 'compress_data' => '1', 'compression_lib' => '' ] ], 'page_cache' => [ 'id_prefix' => '0e2_' ] ], 'allow_parallel_generation' => false],Downloadable Domains
Section titled “Downloadable Domains”'downloadable_domains' => [{{- $domainArr := split .env.WORKSPACE_DOMAINS " " }}{{- range $ix, $domain := $domainArr }} '{{ $domain }}'{{ if lt $ix (len $domainArr | add -1) }},{{ end }}{{- end }}],Base URLs and Search Engine
Section titled “Base URLs and Search Engine”'system' => [ 'default' => [ 'web' => [ 'unsecure' => [ 'base_url' => 'https://{{ .env.WORKSPACE_DOMAIN_1 }}/', 'base_link_url' => '{{ `{{unsecure_base_url}}` }}', 'base_static_url' => null, 'base_media_url' => null ], 'secure' => [ 'base_url' => '{{ `{{unsecure_base_url}}` }}', 'base_link_url' => '{{ `{{secure_base_url}}` }}', 'base_static_url' => null, 'base_media_url' => null ], 'default' => [ 'front' => 'cms' ], 'cookie' => [ 'cookie_path' => null, 'cookie_domain' => null ] ], 'catalog' => [ 'search' => [ 'engine' => 'elasticsearch7', 'elasticsearch7_server_hostname' => '{{ .env.WORKSPACE_DB_HOST }}', 'elasticsearch7_server_port' => '{{ .env.WORKSPACE_ELASTICSEARCH_PORT | default "9200" }}', 'elasticsearch7_index_prefix' => '{{ .env.WORKSPACE_NAME }}' ] ] ]]