Difficulty: beginner
Estimated Time: 2 minutes

First steps with Spiff

spiff is a command line tool and declarative in-domain hybrid YAML templating system.

While regular templating systems process a template file by substituting the template expressions by values taken from external data sources, in-domain means that the templating engine knows about the syntax and structure of the processed template. It therefore can take the values for the template expressions directly from the document processed, including those parts denoted by the template expressions itself.

You've completed your first Katacoda scenario!

Spiff++ Introduction

Step 1 of 2

Example 1 - Simple in-domain processing

We start with a simple document: deployment.yaml

Adding url

First add a key url whose value is build from a string literals and the value of the field version. Expressions are surrounded with (( )):

  url: (( "http://apps.mycompany.com/myapp?version=" version ))

Adding description

Then add a similar expression for a description :

  description: (( "This document describes a " name " located at " url ))

Executing document processing

To procress the deployment.yaml document, the spiff tool is called with the command merge and the filename.

spiff merge deployment.yaml

Creating result in JSON

Spiff outputs the resulting document as YAML by default. To generate JSON, use the --json command line option:

spiff merge --json deployment.yaml