ly

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 5 Imported by: 0

README

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.

  1. Create a file called manifest.lua.

  2. 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.

  3. Invoke either from source or releases.

  4. 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

  1. Download the latest release.
  2. Extract the binary from the .tar.gz file -- ie tar xzf ~/Downloads/ly_*.tar.gz.
  3. Put it into an executable PATH -- ie chmod +x ~/Downloads/ly_* && mv ly_ /usr/local/bin/ly.
  4. Run ly -c <your-lua-file>.lua

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONMarshal

func JSONMarshal(value lua.LValue) ([]byte, error)

Encode returns the JSON encoding of value.

func NewState

func NewState() *lua.LState

func YAMLMarshal

func YAMLMarshal(value lua.LValue) ([]byte, error)

Encode returns the YAML encoding of value.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL