CUE v0.12.0 introduced file embedding, which enables a powerful way for CUE configurations to consume data files.
This guide demonstrates how to use file embedding as a flexible alternative to the
--path/-l flag
when handling multiple data files:
allowing their contents to be placed at arbitrary locations in an evaluation;
to be validated by different constraints;
and to have their data used elsewhere in the configuration.
file.cue
@extern(embed)
package example
// Embed the contents of the data files.
_places: _ @embed(file=addresses.yml)
_dates:  _ @embed(file=birthdays.json)
// Validate the contents of the data files.
_places: [_]: [string, ...string]
_dates: [_]: =~#"^\d{4}-\d{2}-\d{2}$"#
// Emit the selected data.
jamie: {
	address:  _places.jamie
	birthday: _dates.jamie
}jamie:
  - 1 Main Street
  - Townsville
  - West Fooshire
alex:
  - 42 The Parade
  - Village-on-the-Wold
  - Countyshire{
    "alex": "1984-02-29",
    "jamie": "2000-01-01",
    "charlie": "1950-06-26"
}TERMINAL
$ cue export --out yaml
jamie:
  address:
    - 1 Main Street
    - Townsville
    - West Fooshire
  birthday: "2000-01-01"Related content
- Reference: cue help embed
- How-to Guide: Embedding files in a CUE evaluation
