Introduction
Avoid YAML templating and use something to generate YAML, programmatically.
This uses Lua (the programming language) to generate YAML file manifests.
This is a self contain binary, no external dependencies needed.
Getting Started
Lua is simple.
It supports strings, numbers, boolean, arrays, and maps.
-
Create a file called manifest.lua
.
-
Give it the contents.
return {name="Hello World"}
The last expression of your manifest.lua
file should always have a return
statement of a hash or array (table
type in Lua).
You will receive in error if the type is incorrect.
See the examples for more advance usage.
-
Invoke either from source or releases.
-
The stdout will be the following YAML payload.
name: Hello World
null
support
Lua has one quirk.
If a table
(array or hash) has a nil
value entry it is no longer considered as contiguous entry in the table
.
This results in the outputted YAML not having a null
entry.
To resolve this a null
value was created in ly
's lua runtime.
The following Lua:
return {name=null}
will render YAML as:
name: null
Installation
Source
The source uses go.mod
for dependency management.
Please ensure that golang
version 0.12.x or higher is installed.
$ git clone https://github.com/jtarchie/ly
$ cd ly
$ go run ly/main.go -c examples/variable.lua
list_with_a_map:
- key1: value1
key2: value2
- item2
Releases
- Download the latest release.
- Extract the binary from the
.tar.gz
file -- ie tar xzf ~/Downloads/ly_*.tar.gz
.
- Put it into an executable
PATH
-- ie chmod +x ~/Downloads/ly_* && mv ly_ /usr/local/bin/ly
.
- Run
ly -c <your-lua-file>.lua