YTT transform

This topic tells you about the Application Accelerator YTT transform in Tanzu Application Platform (commonly known as TAP).

The YTT transform starts the YTT template engine as an external process.

Syntax reference

YTT(extraArgs:  // optional
  {
    SPEL-EXPRESSION-1,
    SPEL-EXPRESSION-2,
    ...
  }
)

The YTT transform’s YAML notation does not require any parameters. When invoked without parameters, which is the typical use case, the YTT transform’s input is determined entirely by two things only:

  1. The input files fed into the transform.
  2. The current values for options and derived symbols.

Execution

YTT is invoked as an external process with the following command line:

ytt -f INPUT-FOLDER \
    --data-values-file SYMBOLS-JSON \
    --output-files OUTPUT-FOLDER \
    EXTRA-ARGS

Where:

  • INPUT-FOLDER is a temporary directory into which the input files are materialized. That is, the set of files passed to the YTT transform as input is written out into this directory to allow the YTT process to read them.

  • SYMBOLS-JSON file is a temporary JSON file, which the current option values and derived symbols are materialized in the form of a JSON map. This allows YTT templates in the INPUT-FOLDER to use these symbols during processing.

  • OUTPUT-FOLDER is a fresh temporary directory that is empty at the time of invocation. In a typical scenario, upon completion, the output directory contains files generated by YTT.

  • EXTRA-ARGS are additional command line arguments obtained by evaluating the SPEL expressions from the extraArgs attribute.

When the ytt process completes with exit code 0, the execution of the YTT transform has succeeded. The contents of the output directory becomes the result of the YTT transform.

When the ytt process completes with an exit code other than 0, the execution of the YTT transform has failed, and an exception is raised.

Examples

See the following examples using the YTT transform.

Basic invocation

When you want to execute ytt on the contents of the entire accelerator repository, use the YTT transform as your only transform in the engine declaration.

engine {
  ...
  YTT()
  ...
}

To do anything beyond calling YTT, compose YTT into your accelerator flow using merge or chain combinators. This is exactly the same as composing any other type of transform.

For example, when you want to define some derived symbols as well as merge the results from YTT with results from other parts of your accelerator transform, you can reference this example:

engine {
  // define derived symbols visible to all transforms below (including YTT)
  let theAnswer = 41 +1 in
  {
    Include({"deploy/*.yaml"})
    YTT()
  }
}

Using extraArgs

The extraArgs passes additional command line arguments to YTT. This adds file marks. See File Marks in the Carvel documentation.

For example, the following runs YTT and renames the foo/demo.yml file in its output to bar/demo.yml.

engine {
  YTT(extraArgs: {"--file-mark", "foo/demo.yml:path=bar/demo.yml"})
}
check-circle-line exclamation-circle-line close-line
Scroll to top icon