Skip to content

Variables and prompting

Variables are declared as an ordered list in the sidecar:

variables:
- name: app_name
description: "Name of the application"
type: str
default: "myapp"
- name: replicas
type: int
default: 3
- name: enable_metrics
type: bool
default: true
- name: runtime
type: choice
choices: ["go", "python", "node"]
default: "go"
FieldRequiredNotes
nameyesThe identifier used inside template files
descriptionnoShown by template variables; used as prompt help
typenostr (default), int, bool, choice
defaultnoAny YAML scalar; keeps its YAML type
choicesonly for choiceList of allowed values

Validation is strict in both directions: type: choice without choices is an error, and choices on a non-choice variable is also an error. An unknown type is rejected.

At apply time each variable resolves through three steps, first match wins:

  1. --var key=value on the command line
  2. default from the sidecar
  3. Interactive prompt
Terminal window
deckctl template apply go-service ./out \
--source local \
--var app_name=billing \
--var replicas=5

--var is repeatable. The value is everything after the first =, so --var motd=key=value sets motd to key=value. A --var entry with no = is silently ignored.

Terminal window
deckctl template variables go-service --source local
┌────────────────┬────────┬─────────┬────────────────────┬─────────────────────────┐
│ Name │ Type │ Default │ Choices │ Description │
├────────────────┼────────┼─────────┼────────────────────┼─────────────────────────┤
│ app_name │ str │ myapp │ │ Name of the application │
│ replicas │ int │ 3 │ │ │
│ enable_metrics │ bool │ true │ │ │
│ runtime │ choice │ go │ go, python, node │ Runtime to target │
└────────────────┴────────┴─────────┴────────────────────┴─────────────────────────┘

This command fetches the template but never renders or writes anything, so it is safe to run against anything. -o json gives you the raw declarations:

Terminal window
deckctl template variables go-service --source local -o json
[
{ "name": "app_name", "description": "Name of the application", "default": "myapp", "type": "str" },
{ "name": "runtime", "default": "go", "type": "choice", "choices": ["go", "python", "node"] }
]

Any variable left without a value after steps 1 and 2 is prompted for, one at a time, using huh.

For scripts and CI, make sure every variable resolves before the prompt step:

Terminal window
deckctl template apply go-service ./out \
--source work \
--tag v1.2.3 \
--var app_name=billing \
--var replicas=5 \
--var enable_metrics=true \
--var runtime=go

--source itself is prompted for when omitted, so always pass it in automation. See Using deckctl in CI.

Copier questions map onto the same model, with two extra capabilities: Jinja-computed defaults and when conditions. See Copier compatibility.