GustShell.Template (gust_shell v0.1.0)

Copy Markdown View Source

EEx templates for shell task commands and environment values.

Templates are checked when the DAG is parsed and rendered when the task starts, so each attempt sees the current secrets and run params. A template can use:

  • run_id, the current run id
  • run_params, the params the run was triggered with
  • params, the task's own params, such as a map_over item
  • Flows, an alias for Gust.Flows
  • secret!/1, which returns a secret's value by name
  • task_result!/1, which returns the saved result of a task in the same run

Example:

run: "cargo build --release --target <%= run_params["target"] %>"
env:
  TOKEN: '<%= secret!("REGISTRY_TOKEN") %>'
  VERSION: '<%= task_result!("read_version")["stdout"] %>'

Summary

Functions

Renders template for task.

Returns the value of the secret named name.

Returns the saved result of the task named name in the current run.

Raises if template is not a valid EEx template.

Functions

render(template, task)

Renders template for task.

The run is only loaded when the template uses run_params.

secret!(name)

Returns the value of the secret named name.

Raises Ecto.NoResultsError if the secret does not exist.

task_result!(name)

(macro)

Returns the saved result of the task named name in the current run.

The task must have finished before this template renders, which a downstream dependency guarantees. Shell task results are maps with the string keys "stdout", "stderr", "exit_code" and "status", or an empty map when the task does not have save: true.

Raises Ecto.NoResultsError if the task does not exist.

validate!(template)

Raises if template is not a valid EEx template.